From 85708073f04fa6ca57cc7b6ac320cf7f2cddf33d Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Wed, 2 May 2012 11:32:42 +0000 Subject: [PATCH 1/6] Fix "yes" calculation in needed_ballot_position (bug found by Robert Sparks). - Legacy-Id: 4347 --- ietf/doc/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ietf/doc/utils.py b/ietf/doc/utils.py index b48c1ccbb..a75ea5a4f 100644 --- a/ietf/doc/utils.py +++ b/ietf/doc/utils.py @@ -60,7 +60,7 @@ def needed_ballot_positions(doc, active_positions): recuse = [p for p in active_positions if p and p.pos_id == "recuse"] answer = [] - if yes < 1: + if len(yes) < 1: answer.append("Needs a YES.") if blocking: if blocking: From b869d9f9dc9522e97029b37126d12b7c377b6164 Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Wed, 2 May 2012 11:36:41 +0000 Subject: [PATCH 2/6] Change max acronym length to 10 instead of 8 - Legacy-Id: 4348 --- ietf/wginfo/edit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ietf/wginfo/edit.py b/ietf/wginfo/edit.py index 6ae1319fb..79ee29389 100644 --- a/ietf/wginfo/edit.py +++ b/ietf/wginfo/edit.py @@ -21,7 +21,7 @@ from ietf.person.forms import EmailsField class WGForm(forms.Form): name = forms.CharField(max_length=255, label="WG Name", required=True) - acronym = forms.CharField(max_length=8, label="WG Acronym", required=True) + acronym = forms.CharField(max_length=10, label="WG Acronym", required=True) chairs = EmailsField(label="WG Chairs", required=False) secretaries = EmailsField(label="WG Secretaries", required=False) techadv = EmailsField(label="WG Technical Advisors", required=False) From 5fcd0297edac0558db5ca00fb39682c86ca5e1da Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Wed, 2 May 2012 12:16:25 +0000 Subject: [PATCH 3/6] Reverse direction of revisions on charter /doc/ page to match tools.ietf.org/html/draft-*. - Legacy-Id: 4349 --- ietf/idrfc/views_doc.py | 6 ++++-- ietf/templates/idrfc/document_charter.html | 2 +- static/css/doc.css | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ietf/idrfc/views_doc.py b/ietf/idrfc/views_doc.py index 1021e1271..ac6035302 100644 --- a/ietf/idrfc/views_doc.py +++ b/ietf/idrfc/views_doc.py @@ -92,10 +92,12 @@ def document_main(request, name, rev=None): doc = get_object_or_404(Document, docalias__name=name) group = doc.group - revisions = [ doc.rev ] - for h in doc.history_set.order_by("-time"): + revisions = [] + for h in doc.history_set.order_by("time", "id"): if h.rev and not h.rev in revisions: revisions.append(h.rev) + if not doc.rev in revisions: + revisions.append(doc.rev) snapshot = False diff --git a/ietf/templates/idrfc/document_charter.html b/ietf/templates/idrfc/document_charter.html index 9afb053fd..3559f8021 100644 --- a/ietf/templates/idrfc/document_charter.html +++ b/ietf/templates/idrfc/document_charter.html @@ -15,7 +15,7 @@ Snapshots: {% for rev in revisions %} - {{ rev }} + {{ rev }} {% endfor %} diff --git a/static/css/doc.css b/static/css/doc.css index 3a49e3c9e..8d1e4211e 100644 --- a/static/css/doc.css +++ b/static/css/doc.css @@ -9,7 +9,7 @@ .m_h { font-family: arial; font-weight:bold;} .snapshots { margin: 0.5em 0; } -.snapshots .revisions a:first-child { font-weight: bold } +.snapshots .revisions a:last-child { font-weight: bold; } .metabox .actions a { display: inline-block; margin-right: 0.4em; } .metabox .ballot-summary { font-style: italic; } From c4298f602ac865496f76e2cfdcf3e0f30c829a2c Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Wed, 2 May 2012 12:18:40 +0000 Subject: [PATCH 4/6] Offer text from latest approved revision in case there's no initial text for a recharter submit form. - Legacy-Id: 4350 --- ietf/wgcharter/views.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ietf/wgcharter/views.py b/ietf/wgcharter/views.py index 4b06dc9de..8e2d59d18 100644 --- a/ietf/wgcharter/views.py +++ b/ietf/wgcharter/views.py @@ -245,9 +245,10 @@ def submit(request, name): not_uploaded_yet = charter.rev.endswith("-00") and not os.path.exists(os.path.join(settings.CHARTER_PATH, '%s-%s.txt' % (charter.canonical_name(), charter.rev))) if not_uploaded_yet: + # this case is special - we recently chartered or rechartered and have no file yet next_rev = charter.rev else: - # Search history for possible collisions with abandoned efforts + # search history for possible collisions with abandoned efforts prev_revs = list(charter.history_set.order_by('-time').values_list('rev', flat=True)) next_rev = next_revision(charter.rev) while next_rev in prev_revs: @@ -276,7 +277,17 @@ def submit(request, name): return HttpResponseRedirect(reverse('doc_view', kwargs={'name': charter.name})) else: init = { "content": ""} - filename = os.path.join(settings.CHARTER_PATH, '%s-%s.txt' % (charter.canonical_name(), charter.rev)) + c = charter + + if not_uploaded_yet: + # use text from last approved revision + last_approved = charter.rev.split("-")[0] + h = charter.history_set.filter(rev=last_approved).order_by("-time", "-id") + if h: + c = h[0] + + filename = os.path.join(settings.CHARTER_PATH, '%s-%s.txt' % (c.canonical_name(), c.rev)) + try: with open(filename, 'r') as f: init["content"] = f.read() From 79d9eb84a9e749684c24023a2958f40017592e66 Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Wed, 2 May 2012 14:52:16 +0000 Subject: [PATCH 5/6] Fix bug in event description when copying over the final approved charter file. - Legacy-Id: 4351 --- ietf/wgcharter/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ietf/wgcharter/views.py b/ietf/wgcharter/views.py index 8e2d59d18..43a7a05d9 100644 --- a/ietf/wgcharter/views.py +++ b/ietf/wgcharter/views.py @@ -502,8 +502,8 @@ def approve(request, name): raise Http404("Charter text %s" % filename) e = NewRevisionDocEvent(doc=charter, by=login, type="new_revision") - e.desc = "New version available: %s-%s.txt" % (charter.canonical_name(), charter.rev) e.rev = next_approved_revision(charter.rev) + e.desc = "New version available: %s-%s.txt" % (charter.canonical_name(), e.rev) e.save() charter.rev = e.rev From 891ac2585d85c868b38a3d7cb646ef9aed5e349d Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Wed, 2 May 2012 17:47:40 +0000 Subject: [PATCH 6/6] Use revision numbers to identify ballots and put a warning on closed ballots. - Legacy-Id: 4352 --- ietf/doc/utils.py | 22 ++++++++++ ietf/idrfc/views_doc.py | 44 +++++++++---------- .../idrfc/document_ballot_content.html | 8 +++- 3 files changed, 49 insertions(+), 25 deletions(-) diff --git a/ietf/doc/utils.py b/ietf/doc/utils.py index a75ea5a4f..dd1ff2893 100644 --- a/ietf/doc/utils.py +++ b/ietf/doc/utils.py @@ -121,6 +121,28 @@ def get_chartering_type(doc): return chartering +def augment_events_with_revision(doc, events): + """Take a set of events for doc and add a .rev attribute with the + revision they refer to by checking NewRevisionDocEvents.""" + + event_revisions = list(NewRevisionDocEvent.objects.filter(doc=doc).order_by('time', 'id').values('id', 'rev', 'time')) + + cur_rev = doc.rev + if doc.get_state_slug() == "rfc": + cur_rev = "RFC" + + for e in sorted(events, key=lambda e: (e.time, e.id), reverse=True): + while event_revisions and (e.time, e.id) < (event_revisions[-1]["time"], event_revisions[-1]["id"]): + event_revisions.pop() + + if event_revisions: + cur_rev = event_revisions[-1]["rev"] + else: + cur_rev = "00" + + e.rev = cur_rev + + def augment_with_telechat_date(docs): """Add a telechat_date attribute to each document with the scheduled telechat or None if it's not scheduled.""" diff --git a/ietf/idrfc/views_doc.py b/ietf/idrfc/views_doc.py index ac6035302..b95c1d416 100644 --- a/ietf/idrfc/views_doc.py +++ b/ietf/idrfc/views_doc.py @@ -50,7 +50,7 @@ from ietf.idrfc.models import RfcIndex, DraftVersions from ietf.idrfc.idrfc_wrapper import BallotWrapper, IdWrapper, RfcWrapper from ietf.ietfworkflows.utils import get_full_info_for_draft from ietf.doc.models import * -from ietf.doc.utils import get_chartering_type, needed_ballot_positions, active_ballot_positions +from ietf.doc.utils import * from ietf.utils.history import find_history_active_at from ietf.ietfauth.decorators import has_role @@ -190,23 +190,7 @@ def document_history(request, name): # grab event history events = doc.docevent_set.all().order_by("-time", "-id").select_related("by") - # fill in revision numbers - event_revisions = list(NewRevisionDocEvent.objects.filter(doc=doc).order_by('time', 'id').values('rev', 'time')) - - cur_rev = doc.rev - if doc.get_state_slug() == "rfc": - cur_rev = "RFC" - - for e in events: - while event_revisions and e.time < event_revisions[-1]["time"]: - event_revisions.pop() - - if event_revisions: - cur_rev = event_revisions[-1]["rev"] - else: - cur_rev = "00" - - e.rev = cur_rev + augment_events_with_revision(doc, events) return render_to_response("idrfc/document_history.html", dict(doc=doc, @@ -255,13 +239,21 @@ def document_writeup(request, name): def document_ballot_content(request, doc, ballot_id, editable=True): """Render HTML string with content of ballot page.""" + all_ballots = list(BallotDocEvent.objects.filter(doc=doc, type="created_ballot").order_by("time")) + augment_events_with_revision(doc, all_ballots) + + ballot = None if ballot_id != None: - ballot = doc.latest_event(BallotDocEvent, type="created_ballot", pk=ballot_id) - else: - ballot = doc.latest_event(BallotDocEvent, type="created_ballot") + ballot_id = int(ballot_id) + for b in all_ballots: + if b.id == ballot_id: + ballot = b + break + elif all_ballots: + ballot = all_ballots[-1] if not ballot: - raise Http404() + raise Http404 deferred = None if doc.type_id == "draft" and doc.get_state_slug("draft-iesg") == "defer": @@ -314,7 +306,12 @@ def document_ballot_content(request, doc, ballot_id, editable=True): text_positions = [p for p in positions if p.discuss or p.comment] text_positions.sort(key=lambda p: (p.old_ad, p.ad.plain_name())) - all_ballots = BallotDocEvent.objects.filter(doc=doc, type="created_ballot") + ballot_open = not BallotDocEvent.objects.filter(doc=doc, + type__in=("closed_ballot", "created_ballot"), + time__gt=ballot.time, + ballot_type=ballot.ballot_type) + if not ballot_open: + editable = False return render_to_string("idrfc/document_ballot_content.html", dict(doc=doc, @@ -322,6 +319,7 @@ def document_ballot_content(request, doc, ballot_id, editable=True): position_groups=position_groups, text_positions=text_positions, editable=editable, + ballot_open=ballot_open, deferred=deferred, summary=summary, all_ballots=all_ballots, diff --git a/ietf/templates/idrfc/document_ballot_content.html b/ietf/templates/idrfc/document_ballot_content.html index 673cafa8c..d30d6ef3a 100644 --- a/ietf/templates/idrfc/document_ballot_content.html +++ b/ietf/templates/idrfc/document_ballot_content.html @@ -39,15 +39,19 @@ {% if all_ballots and all_ballots|length > 1 %}
- Other ballots: + Available ballots: {% for b in all_ballots %} -{{ b.ballot_type.name }} ({{ b.time|date:"Y-m-d" }}) +{{ b.ballot_type.name }} ({{ b.rev }}) {% endfor %}
{% endif %}

{{ ballot.ballot_type.question }}

+{% if not ballot_open %} +

Note: This ballot was opened for revision {{ ballot.rev }} and is now closed.

+{% endif %} +

Summary: {{ summary }}

{% for p in text_positions %}