From c67661311f478900b0f509d71b34b68dd68b9b72 Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Mon, 28 Jan 2013 16:25:42 +0000 Subject: [PATCH] Improved validaiton of status change document name added the ability to start a status change when looking at an RFC (populating the start from accordingly) Made changes and proposed changes show on the RFC pages - Legacy-Id: 5330 --- ietf/doc/views_status_change.py | 45 +++++++++++++++--- ietf/idrfc/idrfc_wrapper.py | 5 ++ ietf/idrfc/urls.py | 2 +- ietf/idrfc/views_doc.py | 14 +++++- ietf/idtracker/templatetags/ietf_filters.py | 1 + ietf/iesg/views.py | 8 ++++ ietf/templates/doc/status_change/start.html | 27 ++++++----- .../doc/status_change/status_changes.html | 2 +- ietf/templates/idrfc/doc_tab_document.html | 47 ++++++++++--------- .../templates/idrfc/doc_tab_document_rfc.html | 2 + 10 files changed, 109 insertions(+), 44 deletions(-) diff --git a/ietf/doc/views_status_change.py b/ietf/doc/views_status_change.py index ad053dfba..560f2e9fe 100644 --- a/ietf/doc/views_status_change.py +++ b/ietf/doc/views_status_change.py @@ -438,6 +438,7 @@ class StartStatusChangeForm(forms.Form): def __init__(self, *args, **kwargs): super(self.__class__, self).__init__(*args, **kwargs) + self.relations = self.initial.get('relations') # telechat choices dates = [d.date for d in TelechatDate.objects.active().order_by('date')] @@ -445,15 +446,37 @@ class StartStatusChangeForm(forms.Form): def clean_document_name(self): name = self.cleaned_data['document_name'] + errors=[] + if re.search("[^a-z0-9-]", name): + errors.append("The name of the document may only contain digits, lowercase letters and dashes") + if re.search("--", name): + errors.append("Please do not put more than one hyphen between any two words in the name") + if name.startswith('status-change'): + errors.append("status-change- will be added automatically as a prefix") + if name.startswith('-'): + errors.append("status-change- will be added automatically as a prefix, starting with a - will result in status-change-%s"%name) + if re.search("-[0-9]{2}$", name): + errors.append("This name looks like ends in a version number. -00 will be added automatically. Please adjust the end of the name.") if Document.objects.filter(name='status-change-%s'%name): - raise forms.ValidationError("status-change-%s already exists"%name) + errors.append("status-change-%s already exists"%name) + if name.endswith('CHANGETHIS'): + errors.append("Please change CHANGETHIS to reflect the intent of this status change") + if errors: + raise forms.ValidationError(errors) return name + def clean_title(self): + title = self.cleaned_data['title'] + errors=[] + if title.endswith('CHANGETHIS'): + errors.append("Please change CHANGETHIS to reflect the intent of this status change") + if errors: + raise forms.ValidationError(errors) + return title + def clean(self): return clean_helper(self,StartStatusChangeForm) -#TODO - cleaned data, especially on document_name - def rfc_status_changes(request): """Show the rfc status changes that are under consideration, and those that are completed.""" @@ -466,9 +489,14 @@ def rfc_status_changes(request): context_instance = RequestContext(request)) @role_required("Area Director","Secretariat") -def start_rfc_status_change(request): +def start_rfc_status_change(request,name): """Start the RFC status change review process, setting the initial shepherding AD, and possibly putting the review on a telechat.""" + if name: + if not re.match("(?i)rfc[0-9]{4}",name): + raise Http404 + seed_rfc = get_object_or_404(Document, type="draft", docalias__name=name) + login = request.user.get_profile() relation_slugs = DocRelationshipName.objects.filter(slug__in=RELATION_SLUGS) @@ -505,8 +533,13 @@ def start_rfc_status_change(request): return HttpResponseRedirect(status_change.get_absolute_url()) else: - init = { - } + init = {} + if name: + init['title'] = "%s to CHANGETHIS" % seed_rfc.title + init['document_name'] = "%s-to-CHANGETHIS" % seed_rfc.canonical_name() + relations={} + relations[seed_rfc.canonical_name()]=None + init['relations'] = relations form = StartStatusChangeForm(initial=init) return render_to_response('doc/status_change/start.html', diff --git a/ietf/idrfc/idrfc_wrapper.py b/ietf/idrfc/idrfc_wrapper.py index b9e1c7dd3..3d1e5c93d 100644 --- a/ietf/idrfc/idrfc_wrapper.py +++ b/ietf/idrfc/idrfc_wrapper.py @@ -405,6 +405,11 @@ class RfcWrapper: result['ietf_process'] = self.ietf_process.dict() return json.dumps(result, indent=2) + def underlying_document(self): + """ Expose the Document object underneath the proxy """ + from ietf.doc.models import Document + return Document.objects.get(docalias__name='rfc%04d'%self.rfc_number) + # --------------------------------------------------------------------------- class IetfProcessData: diff --git a/ietf/idrfc/urls.py b/ietf/idrfc/urls.py index 4e2e83b04..d3acd53e2 100644 --- a/ietf/idrfc/urls.py +++ b/ietf/idrfc/urls.py @@ -42,7 +42,7 @@ urlpatterns = patterns('', (r'^active/$', views_search.active), (r'^in-last-call/$', views_search.in_last_call), url(r'^rfc-status-changes/$', views_status_change.rfc_status_changes, name='rfc_status_changes'), - url(r'^start-rfc-status-change/$', views_status_change.start_rfc_status_change, name='start_rfc_status_change'), + url(r'^start-rfc-status-change/(?P[A-Za-z0-9._+-]*)$', views_status_change.start_rfc_status_change, name='start_rfc_status_change'), url(r'^ad/(?P[A-Za-z0-9.-]+)/$', views_search.by_ad, name="doc_search_by_ad"), url(r'^(?P[A-Za-z0-9._+-]+)/((?P[0-9-]+)/)?$', views_doc.document_main, name="doc_view"), diff --git a/ietf/idrfc/views_doc.py b/ietf/idrfc/views_doc.py index 6f5a76541..6936e447d 100644 --- a/ietf/idrfc/views_doc.py +++ b/ietf/idrfc/views_doc.py @@ -54,6 +54,7 @@ from ietf.doc.models import * from ietf.doc.utils import * from ietf.utils.history import find_history_active_at from ietf.ietfauth.decorators import has_role +from ietf.doc.views_status_change import RELATION_SLUGS as status_change_relationships def render_document_top(request, doc, tab, name): tabs = [] @@ -236,7 +237,7 @@ def document_history(request, name): diff_revisions = [] seen = set() - diffable = name.startswith("draft") or name.startswith("charter") or name.startswith("conflict-review") + diffable = name.startswith("draft") or name.startswith("charter") or name.startswith("conflict-review") or name.startswith("status-change") if diffable: for e in NewRevisionDocEvent.objects.filter(type="new_revision", doc__in=diff_documents).select_related('doc').order_by("-time", "-id"): @@ -250,6 +251,9 @@ def document_history(request, name): elif name.startswith("conflict-review"): h = find_history_active_at(e.doc, e.time) url = settings.CONFLICT_REVIEW_TXT_URL + ("%s-%s.txt" % ((h or doc).canonical_name(), e.rev)) + elif name.startswith("status-change"): + h = find_history_active_at(e.doc, e.time) + url = settings.STATUS_CHANGE_TXT_URL + ("%s-%s.txt" % ((h or doc).canonical_name(), e.rev)) elif name.startswith("draft"): # rfcdiff tool has special support for IDs url = e.doc.name + "-" + e.rev @@ -450,6 +454,14 @@ def document_main_rfc(request, rfc_number, tab): content1 = "" content2 = "" + info['status_changes'] = ', '.join([ rel.source.canonical_name() for rel in RelatedDocument.objects.filter(relationship__in=status_change_relationships,target__document=doc.underlying_document()) if rel.source.get_state_slug() in ('appr-sent','appr-pend')]) + info['proposed_status_changes'] = ', '.join([ rel.source.canonical_name() for rel in RelatedDocument.objects.filter(relationship__in=status_change_relationships,target__document=doc.underlying_document()) if rel.source.get_state_slug() in ('needshep','adrev','iesgeval','defer','appr-pr')]) + + print "DEBUGGING" + print doc.underlying_document() + print "status_changes",info['status_changes'] + print "proposed_status_changes",info['proposed_status_changes'] + history = _get_history(doc, None) template = "idrfc/doc_tab_%s" % tab diff --git a/ietf/idtracker/templatetags/ietf_filters.py b/ietf/idtracker/templatetags/ietf_filters.py index f48a30a8a..b55f88aac 100644 --- a/ietf/idtracker/templatetags/ietf_filters.py +++ b/ietf/idtracker/templatetags/ietf_filters.py @@ -226,6 +226,7 @@ def urlize_ietf_docs(string, autoescape=None): string = re.sub("(?)(FYI ?)0{0,3}(\d+)", "\\1\\2", string) string = re.sub("(?)(draft-[-0-9a-zA-Z._+]+)", "\\1", string) string = re.sub("(?)(conflict-review-[-0-9a-zA-Z._+]+)", "\\1", string) + string = re.sub("(?)(status-change-[-0-9a-zA-Z._+]+)", "\\1", string) return mark_safe(string) urlize_ietf_docs.is_safe = True urlize_ietf_docs.needs_autoescape = True diff --git a/ietf/iesg/views.py b/ietf/iesg/views.py index 9b8da1bf7..a0ab5aa05 100644 --- a/ietf/iesg/views.py +++ b/ietf/iesg/views.py @@ -166,6 +166,14 @@ def get_doc_sectionREDESIGN(doc): s = "332" else: s = "331" + elif doc.type_id == 'statchg': + # TODO This is WRONG + s="211" + #protocol_action = False + #for relation in doc.relateddocument_set.filter(relationship__in="('tops','tois','tohist','toinf','tobcp,'toexp')"): + # if relation.relationship.slug in ('tops','tois') or relation.target.document.std_level.slug in ('std','ds','ps'): + # protocol_action = True + #if protocol_action: return s diff --git a/ietf/templates/doc/status_change/start.html b/ietf/templates/doc/status_change/start.html index 07fb2f6f3..0e15d969a 100644 --- a/ietf/templates/doc/status_change/start.html +++ b/ietf/templates/doc/status_change/start.html @@ -6,6 +6,9 @@ form.start-rfc-status-change-review #id_notify { width: 600px; } +form.start-rfc-status-change-review #id_title { + width: 600px; +} form.start-rfc-status-change-review #id_document_name { width: 510px; } @@ -29,18 +32,6 @@ form.start-rfc-status-change-review .actions {
- {% for field in form.visible_fields %} - - - - - {% if field.label == "Document name" %}
{{ field.label_tag }}: - {% if field.label == "Document name" %}status-change-{% endif %} - {{ field }} - {% if field.help_text %}
{{ field.help_text }}
{% endif %} - - {{ field.errors }} -
Affects RFCs: @@ -77,7 +68,17 @@ form.start-rfc-status-change-review .actions { {{ form.non_field_errors }} - {% endif %} + {% for field in form.visible_fields %} + + + + {% endfor %}
{{ field.label_tag }}: + {% if field.label == "Document name" %}status-change-{% endif %} + {{ field }} + {% if field.help_text %}
{{ field.help_text }}
{% endif %} + + {{ field.errors }} +
diff --git a/ietf/templates/doc/status_change/status_changes.html b/ietf/templates/doc/status_change/status_changes.html index 8106fecb0..5b84dd4ab 100644 --- a/ietf/templates/doc/status_change/status_changes.html +++ b/ietf/templates/doc/status_change/status_changes.html @@ -5,7 +5,7 @@

RFC Status Changes

{% if user|in_group:"Area_Director,Secretariat" %} -

Start new RFC status change document

+

Start new RFC status change document

{% endif %} {% regroup docs by get_state as state_groups %} diff --git a/ietf/templates/idrfc/doc_tab_document.html b/ietf/templates/idrfc/doc_tab_document.html index e4f91e1bd..7ec5f7bc8 100644 --- a/ietf/templates/idrfc/doc_tab_document.html +++ b/ietf/templates/idrfc/doc_tab_document.html @@ -47,29 +47,32 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. {% block doc_metabuttons %} {% if user|in_group:"Area_Director,Secretariat" %} -
-{% ifequal doc.draft_status "Expired" %} -{% if not doc.resurrect_requested_by %} -Request resurrect -{% endif %} -{% if user|in_group:"Secretariat" %} -Resurrect -{% endif %} -{% else %} -{% if stream_info.stream.name == 'ISE' or stream_info.stream.name == 'IRTF' %} -{% if user|in_group:"Secretariat" and not info.conflict_reviews %} -{% url conflict_review_start name=doc.draft_name as start_review_url %}{% if start_review_url %}Begin IETF Conflict Review {% if not doc.underlying_document.intended_std_level %}(note that intended status is not set){% endif %}{% endif %} -{% endif %} -{% else %} - {% if stream_info.stream.name == 'IETF'%}{%if not doc.in_ietf_process %} - {% url doc_edit_info name=doc.draft_name as doc_edit_url %}{% if doc_edit_url %}Begin IESG Processing{% endif %} - {% endif %}{% endif %} -{% endif %} -{% endifequal %} - -
+
+ {% ifequal doc.draft_status "Expired" %} + {% if not doc.resurrect_requested_by and user|in_group:"Area_Director" %} + Request resurrect + {% endif %} + {% if user|in_group:"Secretariat" %} + Resurrect + {% endif %} + {% else %} {# not expired #} + {% if stream_info.stream.name == 'ISE' or stream_info.stream.name == 'IRTF' %} + {% if user|in_group:"Secretariat" and not info.conflict_reviews %} + {% url conflict_review_start name=doc.draft_name as start_review_url %}{% if start_review_url %}Begin IETF Conflict Review {% if not doc.underlying_document.intended_std_level %}(note that intended status is not set){% endif %}{% endif %} + {% endif %} + {% else %} {# Not a candidate for conflict review #} + {% if stream_info.stream.name == 'IETF' and not doc.in_ietf_process %} + {% url doc_edit_info name=doc.draft_name as doc_edit_url %}{% if doc_edit_url %}Begin IESG Processing{% endif %} + {% else %} + {% if doc.underlying_document.get_state_slug == 'rfc' %} + {% url start_rfc_status_change name=doc.underlying_document.canonical_name as start_url %}{% if start_url %}Start {% if info.proposed_status_changes %}An Additional {% endif %}Status Change{% endif %} + {% endif %} + {% endif %} + {% endif %} + {% endifequal %} +
{% endif %}{# if user in group #} -{% endblock doc_metabuttons%} +{% endblock doc_metabuttons %}
diff --git a/ietf/templates/idrfc/doc_tab_document_rfc.html b/ietf/templates/idrfc/doc_tab_document_rfc.html index dab62087a..8d595dd64 100644 --- a/ietf/templates/idrfc/doc_tab_document_rfc.html +++ b/ietf/templates/idrfc/doc_tab_document_rfc.html @@ -41,6 +41,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. {% if doc.updated_by %}
Updated by {{ doc.updated_by|urlize_ietf_docs }}{%endif %} {% if doc.obsoletes %}
Obsoletes {{ doc.obsoletes|urlize_ietf_docs }}{%endif %} {% if doc.updates %}
Updates {{ doc.updates|urlize_ietf_docs }}{%endif %} +{% if info.status_changes %}
Status changed by {{ info.status_changes|urlize_ietf_docs }}{% endif %} +{% if info.proposed_status_changes %}
Proposed status changes by {{ info.proposed_status_changes|urlize_ietf_docs }}{% endif %} {% if doc.also %}
Also Known As {{ doc.also|urlize_ietf_docs }}{%endif %} {% if doc.draft_name %}
Was {{doc.draft_name}}{% endif %} {% if doc.has_errata %}
Errata{% endif %}