From 47b466eaaeb1006ed0302b16805ae8bbdd022ec6 Mon Sep 17 00:00:00 2001 From: Ole Laursen <olau@iola.dk> Date: Tue, 10 Apr 2012 18:11:03 +0000 Subject: [PATCH] Move charter urls from /wgcharter/<group-acronym> to /doc/<doc-name>/charter/ since they now all concern the actual charter documents rather than the WG (this removes some redundant code). - Legacy-Id: 4271 --- ietf/idrfc/urls.py | 4 +- ietf/idrfc/views_doc.py | 6 +- ietf/templates/idrfc/document_charter.html | 10 +-- ietf/templates/wgcharter/change_state.html | 6 +- ietf/urls.py | 1 - ietf/wgcharter/tests.py | 11 ++- ietf/wgcharter/urls.py | 14 ++-- ietf/wgcharter/views.py | 69 ++++--------------- ...hange-state.js => charter-change-state.js} | 0 9 files changed, 38 insertions(+), 83 deletions(-) rename static/js/{wg-change-state.js => charter-change-state.js} (100%) diff --git a/ietf/idrfc/urls.py b/ietf/idrfc/urls.py index 9079479bc..191ea7e44 100644 --- a/ietf/idrfc/urls.py +++ b/ietf/idrfc/urls.py @@ -30,7 +30,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from django.conf.urls.defaults import patterns, url +from django.conf.urls.defaults import patterns, url, include from ietf.idrfc import views_doc, views_search, views_edit, views_ballot, views urlpatterns = patterns('', @@ -65,4 +65,6 @@ urlpatterns = patterns('', url(r'^(?P<name>[A-Za-z0-9.-]+)/edit/approvaltext/$', views_ballot.ballot_approvaltext, name='doc_ballot_approvaltext'), url(r'^(?P<name>[A-Za-z0-9.-]+)/edit/approveballot/$', views_ballot.approve_ballot, name='doc_approve_ballot'), url(r'^(?P<name>[A-Za-z0-9.-]+)/edit/makelastcall/$', views_ballot.make_last_call, name='doc_make_last_call'), + + (r'^(?P<name>[A-Za-z0-9.-]+)/charter/', include('ietf.wgcharter.urls')), ) diff --git a/ietf/idrfc/views_doc.py b/ietf/idrfc/views_doc.py index 1bd5df148..68caeaf10 100644 --- a/ietf/idrfc/views_doc.py +++ b/ietf/idrfc/views_doc.py @@ -217,17 +217,17 @@ def document_writeup(request, name): e = doc.latest_event(WriteupDocEvent, type="changed_review_announcement") writeups.append(("WG Review Announcement", e.text if e else "", - urlreverse("ietf.wgcharter.views.announcement_text", kwargs=dict(name=doc.group.acronym, ann="review")))) + urlreverse("ietf.wgcharter.views.announcement_text", kwargs=dict(name=doc.name, ann="review")))) e = doc.latest_event(WriteupDocEvent, type="changed_action_announcement") writeups.append(("WG Action Announcement", e.text if e else "", - urlreverse("ietf.wgcharter.views.announcement_text", kwargs=dict(name=doc.group.acronym, ann="action")))) + urlreverse("ietf.wgcharter.views.announcement_text", kwargs=dict(name=doc.name, ann="action")))) e = doc.latest_event(WriteupDocEvent, type="changed_ballot_writeup_text") writeups.append(("Ballot Announcement", e.text if e else "", - urlreverse("ietf.wgcharter.views.ballot_writeupnotes", kwargs=dict(name=doc.group.acronym)))) + urlreverse("ietf.wgcharter.views.ballot_writeupnotes", kwargs=dict(name=doc.name)))) if not writeups: raise Http404() diff --git a/ietf/templates/idrfc/document_charter.html b/ietf/templates/idrfc/document_charter.html index a23dbaaa7..254a2e946 100644 --- a/ietf/templates/idrfc/document_charter.html +++ b/ietf/templates/idrfc/document_charter.html @@ -41,12 +41,12 @@ {% if chartering == "rechartering" %}(Rechartering){% endif %} {% if not snapshot and user|has_role:"Area Director,Secretariat" %} - - <a href="{% url wg_change_state name=doc.group.acronym %}">Change state</a> + - <a href="{% url wg_change_state name=doc.name %}">Change state</a> {% if chartering %} - - <a href="{% url wg_startstop_process name=doc.group.acronym option='abandon' %}">Abandon effort</a> + - <a href="{% url wg_startstop_process name=doc.name option='abandon' %}">Abandon effort</a> {% else %} - - <a href="{% url wg_startstop_process name=doc.group.acronym option='recharter' %}">Recharter</a> + - <a href="{% url wg_startstop_process name=doc.name option='recharter' %}">Recharter</a> {% endif %} {% endif %} @@ -67,7 +67,7 @@ <td> {% if not telechat %}Not on agenda{% else %}{{ telechat.telechat_date|date:"Y-m-d" }}{% endif %} {% if user|has_role:"Area Director,Secretariat" %} - - <a href="{% url charter_telechat_date name=doc.group.acronym %}">Change</a> + - <a href="{% url charter_telechat_date name=doc.name %}">Change</a> {% endif %} </td> </tr> @@ -89,7 +89,7 @@ <h3>Charter {{ doc.name }}-{{ doc.rev }} {% if user|has_role:"Area Director,Secretariat" and chartering and doc.group.state_id != "conclude" %} -<a class="edit" href="{% url wg_submit name=doc.group.acronym %}">Edit charter text</a> +<a class="edit" href="{% url wg_submit name=doc.name %}">Edit charter text</a> {% endif %} </h3> diff --git a/ietf/templates/wgcharter/change_state.html b/ietf/templates/wgcharter/change_state.html index bb0415ba8..de1757661 100644 --- a/ietf/templates/wgcharter/change_state.html +++ b/ietf/templates/wgcharter/change_state.html @@ -20,7 +20,7 @@ form.change-state .actions { {% block content %} <h1>{{ title }}</h1> -{% if "Change state" in title %}<p class="helptext">For help on the states, see the <a href="{% url help_charter_states %}">state table</a>.</p>{% endif %} +{% if "Change state" in title %}<p class="helptext">For help on the states, see the <a href="{% url help_charter_states name=doc.name %}">state table</a>.</p>{% endif %} <form class="change-state" action="" method="post"> <table> @@ -57,7 +57,7 @@ form.change-state .actions { {% if option %} <input type="submit" value="Submit"/> {% else %} - <a href="{% url doc_view name=wg.charter.name %}">Back</a> + <a href="{% url doc_view name=doc.name %}">Back</a> <input type="submit" value="Save"/> {% endif %} </td> @@ -82,5 +82,5 @@ form.change-state .actions { <script type="text/javascript"> var messages = {{ messages|safe }}; </script> -<script type="text/javascript" src="/js/wg-change-state.js"></script> +<script type="text/javascript" src="/js/charter-change-state.js"></script> {% endblock %} diff --git a/ietf/urls.py b/ietf/urls.py index e1a5d1aba..f5cf13bce 100644 --- a/ietf/urls.py +++ b/ietf/urls.py @@ -61,7 +61,6 @@ urlpatterns = patterns('', (r'^accounts/', include('ietf.ietfauth.urls')), (r'^doc/', include('ietf.idrfc.urls')), (r'^wg/', include('ietf.wginfo.urls')), - (r'^wgcharter/', include('ietf.wgcharter.urls')), (r'^cookies/', include('ietf.cookies.urls')), (r'^person/', include('ietf.person.urls')), (r'^submit/', include('ietf.submit.urls')), diff --git a/ietf/wgcharter/tests.py b/ietf/wgcharter/tests.py index f6838e45f..07daf4a9b 100644 --- a/ietf/wgcharter/tests.py +++ b/ietf/wgcharter/tests.py @@ -38,8 +38,7 @@ class EditCharterTestCase(django.test.TestCase): group = Group.objects.get(acronym="ames") charter = group.charter - # -- Test change state -- - url = urlreverse('wg_change_state', kwargs=dict(name=group.acronym)) + url = urlreverse('wg_change_state', kwargs=dict(name=charter.name)) login_testing_unauthorized(self, "secretary", url) first_state = charter.get_state() @@ -84,11 +83,10 @@ class EditCharterTestCase(django.test.TestCase): def test_edit_telechat_date(self): make_test_data() - # And make a charter for group group = Group.objects.get(acronym="mars") charter = group.charter - url = urlreverse('charter_telechat_date', kwargs=dict(name=group.acronym)) + url = urlreverse('charter_telechat_date', kwargs=dict(name=charter.name)) login_testing_unauthorized(self, "secretary", url) # add to telechat @@ -120,11 +118,10 @@ class EditCharterTestCase(django.test.TestCase): def test_submit_charter(self): make_test_data() - # And make a charter for group group = Group.objects.get(acronym="mars") charter = group.charter - url = urlreverse('wg_submit', kwargs=dict(name=group.acronym)) + url = urlreverse('wg_submit', kwargs=dict(name=charter.name)) login_testing_unauthorized(self, "secretary", url) # normal get @@ -162,7 +159,7 @@ class CharterApproveBallotTestCase(django.test.TestCase): group = Group.objects.get(acronym="ames") charter = group.charter - url = urlreverse('wg_approve_ballot', kwargs=dict(name=group.acronym)) + url = urlreverse('wg_approve_ballot', kwargs=dict(name=charter.name)) login_testing_unauthorized(self, "secretary", url) with open(os.path.join(self.charter_dir, "charter-ietf-%s-%s.txt" % (group.acronym, charter.rev)), "w") as f: diff --git a/ietf/wgcharter/urls.py b/ietf/wgcharter/urls.py index f4df2b9b4..71a7fa770 100644 --- a/ietf/wgcharter/urls.py +++ b/ietf/wgcharter/urls.py @@ -7,12 +7,12 @@ urlpatterns = patterns('django.views.generic.simple', url(r'^help/state/$', 'direct_to_template', { 'template': 'wgcharter/states.html', 'extra_context': { 'states': State.objects.filter(type="charter") } }, name='help_charter_states'), ) urlpatterns += patterns('', - url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/state/$', "ietf.wgcharter.views.change_state", name='wg_change_state'), - url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/(?P<option>initcharter|recharter|abandon)/$', "ietf.wgcharter.views.change_state", name='wg_startstop_process'), - url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/telechat/$', "ietf.wgcharter.views.telechat_date", name='charter_telechat_date'), - url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/(?P<ann>action|review)/$', "ietf.wgcharter.views.announcement_text", name='wg_announcement_text'), - url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/ballotwriteupnotes/$', "ietf.wgcharter.views.ballot_writeupnotes", name='wg_ballot_writeupnotes'), - url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/approveballot/$', "ietf.wgcharter.views.approve_ballot", name='wg_approve_ballot'), - url(r'^(?P<name>[A-Za-z0-9._+-]+)/submit/$', "ietf.wgcharter.views.submit", name='wg_submit'), + url(r'^state/$', "ietf.wgcharter.views.change_state", name='wg_change_state'), + url(r'^(?P<option>initcharter|recharter|abandon)/$', "ietf.wgcharter.views.change_state", name='wg_startstop_process'), + url(r'^telechat/$', "ietf.wgcharter.views.telechat_date", name='charter_telechat_date'), + url(r'^(?P<ann>action|review)/$', "ietf.wgcharter.views.announcement_text", name='wg_announcement_text'), + url(r'^ballotwriteupnotes/$', "ietf.wgcharter.views.ballot_writeupnotes", name='wg_ballot_writeupnotes'), + url(r'^approveballot/$', "ietf.wgcharter.views.approve_ballot", name='wg_approve_ballot'), + url(r'^submit/$', "ietf.wgcharter.views.submit", name='wg_submit'), ) diff --git a/ietf/wgcharter/views.py b/ietf/wgcharter/views.py index ceb6349e2..d9854ad70 100644 --- a/ietf/wgcharter/views.py +++ b/ietf/wgcharter/views.py @@ -42,17 +42,8 @@ class ChangeStateForm(forms.Form): def change_state(request, name, option=None): """Change state of WG and charter, notifying parties as necessary and logging the change as a comment.""" - # Get WG by acronym, redirecting if there's a newer acronym - try: - wg = Group.objects.get(acronym=name) - except Group.DoesNotExist: - old = GroupHistory.objects.filter(acronym=name) - if old: - return redirect('wg_change_state', name=old[0].group.acronym) - else: - raise Http404() - - charter = set_or_create_charter(wg) + charter = get_object_or_404(Document, type="charter", name=name) + wg = charter.group initial_review = charter.latest_event(InitialReviewDocEvent, type="initial_review") if charter.get_state_slug() != "infrev" or (initial_review and initial_review.expires < datetime.datetime.now()): @@ -162,7 +153,7 @@ def change_state(request, name, option=None): return render_to_response('wgcharter/change_state.html', dict(form=form, - wg=wg, + doc=wg.charter, login=login, option=option, prev_charter_state=prev_charter_state, @@ -187,8 +178,7 @@ class TelechatForm(forms.Form): @role_required("Area Director", "Secretariat") def telechat_date(request, name): - wg = get_object_or_404(Group, acronym=name) - doc = set_or_create_charter(wg) + doc = get_object_or_404(Document, type="charter", name=name) login = request.user.get_profile() e = doc.latest_event(TelechatDocEvent, type="scheduled_for_telechat") @@ -235,18 +225,9 @@ class UploadForm(forms.Form): @role_required('Area Director','Secretariat') def submit(request, name): - # Get WG by acronym, redirecting if there's a newer acronym - try: - wg = Group.objects.get(acronym=name) - except Group.DoesNotExist: - wglist = GroupHistory.objects.filter(acronym=name) - if wglist: - return redirect('charter_submit', name=wglist[0].group.acronym) - else: - raise Http404() - # Get charter - charter = set_or_create_charter(wg) - + charter = get_object_or_404(Document, type="charter", name=name) + wg = charter.group + login = request.user.get_profile() if request.method == 'POST': @@ -301,16 +282,8 @@ class AnnouncementTextForm(forms.Form): @role_required('Area Director','Secretariat') def announcement_text(request, name, ann): """Editing of announcement text""" - try: - wg = Group.objects.get(acronym=name) - except Group.DoesNotExist: - wglist = GroupHistory.objects.filter(acronym=name) - if wglist: - return redirect('wg_announcement_text', name=wglist[0].group.acronym) - else: - raise Http404 - - charter = set_or_create_charter(wg) + charter = get_object_or_404(Document, type="charter", name=name) + wg = charter.group login = request.user.get_profile() @@ -383,16 +356,8 @@ class BallotWriteupForm(forms.Form): @role_required('Area Director','Secretariat') def ballot_writeupnotes(request, name): """Editing of ballot write-up and notes""" - try: - wg = Group.objects.get(acronym=name) - except Group.DoesNotExist: - wglist = GroupHistory.objects.filter(acronym=name) - if wglist: - return redirect('wg_ballot_writeupnotes', name=wglist[0].group.acronym) - else: - raise Http404 - - charter = wg.charter + charter = get_object_or_404(Document, type="charter", name=name) + wg = charter.group ballot = charter.latest_event(BallotDocEvent, type="created_ballot") if not ballot: @@ -459,16 +424,8 @@ def ballot_writeupnotes(request, name): @role_required("Secretariat") def approve_ballot(request, name): """Approve ballot, changing state, copying charter""" - try: - wg = Group.objects.get(acronym=name) - except Group.DoesNotExist: - wglist = GroupHistory.objects.filter(acronym=name) - if wglist: - return redirect('wg_approve_ballot', name=wglist[0].group.acronym) - else: - raise Http404 - - charter = set_or_create_charter(wg) + charter = get_object_or_404(Document, type="charter", name=name) + wg = charter.group login = request.user.get_profile() diff --git a/static/js/wg-change-state.js b/static/js/charter-change-state.js similarity index 100% rename from static/js/wg-change-state.js rename to static/js/charter-change-state.js