Skip to content

Commit d166ef2

Browse files
committed
Fixup revision oddity left by yesterdays refactor.
- Legacy-Id: 4291
1 parent b9a90f3 commit d166ef2

4 files changed

Lines changed: 32 additions & 31 deletions

File tree

ietf/templates/idrfc/document_charter.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,7 @@
9999

100100
<p>Other versions: <a href="{{ txt_url }}">plain text</a></p>
101101

102-
<h3>
103-
{% if doc.rev %}
104-
Charter {{ doc.name }}-{{ doc.rev }}
105-
{% else %}
106-
No text for {{ doc.name }} submitted yet
107-
{% endif %}
102+
<h3>Charter {{ doc.name }}-{{ doc.rev }}
108103

109104
{% if user|has_role:"Area Director,Secretariat" and chartering and group.state_id != "conclude" %}
110105
<a class="edit" href="{% url charter_submit name=doc.name %}">Change charter text</a>

ietf/wgcharter/views.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,27 @@ def change_state(request, name, option=None):
5555
form = ChangeStateForm(request.POST)
5656
if form.is_valid():
5757
clean = form.cleaned_data
58-
if option == "initcharter" or option == "recharter":
58+
charter_rev = charter.rev
59+
60+
if option in ("initcharter", "recharter"):
5961
charter_state = State.objects.get(type="charter", slug="infrev")
60-
charter_rev = ""
62+
# make sure we have the latest revision set, if we
63+
# abandoned a charter before, we could have reset the
64+
# revision to latest approved
65+
prev_revs = charter.history_set.order_by('-rev')[:1]
66+
if prev_revs and prev_revs[0].rev > charter_rev:
67+
charter_rev = prev_revs[0].rev
68+
69+
if "-" not in charter_rev:
70+
charter_rev = charter_rev + "-00"
6171
elif option == "abandon":
6272
if wg.state_id == "proposed":
6373
charter_state = State.objects.get(type="charter", slug="notrev")
6474
else:
6575
charter_state = State.objects.get(type="charter", slug="approved")
66-
charter_rev = approved_revision(charter.rev)
67-
if charter_rev == "00":
68-
charter_rev = ""
76+
charter_rev = approved_revision(charter.rev)
6977
else:
7078
charter_state = clean['charter_state']
71-
charter_rev = charter.rev
7279

7380
comment = clean['comment'].rstrip()
7481
message = clean['message']
@@ -117,6 +124,8 @@ def change_state(request, name, option=None):
117124
e.desc = "Initial review time expires %s" % e.expires.strftime("%Y-%m-%d")
118125
e.save()
119126

127+
if option in ("initcharter", "recharter"):
128+
return redirect('charter_submit', name=charter.name)
120129
return redirect('doc_view', name=charter.name)
121130
else:
122131
if option == "recharter":
@@ -233,16 +242,16 @@ def submit(request, name):
233242

234243
login = request.user.get_profile()
235244

236-
if charter.rev == "":
237-
prev_revs = charter.history_set.exclude(rev="").order_by('-rev').values_list('rev', flat=True)
238-
if prev_revs:
239-
charter.rev = prev_revs[0]
245+
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)))
240246

241-
# Search history for possible collisions with abandoned efforts
242-
prev_revs = set(charter.history_set.order_by('-time').values_list('rev', flat=True))
243-
next_rev = next_revision(charter.rev)
244-
while next_rev in prev_revs:
245-
next_rev = next_revision(next_rev)
247+
if not_uploaded_yet:
248+
next_rev = charter.rev
249+
else:
250+
# Search history for possible collisions with abandoned efforts
251+
prev_revs = list(charter.history_set.order_by('-time').values_list('rev', flat=True))
252+
next_rev = next_revision(charter.rev)
253+
while next_rev in prev_revs:
254+
next_rev = next_revision(next_rev)
246255

247256
if request.method == 'POST':
248257
form = UploadForm(request.POST, request.FILES)

ietf/wginfo/edit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def edit(request, acronym=None, action="edit"):
118118
title=wg.name,
119119
group=wg,
120120
abstract=wg.name,
121-
rev="",
121+
rev="00-00",
122122
)
123123
charter.save()
124124
charter.set_state(State.objects.get(type="charter", slug="infrev"))

ietf/wginfo/tests.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,13 @@ def test_create(self):
117117
self.assertEquals(len(Group.objects.filter(type="wg")), num_wgs + 1)
118118
group = Group.objects.get(acronym="testwg")
119119
self.assertEquals(group.name, "Testing WG")
120-
# check that a charter was created with the correct name
121120
self.assertEquals(group.charter.name, "charter-ietf-testwg")
122-
# and that it has no revision
123-
self.assertEquals(group.charter.rev, "")
121+
self.assertEquals(group.charter.rev, "00-00")
124122

125123

126124
def test_edit_info(self):
127125
make_test_data()
128126

129-
# And make a charter for group
130127
group = Group.objects.get(acronym="mars")
131128

132129
url = urlreverse('wg_edit', kwargs=dict(acronym=group.acronym))
@@ -146,7 +143,7 @@ def test_edit_info(self):
146143
q = PyQuery(r.content)
147144
self.assertTrue(len(q('form ul.errorlist')) > 0)
148145

149-
# Create old acronym
146+
# create old acronym
150147
group.acronym = "oldmars"
151148
group.save()
152149
save_group_in_history(group)
@@ -192,10 +189,8 @@ def test_edit_info(self):
192189
def test_conclude(self):
193190
make_test_data()
194191

195-
# And make a charter for group
196192
group = Group.objects.get(acronym="mars")
197193

198-
# -- Test conclude WG --
199194
url = urlreverse('wg_conclude', kwargs=dict(acronym=group.acronym))
200195
login_testing_unauthorized(self, "secretary", url)
201196

@@ -211,9 +206,11 @@ def test_conclude(self):
211206
q = PyQuery(r.content)
212207
self.assertTrue(len(q('form ul.errorlist')) > 0)
213208

214-
# conclusion request
209+
# request conclusion
210+
mailbox_before = len(outbox)
215211
r = self.client.post(url, dict(instructions="Test instructions"))
216212
self.assertEquals(r.status_code, 302)
217-
# The WG remains active until the state is set to conclude via change_state
213+
self.assertEquals(len(outbox), mailbox_before + 1)
214+
# the WG remains active until the Secretariat takes action
218215
group = Group.objects.get(acronym=group.acronym)
219216
self.assertEquals(group.state_id, "active")

0 commit comments

Comments
 (0)