Fixup revision oddity left by yesterdays refactor.

- Legacy-Id: 4291
This commit is contained in:
Ole Laursen 2012-04-20 11:48:27 +00:00
parent b9a90f35e1
commit d166ef284b
4 changed files with 32 additions and 31 deletions
ietf
templates/idrfc
wgcharter
wginfo

View file

@ -99,12 +99,7 @@
<p>Other versions: <a href="{{ txt_url }}">plain text</a></p>
<h3>
{% if doc.rev %}
Charter {{ doc.name }}-{{ doc.rev }}
{% else %}
No text for {{ doc.name }} submitted yet
{% endif %}
<h3>Charter {{ doc.name }}-{{ doc.rev }}
{% if user|has_role:"Area Director,Secretariat" and chartering and group.state_id != "conclude" %}
<a class="edit" href="{% url charter_submit name=doc.name %}">Change charter text</a>

View file

@ -55,20 +55,27 @@ def change_state(request, name, option=None):
form = ChangeStateForm(request.POST)
if form.is_valid():
clean = form.cleaned_data
if option == "initcharter" or option == "recharter":
charter_rev = charter.rev
if option in ("initcharter", "recharter"):
charter_state = State.objects.get(type="charter", slug="infrev")
charter_rev = ""
# make sure we have the latest revision set, if we
# abandoned a charter before, we could have reset the
# revision to latest approved
prev_revs = charter.history_set.order_by('-rev')[:1]
if prev_revs and prev_revs[0].rev > charter_rev:
charter_rev = prev_revs[0].rev
if "-" not in charter_rev:
charter_rev = charter_rev + "-00"
elif option == "abandon":
if wg.state_id == "proposed":
charter_state = State.objects.get(type="charter", slug="notrev")
else:
charter_state = State.objects.get(type="charter", slug="approved")
charter_rev = approved_revision(charter.rev)
if charter_rev == "00":
charter_rev = ""
charter_rev = approved_revision(charter.rev)
else:
charter_state = clean['charter_state']
charter_rev = charter.rev
comment = clean['comment'].rstrip()
message = clean['message']
@ -117,6 +124,8 @@ def change_state(request, name, option=None):
e.desc = "Initial review time expires %s" % e.expires.strftime("%Y-%m-%d")
e.save()
if option in ("initcharter", "recharter"):
return redirect('charter_submit', name=charter.name)
return redirect('doc_view', name=charter.name)
else:
if option == "recharter":
@ -233,16 +242,16 @@ def submit(request, name):
login = request.user.get_profile()
if charter.rev == "":
prev_revs = charter.history_set.exclude(rev="").order_by('-rev').values_list('rev', flat=True)
if prev_revs:
charter.rev = prev_revs[0]
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)))
# Search history for possible collisions with abandoned efforts
prev_revs = set(charter.history_set.order_by('-time').values_list('rev', flat=True))
next_rev = next_revision(charter.rev)
while next_rev in prev_revs:
next_rev = next_revision(next_rev)
if not_uploaded_yet:
next_rev = charter.rev
else:
# 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:
next_rev = next_revision(next_rev)
if request.method == 'POST':
form = UploadForm(request.POST, request.FILES)

View file

@ -118,7 +118,7 @@ def edit(request, acronym=None, action="edit"):
title=wg.name,
group=wg,
abstract=wg.name,
rev="",
rev="00-00",
)
charter.save()
charter.set_state(State.objects.get(type="charter", slug="infrev"))

View file

@ -117,16 +117,13 @@ class WgEditTestCase(django.test.TestCase):
self.assertEquals(len(Group.objects.filter(type="wg")), num_wgs + 1)
group = Group.objects.get(acronym="testwg")
self.assertEquals(group.name, "Testing WG")
# check that a charter was created with the correct name
self.assertEquals(group.charter.name, "charter-ietf-testwg")
# and that it has no revision
self.assertEquals(group.charter.rev, "")
self.assertEquals(group.charter.rev, "00-00")
def test_edit_info(self):
make_test_data()
# And make a charter for group
group = Group.objects.get(acronym="mars")
url = urlreverse('wg_edit', kwargs=dict(acronym=group.acronym))
@ -146,7 +143,7 @@ class WgEditTestCase(django.test.TestCase):
q = PyQuery(r.content)
self.assertTrue(len(q('form ul.errorlist')) > 0)
# Create old acronym
# create old acronym
group.acronym = "oldmars"
group.save()
save_group_in_history(group)
@ -192,10 +189,8 @@ class WgEditTestCase(django.test.TestCase):
def test_conclude(self):
make_test_data()
# And make a charter for group
group = Group.objects.get(acronym="mars")
# -- Test conclude WG --
url = urlreverse('wg_conclude', kwargs=dict(acronym=group.acronym))
login_testing_unauthorized(self, "secretary", url)
@ -211,9 +206,11 @@ class WgEditTestCase(django.test.TestCase):
q = PyQuery(r.content)
self.assertTrue(len(q('form ul.errorlist')) > 0)
# conclusion request
# request conclusion
mailbox_before = len(outbox)
r = self.client.post(url, dict(instructions="Test instructions"))
self.assertEquals(r.status_code, 302)
# The WG remains active until the state is set to conclude via change_state
self.assertEquals(len(outbox), mailbox_before + 1)
# the WG remains active until the Secretariat takes action
group = Group.objects.get(acronym=group.acronym)
self.assertEquals(group.state_id, "active")