Skip to content

Commit 462aff5

Browse files
committed
Merged in fixes to the charter branch (r4345 - r4353) from olau@iola.dk.
- Legacy-Id: 4354
2 parents bcd28cc + 891ac25 commit 462aff5

7 files changed

Lines changed: 71 additions & 34 deletions

File tree

ietf/doc/utils.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def needed_ballot_positions(doc, active_positions):
5959
recuse = [p for p in active_positions if p and p.pos_id == "recuse"]
6060

6161
answer = []
62-
if yes < 1:
62+
if len(yes) < 1:
6363
answer.append("Needs a YES.")
6464
if blocking:
6565
if blocking:
@@ -143,6 +143,28 @@ def get_chartering_type(doc):
143143

144144
return chartering
145145

146+
def augment_events_with_revision(doc, events):
147+
"""Take a set of events for doc and add a .rev attribute with the
148+
revision they refer to by checking NewRevisionDocEvents."""
149+
150+
event_revisions = list(NewRevisionDocEvent.objects.filter(doc=doc).order_by('time', 'id').values('id', 'rev', 'time'))
151+
152+
cur_rev = doc.rev
153+
if doc.get_state_slug() == "rfc":
154+
cur_rev = "RFC"
155+
156+
for e in sorted(events, key=lambda e: (e.time, e.id), reverse=True):
157+
while event_revisions and (e.time, e.id) < (event_revisions[-1]["time"], event_revisions[-1]["id"]):
158+
event_revisions.pop()
159+
160+
if event_revisions:
161+
cur_rev = event_revisions[-1]["rev"]
162+
else:
163+
cur_rev = "00"
164+
165+
e.rev = cur_rev
166+
167+
146168
def augment_with_telechat_date(docs):
147169
"""Add a telechat_date attribute to each document with the
148170
scheduled telechat or None if it's not scheduled."""

ietf/idrfc/views_doc.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
from ietf.idrfc.idrfc_wrapper import BallotWrapper, IdWrapper, RfcWrapper
5151
from ietf.ietfworkflows.utils import get_full_info_for_draft
5252
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 *
5454
from ietf.utils.history import find_history_active_at
5555
from ietf.ietfauth.decorators import has_role
5656

@@ -96,10 +96,12 @@ def document_main(request, name, rev=None):
9696
group = doc.group
9797
print group
9898

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"):
101101
if h.rev and not h.rev in revisions:
102102
revisions.append(h.rev)
103+
if not doc.rev in revisions:
104+
revisions.append(doc.rev)
103105

104106
snapshot = False
105107

@@ -192,23 +194,7 @@ def document_history(request, name):
192194
# grab event history
193195
events = doc.docevent_set.all().order_by("-time", "-id").select_related("by")
194196

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)
212198

213199
return render_to_response("idrfc/document_history.html",
214200
dict(doc=doc,
@@ -257,13 +243,21 @@ def document_writeup(request, name):
257243

258244
def document_ballot_content(request, doc, ballot_id, editable=True):
259245
"""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
260250
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]
264258

265259
if not ballot:
266-
raise Http404()
260+
raise Http404
267261

268262
deferred = None
269263
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):
316310
text_positions = [p for p in positions if p.discuss or p.comment]
317311
text_positions.sort(key=lambda p: (p.old_ad, p.ad.plain_name()))
318312

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
320319

321320
return render_to_string("idrfc/document_ballot_content.html",
322321
dict(doc=doc,
323322
ballot=ballot,
324323
position_groups=position_groups,
325324
text_positions=text_positions,
326325
editable=editable,
326+
ballot_open=ballot_open,
327327
deferred=deferred,
328328
summary=summary,
329329
all_ballots=all_ballots,

ietf/templates/idrfc/document_ballot_content.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,19 @@
3939

4040
{% if all_ballots and all_ballots|length > 1 %}
4141
<div class="other-ballots">
42-
Other ballots:
42+
Available ballots:
4343
{% for b in all_ballots %}
44-
<a{% if b != ballot %} href="{% url doc_ballot name=doc.name,ballot_id=b.pk %}"{% endif %}>{{ b.ballot_type.name }} ({{ b.time|date:"Y-m-d" }})</a>
44+
<a{% if b != ballot %} href="{% url doc_ballot name=doc.name,ballot_id=b.pk %}"{% endif %}>{{ b.ballot_type.name }} ({{ b.rev }})</a>
4545
{% endfor %}
4646
</div>
4747
{% endif %}
4848

4949
<h2 style="margin-top:12px;">{{ ballot.ballot_type.question }}</h2>
5050

51+
{% if not ballot_open %}
52+
<p>Note: This ballot was opened for revision {{ ballot.rev }} and is now closed.</p>
53+
{% endif %}
54+
5155
<p>Summary: <i>{{ summary }}</i></p>
5256

5357
{% for p in text_positions %}

ietf/templates/idrfc/document_charter.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Snapshots:
1616
<span class="revisions">
1717
{% for rev in revisions %}
18-
<a {% if rev != doc.rev %}href="{% url doc_view name=doc.name %}{% if not forloop.first %}{{ rev }}/{% endif %}"{% endif %}>{{ rev }}</a>
18+
<a {% if rev != doc.rev %}href="{% url doc_view name=doc.name %}{% if not forloop.last %}{{ rev }}/{% endif %}"{% endif %}>{{ rev }}</a>
1919
{% endfor %}
2020
</span>
2121
</div>

ietf/wgcharter/views.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,10 @@ def submit(request, name):
245245
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)))
246246

247247
if not_uploaded_yet:
248+
# this case is special - we recently chartered or rechartered and have no file yet
248249
next_rev = charter.rev
249250
else:
250-
# Search history for possible collisions with abandoned efforts
251+
# search history for possible collisions with abandoned efforts
251252
prev_revs = list(charter.history_set.order_by('-time').values_list('rev', flat=True))
252253
next_rev = next_revision(charter.rev)
253254
while next_rev in prev_revs:
@@ -276,7 +277,17 @@ def submit(request, name):
276277
return HttpResponseRedirect(reverse('doc_view', kwargs={'name': charter.name}))
277278
else:
278279
init = { "content": ""}
279-
filename = os.path.join(settings.CHARTER_PATH, '%s-%s.txt' % (charter.canonical_name(), charter.rev))
280+
c = charter
281+
282+
if not_uploaded_yet:
283+
# use text from last approved revision
284+
last_approved = charter.rev.split("-")[0]
285+
h = charter.history_set.filter(rev=last_approved).order_by("-time", "-id")
286+
if h:
287+
c = h[0]
288+
289+
filename = os.path.join(settings.CHARTER_PATH, '%s-%s.txt' % (c.canonical_name(), c.rev))
290+
280291
try:
281292
with open(filename, 'r') as f:
282293
init["content"] = f.read()
@@ -491,8 +502,8 @@ def approve(request, name):
491502
raise Http404("Charter text %s" % filename)
492503

493504
e = NewRevisionDocEvent(doc=charter, by=login, type="new_revision")
494-
e.desc = "New version available: <b>%s-%s.txt</b>" % (charter.canonical_name(), charter.rev)
495505
e.rev = next_approved_revision(charter.rev)
506+
e.desc = "New version available: <b>%s-%s.txt</b>" % (charter.canonical_name(), e.rev)
496507
e.save()
497508

498509
charter.rev = e.rev

ietf/wginfo/edit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
class WGForm(forms.Form):
2323
name = forms.CharField(max_length=255, label="WG Name", required=True)
24-
acronym = forms.CharField(max_length=8, label="WG Acronym", required=True)
24+
acronym = forms.CharField(max_length=10, label="WG Acronym", required=True)
2525
chairs = EmailsField(label="WG Chairs", required=False)
2626
secretaries = EmailsField(label="WG Secretaries", required=False)
2727
techadv = EmailsField(label="WG Technical Advisors", required=False)

static/css/doc.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
.m_h { font-family: arial; font-weight:bold;}
1010

1111
.snapshots { margin: 0.5em 0; }
12-
.snapshots .revisions a:first-child { font-weight: bold }
12+
.snapshots .revisions a:last-child { font-weight: bold; }
1313

1414
.metabox .actions a { display: inline-block; margin-right: 0.4em; }
1515
.metabox .ballot-summary { font-style: italic; }

0 commit comments

Comments
 (0)