|
50 | 50 | from ietf.idrfc.idrfc_wrapper import BallotWrapper, IdWrapper, RfcWrapper |
51 | 51 | from ietf.ietfworkflows.utils import get_full_info_for_draft |
52 | 52 | from ietf.doc.models import * |
53 | | -from ietf.doc.utils import get_chartering_type, needed_ballot_positions, active_ballot_positions |
| 53 | +from ietf.doc.utils import * |
54 | 54 | from ietf.utils.history import find_history_active_at |
55 | 55 | from ietf.ietfauth.decorators import has_role |
56 | 56 |
|
@@ -190,23 +190,7 @@ def document_history(request, name): |
190 | 190 | # grab event history |
191 | 191 | events = doc.docevent_set.all().order_by("-time", "-id").select_related("by") |
192 | 192 |
|
193 | | - # fill in revision numbers |
194 | | - event_revisions = list(NewRevisionDocEvent.objects.filter(doc=doc).order_by('time', 'id').values('rev', 'time')) |
195 | | - |
196 | | - cur_rev = doc.rev |
197 | | - if doc.get_state_slug() == "rfc": |
198 | | - cur_rev = "RFC" |
199 | | - |
200 | | - for e in events: |
201 | | - while event_revisions and e.time < event_revisions[-1]["time"]: |
202 | | - event_revisions.pop() |
203 | | - |
204 | | - if event_revisions: |
205 | | - cur_rev = event_revisions[-1]["rev"] |
206 | | - else: |
207 | | - cur_rev = "00" |
208 | | - |
209 | | - e.rev = cur_rev |
| 193 | + augment_events_with_revision(doc, events) |
210 | 194 |
|
211 | 195 | return render_to_response("idrfc/document_history.html", |
212 | 196 | dict(doc=doc, |
@@ -255,13 +239,21 @@ def document_writeup(request, name): |
255 | 239 |
|
256 | 240 | def document_ballot_content(request, doc, ballot_id, editable=True): |
257 | 241 | """Render HTML string with content of ballot page.""" |
| 242 | + all_ballots = list(BallotDocEvent.objects.filter(doc=doc, type="created_ballot").order_by("time")) |
| 243 | + augment_events_with_revision(doc, all_ballots) |
| 244 | + |
| 245 | + ballot = None |
258 | 246 | if ballot_id != None: |
259 | | - ballot = doc.latest_event(BallotDocEvent, type="created_ballot", pk=ballot_id) |
260 | | - else: |
261 | | - ballot = doc.latest_event(BallotDocEvent, type="created_ballot") |
| 247 | + ballot_id = int(ballot_id) |
| 248 | + for b in all_ballots: |
| 249 | + if b.id == ballot_id: |
| 250 | + ballot = b |
| 251 | + break |
| 252 | + elif all_ballots: |
| 253 | + ballot = all_ballots[-1] |
262 | 254 |
|
263 | 255 | if not ballot: |
264 | | - raise Http404() |
| 256 | + raise Http404 |
265 | 257 |
|
266 | 258 | deferred = None |
267 | 259 | if doc.type_id == "draft" and doc.get_state_slug("draft-iesg") == "defer": |
@@ -314,14 +306,20 @@ def document_ballot_content(request, doc, ballot_id, editable=True): |
314 | 306 | text_positions = [p for p in positions if p.discuss or p.comment] |
315 | 307 | text_positions.sort(key=lambda p: (p.old_ad, p.ad.plain_name())) |
316 | 308 |
|
317 | | - all_ballots = BallotDocEvent.objects.filter(doc=doc, type="created_ballot") |
| 309 | + ballot_open = not BallotDocEvent.objects.filter(doc=doc, |
| 310 | + type__in=("closed_ballot", "created_ballot"), |
| 311 | + time__gt=ballot.time, |
| 312 | + ballot_type=ballot.ballot_type) |
| 313 | + if not ballot_open: |
| 314 | + editable = False |
318 | 315 |
|
319 | 316 | return render_to_string("idrfc/document_ballot_content.html", |
320 | 317 | dict(doc=doc, |
321 | 318 | ballot=ballot, |
322 | 319 | position_groups=position_groups, |
323 | 320 | text_positions=text_positions, |
324 | 321 | editable=editable, |
| 322 | + ballot_open=ballot_open, |
325 | 323 | deferred=deferred, |
326 | 324 | summary=summary, |
327 | 325 | all_ballots=all_ballots, |
|
0 commit comments