From 89a8834177fa24ee9d35ca125ec8760f3c1da809 Mon Sep 17 00:00:00 2001 From: Bill Fenner Date: Fri, 8 Jun 2007 19:54:59 +0000 Subject: [PATCH] Rename "initial" to "initial_members" so that it doesn't shadow the form attribute "initial" (as in initial data) Render the form field-by-field for MailingListForm, so that we can render the mailing list name conditionally as a text input box or as a hidden field with the value in the page. We can also insert the domain name here too. (Note that this means that hidden fields in this form other than domain name have to be treated specially!) - Legacy-Id: 270 --- ietf/mailinglists/forms.py | 3 +- ietf/mailinglists/models.py | 2 +- ietf/mailinglists/views.py | 7 +++-- ietf/templates/mailinglists/list_summary.html | 2 +- ietf/templates/mailinglists/list_summary.txt | 2 +- .../list_wizard_ListReqClose.html | 1 + .../list_wizard_MailingListForm.html | 29 +++++++++++++++++++ 7 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 ietf/templates/mailinglists/list_wizard_ListReqClose.html create mode 100644 ietf/templates/mailinglists/list_wizard_MailingListForm.html diff --git a/ietf/mailinglists/forms.py b/ietf/mailinglists/forms.py index 9ff93a1bf..0919e9dd4 100644 --- a/ietf/mailinglists/forms.py +++ b/ietf/mailinglists/forms.py @@ -169,8 +169,7 @@ class ListReqAuthorized(forms.Form): class ListReqClose(forms.Form): requestor = forms.CharField(label = "Requestor's full name", widget = forms.TextInput(attrs = {'size': 55})) requestor_email = forms.EmailField(label = "Requestor's email address", widget = forms.TextInput(attrs = {'size': 55})) - # todo: right widgets for these - mlist_name = forms.CharField(widget = forms.HiddenInput()) + mlist_name = forms.CharField(label = 'Mailing List Name') # will turn into just display field by template. domain_name = forms.CharField(widget = forms.HiddenInput()) reason_to_delete = forms.CharField(label = 'Reason for closing list', widget = forms.Textarea(attrs = {'rows': 4, 'cols': 60})) diff --git a/ietf/mailinglists/models.py b/ietf/mailinglists/models.py index 2ef3756d0..6f770c715 100644 --- a/ietf/mailinglists/models.py +++ b/ietf/mailinglists/models.py @@ -80,7 +80,7 @@ class MailingList(models.Model): long_desc = models.TextField('Long description of the email list') # admins is a VARCHAR but can have multiple lines. admins = models.TextField('Mailing list administrators (one address per line)', maxlength=250) - initial = models.TextField('Enter email address(es) of initial subscriber(s) (one address per line) (optional)', blank=True) + initial_members = models.TextField('Enter email address(es) of initial subscriber(s) (one address per line) (optional)', blank=True, db_column='initial') welcome_message = models.TextField('Provide a welcome message for initial subscriber(s)(optional)', blank=True) welcome_new = models.TextField('Provide a welcome message for new subscriber(s)(optional)', blank=True) subscription = models.IntegerField('What steps are required for subscription?', choices=SUBSCRIPTION_CHOICES) diff --git a/ietf/mailinglists/views.py b/ietf/mailinglists/views.py index c9eeb6362..f74e34be5 100644 --- a/ietf/mailinglists/views.py +++ b/ietf/mailinglists/views.py @@ -147,7 +147,7 @@ list_fields = { 'mail_type': None, 'mail_cat': None, 'admins': MultiEmailField(label='List Administrator(s)', widget=AdminRequestor(attrs={'cols': 41, 'rows': 4})), - 'initial': MultiEmailField(label='Initial list member(s)', widget=forms.Textarea(attrs={'cols': 41, 'rows': 4}), required=False), + 'initial_members': MultiEmailField(label='Initial list member(s)', widget=forms.Textarea(attrs={'cols': 41, 'rows': 4}), required=False), } list_labels = { @@ -170,7 +170,7 @@ list_attrs = { 'short_desc': { 'size': 55 }, 'long_desc': { 'cols': 41, 'rows': 4, 'wrap': 'virtual' }, 'admins': { 'cols': 41, 'rows': 4 }, - 'initial': { 'cols': 41, 'rows': 4 }, + 'initial_members': { 'cols': 41, 'rows': 4 }, 'welcome_message': { 'cols': 41, 'rows': 4 }, 'welcome_new': { 'cols': 41, 'rows': 4 }, 'archive_remote': { 'cols': 41, 'rows': 4 }, @@ -190,6 +190,7 @@ class ListReqWizard(wizard.Wizard): clean_forms = [] main_step = 1 requestor_is_approver = False + mlist_known = True def get_template(self): templates = [] #if self.step > 0: @@ -204,6 +205,7 @@ class ListReqWizard(wizard.Wizard): return templates def render_template(self, *args, **kwargs): #self.extra_context['clean_forms'] = self.clean_forms + self.extra_context['mlist_known'] = self.mlist_known if self.step > self.main_step: self.extra_context['main_form'] = self.clean_forms[self.main_step] self.extra_context['requestor_is_approver'] = self.requestor_is_approver @@ -234,6 +236,7 @@ class ListReqWizard(wizard.Wizard): self.initial[self.main_step] = {'mlist_name': form.clean_data['group']} else: self.initial[self.main_step] = {} + self.mlist_known = False if form.clean_data['mail_type'].endswith('wg'): self.initial[self.main_step].update({'domain_name': 'ietf.org'}) else: diff --git a/ietf/templates/mailinglists/list_summary.html b/ietf/templates/mailinglists/list_summary.html index 0d6cc69cb..64c81679f 100644 --- a/ietf/templates/mailinglists/list_summary.html +++ b/ietf/templates/mailinglists/list_summary.html @@ -8,7 +8,7 @@ Short description of the email list: {{ list.short_desc|escape }} Long description of the email list: {{ list.long_desc|escape }} Administrator(s):
{{ list.admins|escape }}
- Email address(es) of initial subscriber(s) (optional):
{{ list.initial|escape }}
+ Email address(es) of initial subscriber(s) (optional):
{{ list.initial_members|escape }}
Welcome message for initial subscriber(s) (optional): {{ list.welcome_message|linebreaksbr }} Welcome message for new subscriber(s) (optional): {{ list.welcome_new|linebreaksbr }} Required steps for subscription: {{ list.get_subscription_display }} diff --git a/ietf/templates/mailinglists/list_summary.txt b/ietf/templates/mailinglists/list_summary.txt index fd73a3a37..9f7d10f91 100644 --- a/ietf/templates/mailinglists/list_summary.txt +++ b/ietf/templates/mailinglists/list_summary.txt @@ -17,7 +17,7 @@ Administrator(s): {{ list.admins }} Email address(es) of the initial subscriber(s) (optional): -{{ list.initial }} +{{ list.initial_members }} Welcome message for initial subscriber(s) (optional): {{ list.welcome_message }} diff --git a/ietf/templates/mailinglists/list_wizard_ListReqClose.html b/ietf/templates/mailinglists/list_wizard_ListReqClose.html new file mode 100644 index 000000000..765ec42f3 --- /dev/null +++ b/ietf/templates/mailinglists/list_wizard_ListReqClose.html @@ -0,0 +1 @@ +{% include "mailinglists/list_wizard_MailingListForm.html" %} diff --git a/ietf/templates/mailinglists/list_wizard_MailingListForm.html b/ietf/templates/mailinglists/list_wizard_MailingListForm.html new file mode 100644 index 000000000..4ea1e9545 --- /dev/null +++ b/ietf/templates/mailinglists/list_wizard_MailingListForm.html @@ -0,0 +1,29 @@ +{% extends "mailinglists/list_wizard_base.html" %} + +{% block mlform %} +{% for field in form %} +{% if field.is_hidden %} +{# we assume that the only hidden form is the domain name #} +{# so don't render anything #} +{% else %} + +{{ field.label_tag }}: + +{% if field.errors %} + +{% endif %} +{% ifequal field.name "mlist_name" %} +{% if mlist_known %}{# if we know the mailing list name already #} +{{ form.initial.mlist_name }}@{{ form.initial.domain_name }}{{ field.as_hidden }} +{% else %} +{{ field }}@{{ form.initial.domain_name }} +{% endif %} +{{ form.domain_name.as_hidden }} +{% else %} +{{ field }} +{% endifequal %} + + +{% endif %} +{% endfor %} +{% endblock %}