Skip to content

Commit ac85396

Browse files
committed
Reduce repetition in the templates by moving "add/delete" logic to
view. Fix up logic in templates, mailing list closing emails look correct (both approval and denial, with and without messages from the approver). - Legacy-Id: 210
1 parent 4e426de commit ac85396

4 files changed

Lines changed: 26 additions & 29 deletions

File tree

ietf/mailinglists/views.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ def list_req_wizard(request):
213213

214214
def list_approve(request, object_id):
215215
list = get_object_or_404(MailingList, mailing_list_id=object_id)
216+
if list.mail_type == 5 or list.mail_type == 6:
217+
req = 'delete'
218+
else:
219+
req = 'add'
216220
action = 'toapprove'
217221
email_to = None
218222
if request.method == 'POST':
@@ -222,7 +226,7 @@ def list_approve(request, object_id):
222226
list.add_comment = request.POST['add_comment']
223227
list.save()
224228
if list.mail_type == 6: # deletion of non-wg list
225-
for nonwg in NonWgMailingList.objects.filter(Q(list_url__iendswith=list.list_name) | Q(list_url__iendswith='%s@%s' % (list.list_name, list.list_domain))):
229+
for nonwg in NonWgMailingList.objects.filter(Q(list_url__iendswith=list.mlist_name) | Q(list_url__iendswith='%s@%s' % (list.mlist_name, list.domain_name))):
226230
nonwg.status = -1
227231
nonwg.save()
228232
email_to = 'ietf-action@ietf.org'
@@ -237,8 +241,8 @@ def list_approve(request, object_id):
237241
email_cc = None
238242
action = 'denied'
239243
if email_to is not None:
240-
send_mail_subj(request, email_to, ('Mailing List Request Tool', 'ietf-secretariat-reply@ietf.org'), 'mailinglists/list_subject.txt', 'mailinglists/list_email.txt', {'list': list, 'action': action}, email_cc)
244+
send_mail_subj(request, email_to, ('Mailing List Request Tool', 'ietf-secretariat-reply@ietf.org'), 'mailinglists/list_subject.txt', 'mailinglists/list_email.txt', {'list': list, 'action': action, 'req': req}, email_cc)
241245
# fall through
242246
form = ApprovalComment()
243-
return render_to_response('mailinglists/list_%s.html' % action, {'list': list, 'form': form},
247+
return render_to_response('mailinglists/list_%s.html' % action, {'list': list, 'form': form, 'req': req},
244248
context_instance=RequestContext(request) )

ietf/templates/mailinglists/list_email.txt

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@ Dear list requestor,
22

33
{% filter wordwrap:"72" %}
44
Your request to {% spaceless %}{% include "mailinglists/list_type_message2.txt" %}{% endspaceless %}
5-
has been {{ action }} by {{ list.auth_person }}, {{ list.auth_person.email }}.
5+
has been {{ action }} by {{ list.auth_person }}, {{ list.auth_person.email.1 }}.
66
{% endfilter %}
77

8+
{% ifequal action "approved" %}
89
{% spaceless %}
9-
{# wish to not repeat myself here #}
10-
{% ifequal list.mail_type 5 %}
11-
The mailing list will be closed within two business days.
12-
{% else %}
13-
{% ifequal list.mail_type 6 %}
10+
{% ifequal req "delete" %}
1411
The mailing list will be closed within two business days.
1512
{% else %}
1613
Your list will be created and the archives will be tested.
@@ -20,18 +17,12 @@ For security reasons we suggest that you change this password.
2017
Please remember to forward this changed password to any other list
2118
admins.
2219
{% endifequal %}
23-
{% endifequal %}
2420
{% endspaceless %}
25-
26-
Requestor: {{ list.requestor }}
27-
28-
Requestor's email address: {{ list.requestor_email }}
29-
30-
Email list name: {{ list.mlist_name }}@{{ list.domain_name }}
21+
{% endifequal %}
3122

3223
{% include "mailinglists/list_summary.txt" %}
3324

34-
{% if list.add_comments %}
35-
Comments by {{ list.auth_person }}, {{ list.auth_person.email }}:
36-
{{ list.add_comments }}
25+
{% if list.add_comment %}
26+
Comments by {{ list.auth_person }}, {{ list.auth_person.email.1 }}:
27+
{{ list.add_comment }}
3728
{% endif %}

ietf/templates/mailinglists/list_summary.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
<tr><td colspan="2">Request to {{ list.get_mail_type_display }}</td></tr>
1+
<tr><td colspan="2">Request to {% filter escape %}{% include "mailinglists/list_type_message2.txt" %}{% endfilter %}</td></tr>
22
<tr><td> Requestor: </td><td>{{ list.requestor|escape }}</td></tr>
33
<tr><td> Requestor's email address: </td><td>{{ list.requestor_email|urlize }}</td></tr>
44
<tr><td> Email list name: </td><td>{{ list.mlist_name }}@{{ list.domain_name }}</td></tr>
5-
{# probably here is where add/move vs. delete comes in? #}
5+
{% ifequal req "delete" %}
6+
<tr><td> Reason for closing list: </td><td>{{ list.reason_to_delete|escape|linebreaksbr }}</td></tr>
7+
{% else %}
68
<tr><td> Short description of the email list: </td><td>{{ list.short_desc|escape }}</td></tr>
79
<tr><td> Long description of the email list: </td><td>{{ list.long_desc|escape }}</td></tr>
810
<tr><td> Administrator(s): </td><td><pre>{{ list.admins|escape }}</pre></td></tr>
@@ -14,3 +16,4 @@
1416
<tr><td> Administrator approval required for posts: </td><td>{{ list.post_admin|yesno:"YES,NO" }}</td></tr>
1517
<tr><td> Private Archive: </td><td>{{ list.archive_private|yesno:"YES,NO" }}</td></tr>
1618
<tr><td> Specific information about how to access and move the exiting archive from a remote location (optional): </td><td>{{ list.archive_remote }}</td></tr>
19+
{% endifequal %}

ietf/templates/mailinglists/list_summary.txt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
{% spaceless %}
2-
{# wish to not repeat myself here #}
3-
{% ifequal list.mail_type 5 %}
4-
Reason for closing list: {{ list.reason_to_delete }}
5-
{% else %}
6-
{% ifequal list.mail_type 6 %}
1+
Requestor: {{ list.requestor }}
2+
3+
Requestor's email address: {{ list.requestor_email }}
4+
5+
Email list name: {{ list.mlist_name }}@{{ list.domain_name }}
6+
7+
{% ifequal req "delete" %}
78
Reason for closing list: {{ list.reason_to_delete }}
89
{% else %}
910
Short description of the email list: {{ list.short_desc }}
@@ -33,5 +34,3 @@ Specific information about how to access and move the existing archive from a re
3334
{{ list.archive_remote }}
3435

3536
{% endifequal %}
36-
{% endifequal %}
37-
{% endspaceless %}

0 commit comments

Comments
 (0)