|
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 |
|
@@ -96,10 +96,12 @@ def document_main(request, name, rev=None): |
96 | 96 | group = doc.group |
97 | 97 | print group |
98 | 98 |
|
99 | | - revisions = [ doc.rev ] |
100 | | - for h in doc.history_set.order_by("-time"): |
| 99 | + revisions = [] |
| 100 | + for h in doc.history_set.order_by("time", "id"): |
101 | 101 | if h.rev and not h.rev in revisions: |
102 | 102 | revisions.append(h.rev) |
| 103 | + if not doc.rev in revisions: |
| 104 | + revisions.append(doc.rev) |
103 | 105 |
|
104 | 106 | snapshot = False |
105 | 107 |
|
@@ -192,23 +194,7 @@ def document_history(request, name): |
192 | 194 | # grab event history |
193 | 195 | events = doc.docevent_set.all().order_by("-time", "-id").select_related("by") |
194 | 196 |
|
195 | | - # fill in revision numbers |
196 | | - event_revisions = list(NewRevisionDocEvent.objects.filter(doc=doc).order_by('time', 'id').values('rev', 'time')) |
197 | | - |
198 | | - cur_rev = doc.rev |
199 | | - if doc.get_state_slug() == "rfc": |
200 | | - cur_rev = "RFC" |
201 | | - |
202 | | - for e in events: |
203 | | - while event_revisions and e.time < event_revisions[-1]["time"]: |
204 | | - event_revisions.pop() |
205 | | - |
206 | | - if event_revisions: |
207 | | - cur_rev = event_revisions[-1]["rev"] |
208 | | - else: |
209 | | - cur_rev = "00" |
210 | | - |
211 | | - e.rev = cur_rev |
| 197 | + augment_events_with_revision(doc, events) |
212 | 198 |
|
213 | 199 | return render_to_response("idrfc/document_history.html", |
214 | 200 | dict(doc=doc, |
@@ -257,13 +243,21 @@ def document_writeup(request, name): |
257 | 243 |
|
258 | 244 | def document_ballot_content(request, doc, ballot_id, editable=True): |
259 | 245 | """Render HTML string with content of ballot page.""" |
| 246 | + all_ballots = list(BallotDocEvent.objects.filter(doc=doc, type="created_ballot").order_by("time")) |
| 247 | + augment_events_with_revision(doc, all_ballots) |
| 248 | + |
| 249 | + ballot = None |
260 | 250 | if ballot_id != None: |
261 | | - ballot = doc.latest_event(BallotDocEvent, type="created_ballot", pk=ballot_id) |
262 | | - else: |
263 | | - ballot = doc.latest_event(BallotDocEvent, type="created_ballot") |
| 251 | + ballot_id = int(ballot_id) |
| 252 | + for b in all_ballots: |
| 253 | + if b.id == ballot_id: |
| 254 | + ballot = b |
| 255 | + break |
| 256 | + elif all_ballots: |
| 257 | + ballot = all_ballots[-1] |
264 | 258 |
|
265 | 259 | if not ballot: |
266 | | - raise Http404() |
| 260 | + raise Http404 |
267 | 261 |
|
268 | 262 | deferred = None |
269 | 263 | if doc.type_id == "draft" and doc.get_state_slug("draft-iesg") == "defer": |
@@ -316,14 +310,20 @@ def document_ballot_content(request, doc, ballot_id, editable=True): |
316 | 310 | text_positions = [p for p in positions if p.discuss or p.comment] |
317 | 311 | text_positions.sort(key=lambda p: (p.old_ad, p.ad.plain_name())) |
318 | 312 |
|
319 | | - all_ballots = BallotDocEvent.objects.filter(doc=doc, type="created_ballot") |
| 313 | + ballot_open = not BallotDocEvent.objects.filter(doc=doc, |
| 314 | + type__in=("closed_ballot", "created_ballot"), |
| 315 | + time__gt=ballot.time, |
| 316 | + ballot_type=ballot.ballot_type) |
| 317 | + if not ballot_open: |
| 318 | + editable = False |
320 | 319 |
|
321 | 320 | return render_to_string("idrfc/document_ballot_content.html", |
322 | 321 | dict(doc=doc, |
323 | 322 | ballot=ballot, |
324 | 323 | position_groups=position_groups, |
325 | 324 | text_positions=text_positions, |
326 | 325 | editable=editable, |
| 326 | + ballot_open=ballot_open, |
327 | 327 | deferred=deferred, |
328 | 328 | summary=summary, |
329 | 329 | all_ballots=all_ballots, |
|
0 commit comments