From b9a90f35e122ea832c277afc2d2b0df75981a139 Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Thu, 19 Apr 2012 15:15:43 +0000 Subject: [PATCH] Clean up and polish charter branch code, fix some subtle bugs with revision and approved charter lookup. - Legacy-Id: 4290 --- ietf/doc/models.py | 2 +- ietf/doc/utils.py | 8 +- ietf/group/proxy.py | 24 ++-- ietf/idrfc/views_doc.py | 17 ++- ietf/templates/idrfc/document_charter.html | 78 +++++++------ .../{approve_ballot.html => approve.html} | 12 +- ietf/wgcharter/tests.py | 10 +- ietf/wgcharter/urls.py | 12 +- ietf/wgcharter/utils.py | 61 ++++------ ietf/wgcharter/views.py | 106 +++++++++--------- ietf/wginfo/edit.py | 50 +++++---- static/css/doc.css | 2 + 12 files changed, 196 insertions(+), 186 deletions(-) rename ietf/templates/wgcharter/{approve_ballot.html => approve.html} (64%) diff --git a/ietf/doc/models.py b/ietf/doc/models.py index d3694cb85..2bccbaae6 100644 --- a/ietf/doc/models.py +++ b/ietf/doc/models.py @@ -196,7 +196,7 @@ class DocHistoryAuthor(models.Model): class DocHistory(DocumentInfo): doc = models.ForeignKey(Document, related_name="history_set") - name = models.CharField(max_length=255) # WG charter names can change if the group acronym changes + name = models.CharField(max_length=255) # WG charter canonical names can change if the group acronym changes related = models.ManyToManyField('DocAlias', through=RelatedDocHistory, blank=True) authors = models.ManyToManyField(Email, through=DocHistoryAuthor, blank=True) def __unicode__(self): diff --git a/ietf/doc/utils.py b/ietf/doc/utils.py index 595b8ecc9..b48c1ccbb 100644 --- a/ietf/doc/utils.py +++ b/ietf/doc/utils.py @@ -54,10 +54,10 @@ def needed_ballot_positions(doc, active_positions): '''Returns text answering the question "what does this document need to pass?". The return value is only useful if the document is currently in IESG evaluation.''' - yes = [p for p in active_positions if p.pos_id == "yes"] - noobj = [p for p in active_positions if p.pos_id == "noobj"] - blocking = [p for p in active_positions if p.pos.blocking] - recuse = [p for p in active_positions if p.pos_id == "recuse"] + yes = [p for p in active_positions if p and p.pos_id == "yes"] + noobj = [p for p in active_positions if p and p.pos_id == "noobj"] + blocking = [p for p in active_positions if p and p.pos.blocking] + recuse = [p for p in active_positions if p and p.pos_id == "recuse"] answer = [] if yes < 1: diff --git a/ietf/group/proxy.py b/ietf/group/proxy.py index 2784003bc..eb226d643 100644 --- a/ietf/group/proxy.py +++ b/ietf/group/proxy.py @@ -1,8 +1,6 @@ from ietf.utils.proxy import TranslatingManager, proxy_role_email from models import * -from ietf.doc.models import Document # for charter text -from ietf.wgcharter.utils import get_charter_for_revision, approved_revision class Acronym(Group): class LazyIndividualSubmitter(object): @@ -203,15 +201,19 @@ class IETFWG(Group): # get file path from settings. Syntesize file name from path, acronym, and suffix try: # Try getting charter from new charter tool - charter = Document.objects.get(docalias__name="charter-ietf-%s" % self.acronym) - ch = get_charter_for_revision(charter, charter.rev) - name = ch.name - rev = approved_revision(ch.rev) - filename = os.path.join(charter.get_file_path(), "%s-%s.txt" % (name, rev)) - desc_file = open(filename) - desc = desc_file.read() - return desc - except: + c = self.charter + + # find the latest, preferably approved, revision + for h in self.charter.history_set.exclude(rev="").order_by("time"): + h_appr = "-" not in h.rev + c_appr = "-" not in c.rev + if (h.rev > c.rev and not (c_appr and not h_appr)) or (h_appr and not c_appr): + c = h + + filename = os.path.join(c.get_file_path(), "%s-%s.txt" % (c.canonical_name(), c.rev)) + with open(filename) as f: + return f.read() + except IOError: try: filename = os.path.join(settings.IETFWG_DESCRIPTIONS_PATH, self.acronym) + ".desc.txt" desc_file = open(filename) diff --git a/ietf/idrfc/views_doc.py b/ietf/idrfc/views_doc.py index 95981f173..e0dedf80b 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 +from ietf.doc.utils import get_chartering_type, needed_ballot_positions, active_ballot_positions from ietf.utils.history import find_history_active_at from ietf.ietfauth.decorators import has_role @@ -90,10 +90,11 @@ def document_main(request, name, rev=None): return document_main_idrfc(request, name, tab="document") doc = get_object_or_404(Document, docalias__name=name) + group = doc.group revisions = [ doc.rev ] for h in doc.history_set.order_by("-time"): - if not h.rev in revisions: + if h.rev and not h.rev in revisions: revisions.append(h.rev) snapshot = False @@ -115,17 +116,23 @@ def document_main(request, name, rev=None): # find old group, too gh = find_history_active_at(doc.group, doc.time) if gh: - doc.group = gh + group = gh top = render_document_top(request, doc, "document") + telechat = doc.latest_event(TelechatDocEvent, type="scheduled_for_telechat") + if telechat and telechat.telechat_date < datetime.date.today(): + telechat = None + if doc.type_id == "charter": filename = "%s-%s.txt" % (doc.canonical_name(), doc.rev) content = _get_html(filename, os.path.join(settings.CHARTER_PATH, filename), split=False) - telechat = doc.latest_event(TelechatDocEvent, type="scheduled_for_telechat") + ballot_summary = None + if doc.get_state_slug() in ("intrev", "iesgrev"): + ballot_summary = needed_ballot_positions(doc, active_ballot_positions(doc).values()) return render_to_response("idrfc/document_charter.html", dict(doc=doc, @@ -136,6 +143,8 @@ def document_main(request, name, rev=None): revisions=revisions, snapshot=snapshot, telechat=telechat, + ballot_summary=ballot_summary, + group=group, ), context_instance=RequestContext(request)) diff --git a/ietf/templates/idrfc/document_charter.html b/ietf/templates/idrfc/document_charter.html index 7529be067..eed3262dc 100644 --- a/ietf/templates/idrfc/document_charter.html +++ b/ietf/templates/idrfc/document_charter.html @@ -24,55 +24,67 @@
{% if snapshot %}Snapshot of{% endif %} {% if doc.get_state_slug != "approved" %}Proposed{% endif %} - Charter for {{ doc.group.name }} - ({{ doc.group.acronym }} {{ doc.group.type.name }}) + Charter for {{ group.name }} + ({{ group.acronym }} {{ group.type.name }})
- + - + {% if chartering %} + - Abandon effort - {% if chartering and doc.group.comments %} - - {% if chartering == "initial" %}{% endif %} - {% if chartering == "rechartering" %}{% endif %} - - - {% endif %} + {% if request.user|has_role:"Secretariat" %} + - Approve charter + {% endif %} + + {% else %} + - Recharter + {% endif %} + + {% endif %} + + + {% if not snapshot and chartering %} +
+ {% if not telechat %}Not on agenda of IESG telechat{% else %}On agenda of {{ telechat.telechat_date|date:"Y-m-d" }} IESG telechat{% endif %} + {% if user|has_role:"Area Director,Secretariat" %} + - Change + {% endif %} +
+ + {% if ballot_summary %} +
+ ({{ ballot_summary }}) +
+ {% endif %} - {% if not snapshot %} - - - + + {% if chartering and group.comments %} + + {% if chartering == "initial" %}{% endif %} + {% if chartering == "rechartering" %}{% endif %} + + {% endif %} + @@ -81,7 +93,7 @@
WG State:{{ doc.group.state.name }}{{ group.state.name }}
Charter State: - {{ doc.get_state.name }} - {% if chartering == "initial" %}(Initial Chartering){% endif %} - {% if chartering == "rechartering" %}(Rechartering){% endif %} +
+ {{ doc.get_state.name }} + {% if chartering == "initial" %}(Initial Chartering){% endif %} + {% if chartering == "rechartering" %}(Rechartering){% endif %} - {% if not snapshot and user|has_role:"Area Director,Secretariat" %} - - Change state + {% if not snapshot and user|has_role:"Area Director,Secretariat" %} - {% if chartering %} - - Abandon effort - {% else %} - - Recharter - {% endif %} - {% endif %} -
Reason for chartering:Reason for rechartering:{{ doc.group.comments }}
IESG telechat: - {% if not telechat %}Not on agenda{% else %}{{ telechat.telechat_date|date:"Y-m-d" }}{% endif %} - {% if user|has_role:"Area Director,Secretariat" %} - - Change {% endif %}
Reason for chartering:Reason for rechartering:{{ group.comments }}

Last updated: {{ doc.time|date:"Y-m-d" }}
- Atom feed + Atom feed
@@ -94,8 +106,8 @@ No text for {{ doc.name }} submitted yet {% endif %} -{% if user|has_role:"Area Director,Secretariat" and chartering and doc.group.state_id != "conclude" %} -Change charter text +{% if user|has_role:"Area Director,Secretariat" and chartering and group.state_id != "conclude" %} +Change charter text {% endif %} diff --git a/ietf/templates/wgcharter/approve_ballot.html b/ietf/templates/wgcharter/approve.html similarity index 64% rename from ietf/templates/wgcharter/approve_ballot.html rename to ietf/templates/wgcharter/approve.html index 1935e6699..1fba5eed5 100644 --- a/ietf/templates/wgcharter/approve_ballot.html +++ b/ietf/templates/wgcharter/approve.html @@ -1,15 +1,15 @@ {% extends "base.html" %} -{% block title %}Approve ballot for {{ wg.acronym }}{% endblock %} +{% block title %}Approve {{ charter.canonical_name }}{% endblock %} {% block morecss %} -form.approve-ballot pre { +form.approve pre { margin: 0; padding: 4px; border-top: 4px solid #eee; border-bottom: 4px solid #eee; } -form.approve-ballot .announcement { +form.approve .announcement { overflow-x: auto; overflow-y: scroll; width: 800px; @@ -19,18 +19,18 @@ form.approve-ballot .announcement { {% endblock %} {% block content %} -

Approve Ballot for {{ wg.acronym }}

+

Approve {{ charter.canonical_name }}

IETF announcement:
-
+
{{ announcement }}
- Back + Back
diff --git a/ietf/wgcharter/tests.py b/ietf/wgcharter/tests.py index 07daf4a9b..e5d2c4f3a 100644 --- a/ietf/wgcharter/tests.py +++ b/ietf/wgcharter/tests.py @@ -38,7 +38,7 @@ class EditCharterTestCase(django.test.TestCase): group = Group.objects.get(acronym="ames") charter = group.charter - url = urlreverse('wg_change_state', kwargs=dict(name=charter.name)) + url = urlreverse('charter_change_state', kwargs=dict(name=charter.name)) login_testing_unauthorized(self, "secretary", url) first_state = charter.get_state() @@ -121,7 +121,7 @@ class EditCharterTestCase(django.test.TestCase): group = Group.objects.get(acronym="mars") charter = group.charter - url = urlreverse('wg_submit', kwargs=dict(name=charter.name)) + url = urlreverse('charter_submit', kwargs=dict(name=charter.name)) login_testing_unauthorized(self, "secretary", url) # normal get @@ -153,16 +153,16 @@ class CharterApproveBallotTestCase(django.test.TestCase): def tearDown(self): shutil.rmtree(self.charter_dir) - def test_approve_ballot(self): + def test_approve(self): make_test_data() group = Group.objects.get(acronym="ames") charter = group.charter - url = urlreverse('wg_approve_ballot', kwargs=dict(name=charter.name)) + url = urlreverse('charter_approve', 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: + with open(os.path.join(self.charter_dir, "%s-%s.txt" % (charter.canonical_name(), charter.rev)), "w") as f: f.write("This is a charter.") p = Person.objects.get(name="Aread Irector") diff --git a/ietf/wgcharter/urls.py b/ietf/wgcharter/urls.py index 71a7fa770..1673cc92c 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'^state/$', "ietf.wgcharter.views.change_state", name='wg_change_state'), - url(r'^(?P