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
This commit is contained in:
Bill Fenner 2007-06-08 19:54:59 +00:00
parent 415e274dde
commit 89a8834177
7 changed files with 39 additions and 7 deletions

View file

@ -169,8 +169,7 @@ class ListReqAuthorized(forms.Form):
class ListReqClose(forms.Form): class ListReqClose(forms.Form):
requestor = forms.CharField(label = "Requestor's full name", widget = forms.TextInput(attrs = {'size': 55})) 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})) requestor_email = forms.EmailField(label = "Requestor's email address", widget = forms.TextInput(attrs = {'size': 55}))
# todo: right widgets for these mlist_name = forms.CharField(label = 'Mailing List Name') # will turn into just display field by template.
mlist_name = forms.CharField(widget = forms.HiddenInput())
domain_name = forms.CharField(widget = forms.HiddenInput()) 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})) reason_to_delete = forms.CharField(label = 'Reason for closing list', widget = forms.Textarea(attrs = {'rows': 4, 'cols': 60}))

View file

@ -80,7 +80,7 @@ class MailingList(models.Model):
long_desc = models.TextField('Long description of the email list') long_desc = models.TextField('Long description of the email list')
# admins is a VARCHAR but can have multiple lines. # admins is a VARCHAR but can have multiple lines.
admins = models.TextField('Mailing list administrators (one address per line)', maxlength=250) 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_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) 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) subscription = models.IntegerField('What steps are required for subscription?', choices=SUBSCRIPTION_CHOICES)

View file

@ -147,7 +147,7 @@ list_fields = {
'mail_type': None, 'mail_type': None,
'mail_cat': None, 'mail_cat': None,
'admins': MultiEmailField(label='List Administrator(s)', widget=AdminRequestor(attrs={'cols': 41, 'rows': 4})), '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 = { list_labels = {
@ -170,7 +170,7 @@ list_attrs = {
'short_desc': { 'size': 55 }, 'short_desc': { 'size': 55 },
'long_desc': { 'cols': 41, 'rows': 4, 'wrap': 'virtual' }, 'long_desc': { 'cols': 41, 'rows': 4, 'wrap': 'virtual' },
'admins': { 'cols': 41, 'rows': 4 }, 'admins': { 'cols': 41, 'rows': 4 },
'initial': { 'cols': 41, 'rows': 4 }, 'initial_members': { 'cols': 41, 'rows': 4 },
'welcome_message': { 'cols': 41, 'rows': 4 }, 'welcome_message': { 'cols': 41, 'rows': 4 },
'welcome_new': { 'cols': 41, 'rows': 4 }, 'welcome_new': { 'cols': 41, 'rows': 4 },
'archive_remote': { 'cols': 41, 'rows': 4 }, 'archive_remote': { 'cols': 41, 'rows': 4 },
@ -190,6 +190,7 @@ class ListReqWizard(wizard.Wizard):
clean_forms = [] clean_forms = []
main_step = 1 main_step = 1
requestor_is_approver = False requestor_is_approver = False
mlist_known = True
def get_template(self): def get_template(self):
templates = [] templates = []
#if self.step > 0: #if self.step > 0:
@ -204,6 +205,7 @@ class ListReqWizard(wizard.Wizard):
return templates return templates
def render_template(self, *args, **kwargs): def render_template(self, *args, **kwargs):
#self.extra_context['clean_forms'] = self.clean_forms #self.extra_context['clean_forms'] = self.clean_forms
self.extra_context['mlist_known'] = self.mlist_known
if self.step > self.main_step: if self.step > self.main_step:
self.extra_context['main_form'] = self.clean_forms[self.main_step] self.extra_context['main_form'] = self.clean_forms[self.main_step]
self.extra_context['requestor_is_approver'] = self.requestor_is_approver 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']} self.initial[self.main_step] = {'mlist_name': form.clean_data['group']}
else: else:
self.initial[self.main_step] = {} self.initial[self.main_step] = {}
self.mlist_known = False
if form.clean_data['mail_type'].endswith('wg'): if form.clean_data['mail_type'].endswith('wg'):
self.initial[self.main_step].update({'domain_name': 'ietf.org'}) self.initial[self.main_step].update({'domain_name': 'ietf.org'})
else: else:

View file

@ -8,7 +8,7 @@
<tr><td> Short description of the email list: </td><td>{{ list.short_desc|escape }}</td></tr> <tr><td> Short description of the email list: </td><td>{{ list.short_desc|escape }}</td></tr>
<tr><td> Long description of the email list: </td><td>{{ list.long_desc|escape }}</td></tr> <tr><td> Long description of the email list: </td><td>{{ list.long_desc|escape }}</td></tr>
<tr><td> Administrator(s): </td><td><pre>{{ list.admins|escape }}</pre></td></tr> <tr><td> Administrator(s): </td><td><pre>{{ list.admins|escape }}</pre></td></tr>
<tr><td> Email address(es) of initial subscriber(s) (optional): </td><td><pre>{{ list.initial|escape }}</pre></td></tr> <tr><td> Email address(es) of initial subscriber(s) (optional): </td><td><pre>{{ list.initial_members|escape }}</pre></td></tr>
<tr><td> Welcome message for initial subscriber(s) (optional): </td><td>{{ list.welcome_message|linebreaksbr }}</td></tr> <tr><td> Welcome message for initial subscriber(s) (optional): </td><td>{{ list.welcome_message|linebreaksbr }}</td></tr>
<tr><td> Welcome message for new subscriber(s) (optional): </td><td>{{ list.welcome_new|linebreaksbr }}</td></tr> <tr><td> Welcome message for new subscriber(s) (optional): </td><td>{{ list.welcome_new|linebreaksbr }}</td></tr>
<tr><td> Required steps for subscription: </td><td>{{ list.get_subscription_display }}</td></tr> <tr><td> Required steps for subscription: </td><td>{{ list.get_subscription_display }}</td></tr>

View file

@ -17,7 +17,7 @@ Administrator(s):
{{ list.admins }} {{ list.admins }}
Email address(es) of the initial subscriber(s) (optional): Email address(es) of the initial subscriber(s) (optional):
{{ list.initial }} {{ list.initial_members }}
Welcome message for initial subscriber(s) (optional): Welcome message for initial subscriber(s) (optional):
{{ list.welcome_message }} {{ list.welcome_message }}

View file

@ -0,0 +1 @@
{% include "mailinglists/list_wizard_MailingListForm.html" %}

View file

@ -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 %}
<tr>
<th>{{ field.label_tag }}:</th>
<td>
{% if field.errors %}
<ul class="errorlist">{% for error in field.errors %}<li>{{ error|escape }}</li>{% endfor %}</ul>
{% 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 %}
</td>
</tr>
{% endif %}
{% endfor %}
{% endblock %}