From f05bc8cf1f4b3497851b1b4ecab5910d8554df6f Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Sat, 25 Feb 2012 01:48:33 +0000 Subject: [PATCH] Add "Assigned to area" select box to individually submitted documents in the AD edit form, change search to define area = doc.group or doc.group.parent (so don't take AD into account), plus a bunch of small tweaks to make a document with an area set as group behave like an individually submitted document, at least for the time being (they are presented as "Individual in xyz area" on their document page) - Legacy-Id: 3968 --- ietf/doc/proxy.py | 20 ++++++++++---------- ietf/idrfc/expire.py | 2 +- ietf/idrfc/idrfc_wrapper.py | 10 ++++++++-- ietf/idrfc/mails.py | 8 ++++---- ietf/idrfc/views_ballot.py | 2 +- ietf/idrfc/views_edit.py | 23 +++++++++++++++++++---- ietf/idrfc/views_search.py | 4 +--- ietf/submit/forms.py | 2 ++ ietf/submit/utils.py | 5 ++++- 9 files changed, 50 insertions(+), 26 deletions(-) diff --git a/ietf/doc/proxy.py b/ietf/doc/proxy.py index 2f36d2695..64795f83c 100644 --- a/ietf/doc/proxy.py +++ b/ietf/doc/proxy.py @@ -232,7 +232,11 @@ class InternetDraft(Document): def filename_with_rev(self): return "%s-%s.txt" % (self.filename, self.revision_display()) def group_acronym(self): - return super(Document, self).group.acronym + g = super(Document, self).group + if g.type_id == "area": + return "none" + else: + return g.acronym def group_ml_archive(self): return self.group.list_archive def idstate(self): @@ -385,15 +389,11 @@ class InternetDraft(Document): def area_acronym(self): from ietf.group.proxy import Area g = super(InternetDraft, self).group # be careful with group which is proxied - if g and g.type_id != "individ": - return Area().from_object(g.parent) - elif self.ad: - # return area for AD - try: - area = Group.objects.get(role__name="ad", role__person=self.ad, state="active") - return Area().from_object(area) - except Group.DoesNotExist: - return None + if g: + if g.type_id == "area": + return Area().from_object(g) + elif g.type_id != "individ": + return Area().from_object(g.parent) else: return None diff --git a/ietf/idrfc/expire.py b/ietf/idrfc/expire.py index ff40dfad1..27d4657c5 100644 --- a/ietf/idrfc/expire.py +++ b/ietf/idrfc/expire.py @@ -101,7 +101,7 @@ def send_expire_warning_for_idREDESIGN(doc): to = [e.formatted_email() for e in doc.authors.all() if not e.address.startswith("unknown-email")] cc = None - if doc.group.type_id != "individ": + if doc.group.type_id in ("wg", "rg"): cc = [e.formatted_email() for e in Email.objects.filter(role__group=doc.group, role__name="chair") if not e.address.startswith("unknown-email")] s = doc.get_state("draft-iesg") diff --git a/ietf/idrfc/idrfc_wrapper.py b/ietf/idrfc/idrfc_wrapper.py index 1c18a1b0e..cf730c8ce 100644 --- a/ietf/idrfc/idrfc_wrapper.py +++ b/ietf/idrfc/idrfc_wrapper.py @@ -158,7 +158,11 @@ class IdWrapper: if self._draft.group_id == Acronym.INDIVIDUAL_SUBMITTER: return "Individual" - + + if settings.USE_DB_REDESIGN_PROXY_CLASSES: + if self._draft.group and self._draft.group.type_id == "area": + return u"Individual in %s area" % self._draft.group.acronym + a = self.group_acronym() if a: if settings.USE_DB_REDESIGN_PROXY_CLASSES and self._draft.stream_id == "ietf" and self._draft.get_state_slug("draft-stream-ietf") == "c-adopt": @@ -174,7 +178,7 @@ class IdWrapper: if self._idinternal and self._idinternal.via_rfc_editor: return "www.ietf.org/mail-archive/web/" - if self._draft.group_id == Acronym.INDIVIDUAL_SUBMITTER: + if self._draft.group_id == Acronym.INDIVIDUAL_SUBMITTER or (settings.USE_DB_REDESIGN_PROXY_CLASSES and self._draft.group.type_id == "area"): return "www.ietf.org/mail-archive/web/" a = self._draft.group_ml_archive() @@ -188,6 +192,8 @@ class IdWrapper: def group_acronym(self): if self._draft.group_id != 0 and self._draft.group != None and str(self._draft.group) != "none": + if settings.USE_DB_REDESIGN_PROXY_CLASSES and self._draft.group.type_id == "area": + return None return str(self._draft.group) else: return None diff --git a/ietf/idrfc/mails.py b/ietf/idrfc/mails.py index cd0eef59f..19592b138 100644 --- a/ietf/idrfc/mails.py +++ b/ietf/idrfc/mails.py @@ -151,7 +151,7 @@ def generate_last_call_announcementREDESIGN(request, doc): expiration_date = date.today() + timedelta(days=14) cc = [] - if doc.group.type_id == "individ": + if doc.group.type_id in ("individ", "area"): group = "an individual submitter" expiration_date += timedelta(days=14) else: @@ -308,7 +308,7 @@ def generate_approval_mail_approved(request, doc): # the second check catches some area working groups (like # Transport Area Working Group) - if doc.group.type_id not in ("area", "individ") and not doc.group.name.endswith("Working Group"): + if doc.group.type_id not in ("area", "individ", "ag") and not doc.group.name.endswith("Working Group"): doc.group.name_with_wg = doc.group.name + " Working Group" if doc.group.list_email: cc.append("%s mailing list <%s>" % (doc.group.acronym, doc.group.list_email)) @@ -318,7 +318,7 @@ def generate_approval_mail_approved(request, doc): doc.filled_title = textwrap.fill(doc.title, width=70, subsequent_indent=" " * 3) - if doc.group.type_id == "individ": + if doc.group.type_id in ("individ", "area"): made_by = "This document has been reviewed in the IETF but is not the product of an IETF Working Group." else: made_by = "This document is the product of the %s." % doc.group.name_with_wg @@ -326,7 +326,7 @@ def generate_approval_mail_approved(request, doc): director = doc.ad other_director = Person.objects.filter(role__group__role__person=director, role__group__role__name="ad").exclude(pk=director.pk) - if doc.group.type_id != "individ" and other_director: + if doc.group.type_id not in ("individ", "area") and other_director: contacts = "The IESG contact persons are %s and %s." % (director.plain_name(), other_director[0].plain_name()) else: contacts = "The IESG contact person is %s." % director.plain_name() diff --git a/ietf/idrfc/views_ballot.py b/ietf/idrfc/views_ballot.py index 6701facf2..6169bba2e 100644 --- a/ietf/idrfc/views_ballot.py +++ b/ietf/idrfc/views_ballot.py @@ -1385,7 +1385,7 @@ def make_last_callREDESIGN(request, name): initial = {} initial["last_call_sent_date"] = date.today() expire_days = 14 - if doc.group.type_id == "individ": + if doc.group.type_id in ("individ", "area"): expire_days = 28 initial["last_call_expiration_date"] = date.today() + timedelta(days=expire_days) diff --git a/ietf/idrfc/views_edit.py b/ietf/idrfc/views_edit.py index ad865f0ce..1d946cdc2 100644 --- a/ietf/idrfc/views_edit.py +++ b/ietf/idrfc/views_edit.py @@ -443,6 +443,7 @@ class EditInfoFormREDESIGN(forms.Form): intended_std_level = forms.ModelChoiceField(IntendedStdLevelName.objects.all(), empty_label="(None)", required=True, label="Intended RFC status") via_rfc_editor = forms.BooleanField(required=False, label="Via IRTF or RFC Editor") stream = forms.ModelChoiceField(StreamName.objects.all(), empty_label="(None)", required=True) + area = forms.ModelChoiceField(Group.objects.filter(type="area", state="active"), empty_label="(None - individual submission)", required=False, label="Assigned to area") ad = forms.ModelChoiceField(Person.objects.filter(role__name="ad", role__group__state="active").order_by('name'), label="Responsible AD", empty_label="(None)", required=True) create_in_state = forms.ModelChoiceField(State.objects.filter(type="draft-iesg", slug__in=("pub-req", "watching")), empty_label=None, required=False) notify = forms.CharField(max_length=255, label="Notice emails", help_text="Separate email addresses with commas", required=False) @@ -478,7 +479,7 @@ class EditInfoFormREDESIGN(forms.Form): def get_initial_notify(doc): # set change state notice to something sensible receivers = [] - if doc.group.type_id == "individ": + if doc.group.type_id in ("individ", "area"): for a in doc.authors.all(): receivers.append(a.address) else: @@ -546,9 +547,9 @@ def edit_infoREDESIGN(request, name): changes = [] def desc(attr, new, old): - entry = "%(attr)s has been changed to %(new)s from %(old)s" + entry = "%(attr)s changed to %(new)s from %(old)s" if new_document: - entry = "%(attr)s has been changed to %(new)s" + entry = "%(attr)s changed to %(new)s" return entry % dict(attr=attr, new=new, old=old) @@ -576,6 +577,17 @@ def edit_infoREDESIGN(request, name): doc.note = r['note'] + if doc.group.type_id in ("individ", "area"): + if not r["area"]: + r["area"] = Group.objects.get(type="individ") + + if r["area"] != doc.group: + if r["area"].type_id == "area": + changes.append(u"Assigned to %s" % r["area"].name) + else: + changes.append(u"No longer assigned to any area") + doc.group = r["area"] + for c in changes: e = DocEvent(doc=doc, by=login) e.desc = c @@ -601,6 +613,7 @@ def edit_infoREDESIGN(request, name): return HttpResponseRedirect(doc.get_absolute_url()) else: init = dict(intended_std_level=doc.intended_std_level_id, + area=doc.group_id, ad=doc.ad_id, stream=doc.stream_id, notify=doc.notify, @@ -616,7 +629,9 @@ def edit_infoREDESIGN(request, name): form.standard_fields = [x for x in form.standard_fields if x.name != "create_in_state"] if not has_role(request.user, 'Secretariat'): form.standard_fields = [x for x in form.standard_fields if x.name != "via_rfc_editor"] - + if doc.group.type_id not in ("individ", "area"): + form.standard_fields = [x for x in form.standard_fields if x.name != "area"] + return render_to_response('idrfc/edit_infoREDESIGN.html', dict(doc=doc, form=form, diff --git a/ietf/idrfc/views_search.py b/ietf/idrfc/views_search.py index 4667a6475..a564deffd 100644 --- a/ietf/idrfc/views_search.py +++ b/ietf/idrfc/views_search.py @@ -360,9 +360,7 @@ if settings.USE_DB_REDESIGN_PROXY_CLASSES: docs = docs.filter(group__acronym=query["group"]) elif by == "area": docs = docs.filter(Q(group__type="wg", group__parent=query["area"]) | - Q(group__type="individ", - ad__role__name="ad", - ad__role__group=query["area"])).distinct() + Q(group=query["area"])).distinct() elif by == "ad": docs = docs.filter(ad=query["ad"]) elif by == "state": diff --git a/ietf/submit/forms.py b/ietf/submit/forms.py index cbc5d9f67..03c4b280a 100644 --- a/ietf/submit/forms.py +++ b/ietf/submit/forms.py @@ -229,6 +229,8 @@ class UploadForm(forms.Form): if existing_draft: group = existing_draft[0].group and existing_draft[0].group.ietfwg or None if group and group.pk != NONE_WG: + if settings.USE_DB_REDESIGN_PROXY_CLASSES and group.type_id == "area": + return None return group else: return None diff --git a/ietf/submit/utils.py b/ietf/submit/utils.py index 9671116c0..d2cada102 100644 --- a/ietf/submit/utils.py +++ b/ietf/submit/utils.py @@ -107,7 +107,10 @@ def perform_postREDESIGN(request, submission): draft.type_id = "draft" draft.time = datetime.datetime.now() draft.title = submission.id_document_name - draft.group_id = group_id + if not (group_id == NONE_WG and draft.group and draft.group.type_id == "area"): + # don't overwrite an assigned area if it's still an individual + # submission + draft.group_id = group_id draft.rev = submission.revision draft.pages = submission.txt_page_count draft.abstract = submission.abstract