Skip to content

Commit 89a8834

Browse files
committed
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
1 parent 415e274 commit 89a8834

7 files changed

Lines changed: 39 additions & 7 deletions

File tree

ietf/mailinglists/forms.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,7 @@ def clean_authorized(self):
169169
class ListReqClose(forms.Form):
170170
requestor = forms.CharField(label = "Requestor's full name", widget = forms.TextInput(attrs = {'size': 55}))
171171
requestor_email = forms.EmailField(label = "Requestor's email address", widget = forms.TextInput(attrs = {'size': 55}))
172-
# todo: right widgets for these
173-
mlist_name = forms.CharField(widget = forms.HiddenInput())
172+
mlist_name = forms.CharField(label = 'Mailing List Name') # will turn into just display field by template.
174173
domain_name = forms.CharField(widget = forms.HiddenInput())
175174
reason_to_delete = forms.CharField(label = 'Reason for closing list', widget = forms.Textarea(attrs = {'rows': 4, 'cols': 60}))
176175

ietf/mailinglists/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class MailingList(models.Model):
8080
long_desc = models.TextField('Long description of the email list')
8181
# admins is a VARCHAR but can have multiple lines.
8282
admins = models.TextField('Mailing list administrators (one address per line)', maxlength=250)
83-
initial = models.TextField('Enter email address(es) of initial subscriber(s) (one address per line) (optional)', blank=True)
83+
initial_members = models.TextField('Enter email address(es) of initial subscriber(s) (one address per line) (optional)', blank=True, db_column='initial')
8484
welcome_message = models.TextField('Provide a welcome message for initial subscriber(s)(optional)', blank=True)
8585
welcome_new = models.TextField('Provide a welcome message for new subscriber(s)(optional)', blank=True)
8686
subscription = models.IntegerField('What steps are required for subscription?', choices=SUBSCRIPTION_CHOICES)

ietf/mailinglists/views.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def non_wg_wizard(request):
147147
'mail_type': None,
148148
'mail_cat': None,
149149
'admins': MultiEmailField(label='List Administrator(s)', widget=AdminRequestor(attrs={'cols': 41, 'rows': 4})),
150-
'initial': MultiEmailField(label='Initial list member(s)', widget=forms.Textarea(attrs={'cols': 41, 'rows': 4}), required=False),
150+
'initial_members': MultiEmailField(label='Initial list member(s)', widget=forms.Textarea(attrs={'cols': 41, 'rows': 4}), required=False),
151151
}
152152

153153
list_labels = {
@@ -170,7 +170,7 @@ def non_wg_wizard(request):
170170
'short_desc': { 'size': 55 },
171171
'long_desc': { 'cols': 41, 'rows': 4, 'wrap': 'virtual' },
172172
'admins': { 'cols': 41, 'rows': 4 },
173-
'initial': { 'cols': 41, 'rows': 4 },
173+
'initial_members': { 'cols': 41, 'rows': 4 },
174174
'welcome_message': { 'cols': 41, 'rows': 4 },
175175
'welcome_new': { 'cols': 41, 'rows': 4 },
176176
'archive_remote': { 'cols': 41, 'rows': 4 },
@@ -190,6 +190,7 @@ class ListReqWizard(wizard.Wizard):
190190
clean_forms = []
191191
main_step = 1
192192
requestor_is_approver = False
193+
mlist_known = True
193194
def get_template(self):
194195
templates = []
195196
#if self.step > 0:
@@ -204,6 +205,7 @@ def get_template(self):
204205
return templates
205206
def render_template(self, *args, **kwargs):
206207
#self.extra_context['clean_forms'] = self.clean_forms
208+
self.extra_context['mlist_known'] = self.mlist_known
207209
if self.step > self.main_step:
208210
self.extra_context['main_form'] = self.clean_forms[self.main_step]
209211
self.extra_context['requestor_is_approver'] = self.requestor_is_approver
@@ -234,6 +236,7 @@ def process_step(self, request, form, step):
234236
self.initial[self.main_step] = {'mlist_name': form.clean_data['group']}
235237
else:
236238
self.initial[self.main_step] = {}
239+
self.mlist_known = False
237240
if form.clean_data['mail_type'].endswith('wg'):
238241
self.initial[self.main_step].update({'domain_name': 'ietf.org'})
239242
else:

ietf/templates/mailinglists/list_summary.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<tr><td> Short description of the email list: </td><td>{{ list.short_desc|escape }}</td></tr>
99
<tr><td> Long description of the email list: </td><td>{{ list.long_desc|escape }}</td></tr>
1010
<tr><td> Administrator(s): </td><td><pre>{{ list.admins|escape }}</pre></td></tr>
11-
<tr><td> Email address(es) of initial subscriber(s) (optional): </td><td><pre>{{ list.initial|escape }}</pre></td></tr>
11+
<tr><td> Email address(es) of initial subscriber(s) (optional): </td><td><pre>{{ list.initial_members|escape }}</pre></td></tr>
1212
<tr><td> Welcome message for initial subscriber(s) (optional): </td><td>{{ list.welcome_message|linebreaksbr }}</td></tr>
1313
<tr><td> Welcome message for new subscriber(s) (optional): </td><td>{{ list.welcome_new|linebreaksbr }}</td></tr>
1414
<tr><td> Required steps for subscription: </td><td>{{ list.get_subscription_display }}</td></tr>

ietf/templates/mailinglists/list_summary.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Administrator(s):
1717
{{ list.admins }}
1818

1919
Email address(es) of the initial subscriber(s) (optional):
20-
{{ list.initial }}
20+
{{ list.initial_members }}
2121

2222
Welcome message for initial subscriber(s) (optional):
2323
{{ list.welcome_message }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% include "mailinglists/list_wizard_MailingListForm.html" %}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{% extends "mailinglists/list_wizard_base.html" %}
2+
3+
{% block mlform %}
4+
{% for field in form %}
5+
{% if field.is_hidden %}
6+
{# we assume that the only hidden form is the domain name #}
7+
{# so don't render anything #}
8+
{% else %}
9+
<tr>
10+
<th>{{ field.label_tag }}:</th>
11+
<td>
12+
{% if field.errors %}
13+
<ul class="errorlist">{% for error in field.errors %}<li>{{ error|escape }}</li>{% endfor %}</ul>
14+
{% endif %}
15+
{% ifequal field.name "mlist_name" %}
16+
{% if mlist_known %}{# if we know the mailing list name already #}
17+
{{ form.initial.mlist_name }}@{{ form.initial.domain_name }}{{ field.as_hidden }}
18+
{% else %}
19+
{{ field }}@{{ form.initial.domain_name }}
20+
{% endif %}
21+
{{ form.domain_name.as_hidden }}
22+
{% else %}
23+
{{ field }}
24+
{% endifequal %}
25+
</td>
26+
</tr>
27+
{% endif %}
28+
{% endfor %}
29+
{% endblock %}

0 commit comments

Comments
 (0)