From ac853962e245cafb99e8a5f9dca909ee1a89b3ef Mon Sep 17 00:00:00 2001 From: Bill Fenner Date: Fri, 1 Jun 2007 19:13:21 +0000 Subject: [PATCH] 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 --- ietf/mailinglists/views.py | 10 +++++--- ietf/templates/mailinglists/list_email.txt | 23 ++++++------------- ietf/templates/mailinglists/list_summary.html | 7 ++++-- ietf/templates/mailinglists/list_summary.txt | 15 ++++++------ 4 files changed, 26 insertions(+), 29 deletions(-) diff --git a/ietf/mailinglists/views.py b/ietf/mailinglists/views.py index 95d287c7a..04f3bd11a 100644 --- a/ietf/mailinglists/views.py +++ b/ietf/mailinglists/views.py @@ -213,6 +213,10 @@ def list_req_wizard(request): def list_approve(request, object_id): list = get_object_or_404(MailingList, mailing_list_id=object_id) + if list.mail_type == 5 or list.mail_type == 6: + req = 'delete' + else: + req = 'add' action = 'toapprove' email_to = None if request.method == 'POST': @@ -222,7 +226,7 @@ def list_approve(request, object_id): list.add_comment = request.POST['add_comment'] list.save() if list.mail_type == 6: # deletion of non-wg list - 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))): + 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))): nonwg.status = -1 nonwg.save() email_to = 'ietf-action@ietf.org' @@ -237,8 +241,8 @@ def list_approve(request, object_id): email_cc = None action = 'denied' if email_to is not None: - 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) + 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) # fall through form = ApprovalComment() - return render_to_response('mailinglists/list_%s.html' % action, {'list': list, 'form': form}, + return render_to_response('mailinglists/list_%s.html' % action, {'list': list, 'form': form, 'req': req}, context_instance=RequestContext(request) ) diff --git a/ietf/templates/mailinglists/list_email.txt b/ietf/templates/mailinglists/list_email.txt index 09851e94e..9e94549a0 100644 --- a/ietf/templates/mailinglists/list_email.txt +++ b/ietf/templates/mailinglists/list_email.txt @@ -2,15 +2,12 @@ Dear list requestor, {% filter wordwrap:"72" %} Your request to {% spaceless %}{% include "mailinglists/list_type_message2.txt" %}{% endspaceless %} -has been {{ action }} by {{ list.auth_person }}, {{ list.auth_person.email }}. +has been {{ action }} by {{ list.auth_person }}, {{ list.auth_person.email.1 }}. {% endfilter %} +{% ifequal action "approved" %} {% spaceless %} -{# wish to not repeat myself here #} -{% ifequal list.mail_type 5 %} -The mailing list will be closed within two business days. -{% else %} -{% ifequal list.mail_type 6 %} +{% ifequal req "delete" %} The mailing list will be closed within two business days. {% else %} 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. Please remember to forward this changed password to any other list admins. {% endifequal %} -{% endifequal %} {% endspaceless %} - -Requestor: {{ list.requestor }} - -Requestor's email address: {{ list.requestor_email }} - -Email list name: {{ list.mlist_name }}@{{ list.domain_name }} +{% endifequal %} {% include "mailinglists/list_summary.txt" %} -{% if list.add_comments %} -Comments by {{ list.auth_person }}, {{ list.auth_person.email }}: -{{ list.add_comments }} +{% if list.add_comment %} +Comments by {{ list.auth_person }}, {{ list.auth_person.email.1 }}: +{{ list.add_comment }} {% endif %} diff --git a/ietf/templates/mailinglists/list_summary.html b/ietf/templates/mailinglists/list_summary.html index 57e695655..eacff1391 100644 --- a/ietf/templates/mailinglists/list_summary.html +++ b/ietf/templates/mailinglists/list_summary.html @@ -1,8 +1,10 @@ -Request to {{ list.get_mail_type_display }} +Request to {% filter escape %}{% include "mailinglists/list_type_message2.txt" %}{% endfilter %} Requestor: {{ list.requestor|escape }} Requestor's email address: {{ list.requestor_email|urlize }} Email list name: {{ list.mlist_name }}@{{ list.domain_name }} -{# probably here is where add/move vs. delete comes in? #} +{% ifequal req "delete" %} + Reason for closing list: {{ list.reason_to_delete|escape|linebreaksbr }} +{% else %} 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 }}
@@ -14,3 +16,4 @@ Administrator approval required for posts: {{ list.post_admin|yesno:"YES,NO" }} Private Archive: {{ list.archive_private|yesno:"YES,NO" }} Specific information about how to access and move the exiting archive from a remote location (optional): {{ list.archive_remote }} +{% endifequal %} diff --git a/ietf/templates/mailinglists/list_summary.txt b/ietf/templates/mailinglists/list_summary.txt index 872e26db4..48358c490 100644 --- a/ietf/templates/mailinglists/list_summary.txt +++ b/ietf/templates/mailinglists/list_summary.txt @@ -1,9 +1,10 @@ -{% spaceless %} -{# wish to not repeat myself here #} -{% ifequal list.mail_type 5 %} -Reason for closing list: {{ list.reason_to_delete }} -{% else %} -{% ifequal list.mail_type 6 %} +Requestor: {{ list.requestor }} + +Requestor's email address: {{ list.requestor_email }} + +Email list name: {{ list.mlist_name }}@{{ list.domain_name }} + +{% ifequal req "delete" %} Reason for closing list: {{ list.reason_to_delete }} {% else %} 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 {{ list.archive_remote }} {% endifequal %} -{% endifequal %} -{% endspaceless %}