diff --git a/ietf/mailinglists/forms.py b/ietf/mailinglists/forms.py index 89933561b..7daf24f4d 100644 --- a/ietf/mailinglists/forms.py +++ b/ietf/mailinglists/forms.py @@ -194,3 +194,5 @@ class MultiEmailField(forms.CharField): raise forms.ValidationError, "The following email addresses seem to be invalid: %s" % ", ".join(["'" + addr + "'" for addr in bad]) return value +class ApprovalComment(forms.Form): + add_comment = forms.CharField(label="Approver's comments to the requestor (will be emailed to the requestor)", widget=forms.Textarea(attrs={'cols':41, 'rows': 4})) diff --git a/ietf/mailinglists/models.py b/ietf/mailinglists/models.py index f48054389..bd67b2459 100644 --- a/ietf/mailinglists/models.py +++ b/ietf/mailinglists/models.py @@ -23,17 +23,17 @@ class ImportedMailingList(models.Model): class MailingList(models.Model): SUBSCRIPTION_CHOICES = ( - ('1', 'Confirm'), - ('2', 'Approval'), - ('3', 'Confirm+Approval'), + (1, 'Confirm'), + (2, 'Approval'), + (3, 'Confirm+Approval'), ) MAILTYPE_CHOICES = ( - ('1', 'Create new WG email list at ietf.org'), - ('2', 'Move existing WG email list to ietf.org'), - ('3', 'Move existing non-WG email list to selected domain'), - ('4', 'Create new non-WG email list at selected domain'), - ('5', 'Close existing WG email list at ietf.org'), - ('6', 'Close existing non-WG email list at selected domain'), + (1, 'Create new WG email list at ietf.org'), + (2, 'Move existing WG email list to ietf.org'), + (3, 'Move existing non-WG email list to selected domain'), + (4, 'Create new non-WG email list at selected domain'), + (5, 'Close existing WG email list at ietf.org'), + (6, 'Close existing non-WG email list at selected domain'), ) # I don't understand the reasoning behind 2 vs 3. # this is set in the javascript and not editable, @@ -41,9 +41,9 @@ class MailingList(models.Model): # The existing database doesn't help much since many # mail_cat values are NULL. MAILCAT_CHOICES = ( - ('1', 'WG Mailing List'), - ('2', 'Non-WG Mailing List'), - ('3', 'Close Non-WG Mailing List'), + (1, 'WG Mailing List'), + (2, 'Non-WG Mailing List'), + (3, 'Close Non-WG Mailing List'), ) mailing_list_id = models.CharField('Unique ID', primary_key=True, maxlength=25, editable=False) request_date = models.DateField(default=datetime.now, editable=False) diff --git a/ietf/mailinglists/urls.py b/ietf/mailinglists/urls.py index cc8dc5833..3f566c62d 100644 --- a/ietf/mailinglists/urls.py +++ b/ietf/mailinglists/urls.py @@ -11,4 +11,5 @@ urlpatterns = patterns('django.views.generic.list_detail', urlpatterns += patterns('', (r'^nonwg_lists/submit/$', views.non_wg_wizard), (r'^request/$', views.list_req_wizard), + (r'^approve/(?P[^/]+)/$', views.list_approve), ) diff --git a/ietf/mailinglists/views.py b/ietf/mailinglists/views.py index cda302520..95d287c7a 100644 --- a/ietf/mailinglists/views.py +++ b/ietf/mailinglists/views.py @@ -1,11 +1,13 @@ -from forms import NonWgStep1, ListReqStep1, PickApprover, DeletionPickApprover, UrlMultiWidget, Preview, ListReqAuthorized, ListReqClose, MultiEmailField, AdminRequestor +from forms import NonWgStep1, ListReqStep1, PickApprover, DeletionPickApprover, UrlMultiWidget, Preview, ListReqAuthorized, ListReqClose, MultiEmailField, AdminRequestor, ApprovalComment from models import NonWgMailingList, MailingList from ietf.idtracker.models import Area, PersonOrOrgInfo from django import newforms as forms -from django.shortcuts import render_to_response +from django.shortcuts import get_object_or_404, render_to_response from django.template import RequestContext +from django.db.models import Q from ietf.contrib import wizard, form_decorator from ietf.utils.mail import send_mail_subj +from datetime import datetime def formchoice(form, field): if not(form.is_valid()): @@ -152,8 +154,7 @@ list_labels = { 'post_who': 'Who is allowed to post to this list?', } -# can I do a multiwidget for the mailing list admins? -# and something to display @domain after the email list name? +# would like something to display @domain after the email list name? list_widgets = { 'subscription': forms.Select(choices=MailingList.SUBSCRIPTION_CHOICES), 'post_who': forms.Select(choices=(('1', 'List members only'), ('0', 'Open'))), @@ -187,6 +188,7 @@ class ListReqWizard(wizard.Wizard): templates.append("mailinglists/list_wizard_%s.html" % (c)) templates.append("mailinglists/list_wizard_step%d.html" % (self.step)) templates.append("mailinglists/list_wizard.html") + print templates return templates # want to implement parse_params to get domain for list def process_step(self, request, form, step): @@ -208,3 +210,35 @@ class ListReqWizard(wizard.Wizard): def list_req_wizard(request): wiz = ListReqWizard([ ListReqStep1 ]) return wiz(request) + +def list_approve(request, object_id): + list = get_object_or_404(MailingList, mailing_list_id=object_id) + action = 'toapprove' + email_to = None + if request.method == 'POST': + if request.POST.has_key('approved'): + list.approved=1 + list.approved_date = datetime.now() + 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))): + nonwg.status = -1 + nonwg.save() + email_to = 'ietf-action@ietf.org' + email_cc = [(list.requestor, list.requestor_email)] + action = 'approved' + elif request.POST.has_key('disapprove'): + list.approved = -1 + list.approved_date = datetime.now() + list.add_comment = request.POST['add_comment'] + list.save() + email_to = [(list.requestor, list.requestor_email)] + 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) + # fall through + form = ApprovalComment() + return render_to_response('mailinglists/list_%s.html' % action, {'list': list, 'form': form}, + context_instance=RequestContext(request) ) diff --git a/ietf/templates/mailinglists/list_action.txt b/ietf/templates/mailinglists/list_action.txt new file mode 100644 index 000000000..11ea58d60 --- /dev/null +++ b/ietf/templates/mailinglists/list_action.txt @@ -0,0 +1,25 @@ +{% ifequal list.mail_type 1 %} +create this new +{% else %} +{% ifequal list.mail_type 2 %} +move the +{% else %} +{% ifequal list.mail_type 3 %} +move the +{% else %} +{% ifequal list.mail_type 4 %} +create this new +{% else %} +{% ifequal list.mail_type 5 %} +close the +{% else %} +{% ifequal list.mail_type 6 %} +close the +{% else %} +** programming error ** +{% endifequal %} +{% endifequal %} +{% endifequal %} +{% endifequal %} +{% endifequal %} +{% endifequal %} diff --git a/ietf/templates/mailinglists/list_approval_base.html b/ietf/templates/mailinglists/list_approval_base.html new file mode 100644 index 000000000..04e2e5339 --- /dev/null +++ b/ietf/templates/mailinglists/list_approval_base.html @@ -0,0 +1,39 @@ +{% extends "base.html" %} + +{% block title %}Mailing list request approval note.{% endblock %} + +{% block css %} +table { + margin:0; + padding:0; + font-family: Verdana, Arial, sans-serif; + font-size: 13px; + color: #022D66; + font-style: normal; + } +th { + font-weight: normal; + text-align: left; +} +{% endblock %} + +{% block content %} + +
+ + + + + + + +
+ +
+ +
+{% block innercontent %}{% endblock %} +
+
+{% endblock %} diff --git a/ietf/templates/mailinglists/list_approved.html b/ietf/templates/mailinglists/list_approved.html new file mode 100644 index 000000000..baea9c61e --- /dev/null +++ b/ietf/templates/mailinglists/list_approved.html @@ -0,0 +1,6 @@ +{% extends "mailinglists/list_approval_base.html" %} + +{% block innercontent %} + Your note approving the request to {% filter escape %}{% include "mailinglists/list_type_message2.txt" %}{% endfilter %} has been sent to the Secretariat and the requestor.
+It will take up to two business days for the Secretariat to {% include "mailinglists/list_action.txt" %} email list.


+{% endblock %} diff --git a/ietf/templates/mailinglists/list_denied.html b/ietf/templates/mailinglists/list_denied.html new file mode 100644 index 000000000..041337a78 --- /dev/null +++ b/ietf/templates/mailinglists/list_denied.html @@ -0,0 +1,5 @@ +{% extends "mailinglists/list_approval_base.html" %} + +{% block innercontent %} + Your note denying the request to {% filter escape %}{% include "mailinglists/list_type_message2.txt" %}{% endfilter %} has been sent to the requestor with your comments (if any).
+{% endblock %} diff --git a/ietf/templates/mailinglists/list_email.txt b/ietf/templates/mailinglists/list_email.txt new file mode 100644 index 000000000..09851e94e --- /dev/null +++ b/ietf/templates/mailinglists/list_email.txt @@ -0,0 +1,37 @@ +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 }}. +{% endfilter %} + +{% 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 %} +The mailing list will be closed within two business days. +{% else %} +Your list will be created and the archives will be tested. +You will receive a welcome E-mail containing your administrator's +password within two business days. +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 }} + +{% include "mailinglists/list_summary.txt" %} + +{% if list.add_comments %} +Comments by {{ list.auth_person }}, {{ list.auth_person.email }}: +{{ list.add_comments }} +{% endif %} diff --git a/ietf/templates/mailinglists/list_subject.txt b/ietf/templates/mailinglists/list_subject.txt new file mode 100644 index 000000000..5203f5476 --- /dev/null +++ b/ietf/templates/mailinglists/list_subject.txt @@ -0,0 +1 @@ +{% include "mailinglists/list_type_message.txt" %} has been {{ action }} diff --git a/ietf/templates/mailinglists/list_summary.html b/ietf/templates/mailinglists/list_summary.html new file mode 100644 index 000000000..57e695655 --- /dev/null +++ b/ietf/templates/mailinglists/list_summary.html @@ -0,0 +1,16 @@ +Request to {{ list.get_mail_type_display }} + 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? #} + 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 }}
+ 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 }} + Messages to this list can be posted by:{{ list.post_who|yesno:"List members only,Open" }} + 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 }} diff --git a/ietf/templates/mailinglists/list_summary.txt b/ietf/templates/mailinglists/list_summary.txt new file mode 100644 index 000000000..872e26db4 --- /dev/null +++ b/ietf/templates/mailinglists/list_summary.txt @@ -0,0 +1,37 @@ +{% 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 %} +Reason for closing list: {{ list.reason_to_delete }} +{% else %} +Short description of the email list: {{ list.short_desc }} + +Long description of the email list: {{ list.long_desc }} + +Administrator(s): {{ list.admins }}{# formatting? #} + +Email address(es) of the initial subscriber(s) (optional): +{{ list.initial }} + +Welcome message for initial subscriber(s) (optional): +{{ list.welcome_message }} + +Welcome message for new subscriber(s) (optional): +{{ list.welcome_new }} + +Required steps for subscription: {{ list.get_subscription_display }} + +Messages to this list can be posted by: {{ list.post_who|yesno:"List members only,Open" }} + +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 existing archive from a remote location (optional): +{{ list.archive_remote }} + +{% endifequal %} +{% endifequal %} +{% endspaceless %} diff --git a/ietf/templates/mailinglists/list_toapprove.html b/ietf/templates/mailinglists/list_toapprove.html new file mode 100644 index 000000000..57dfdad8a --- /dev/null +++ b/ietf/templates/mailinglists/list_toapprove.html @@ -0,0 +1,51 @@ +{% extends "base.html" %} + +{% block title %}Confirmation of Request to {{ list.get_mail_type_display }}{% endblock %} + +{% block css %} +table { + margin:0; + padding:0; + font-family: Verdana, Arial, sans-serif; + font-size: 13px; + color: #022D66; + font-style: normal; + } +th { + font-weight: normal; + text-align: left; +} +{% endblock %} + +{% block content %} +{% if list.approved %} + This mailing list request has already been + {% ifequal list.approved 1 %} + approved and sent to the IETF Secretariat. + {% else %} + denied and the requestor has been notified. + {% endifequal %} +{% else %} +
+ +
+ + + + + + +{% include "mailinglists/list_summary.html" %} +{{ form }} + +
+ +
+ +


+
+
+ + +{% endif %} +{% endblock %} diff --git a/ietf/templates/mailinglists/list_type_message.txt b/ietf/templates/mailinglists/list_type_message.txt new file mode 100644 index 000000000..612e1715a --- /dev/null +++ b/ietf/templates/mailinglists/list_type_message.txt @@ -0,0 +1,25 @@ +{% ifequal list.mail_type 1 %} +Creation of the WG email list <{{ list.mlist_name }}@ietf.org> +{% else %} +{% ifequal list.mail_type 2 %} +Movement of the WG email list for {{ list.mlist_name }} to ietf.org +{% else %} +{% ifequal list.mail_type 3 %} +Movement of the non-WG email list {{ list.mlist_name }} to {{ list.domain_name }} +{% else %} +{% ifequal list.mail_type 4 %} +Creation of the non-WG email list <{{ list.mlist_name }}@{{ list.domain_name }}> +{% else %} +{% ifequal list.mail_type 5 %} +Closing the WG email list <{{ list.mlist_name }}@ietf.org> +{% else %} +{% ifequal list.mail_type 6 %} +Closing the non-WG email list <{{ list.mlist_name }}@{{ list.domain_name }}> +{% else %} +** programming error ** +{% endifequal %} +{% endifequal %} +{% endifequal %} +{% endifequal %} +{% endifequal %} +{% endifequal %} diff --git a/ietf/templates/mailinglists/list_type_message2.txt b/ietf/templates/mailinglists/list_type_message2.txt new file mode 100644 index 000000000..cc24c6548 --- /dev/null +++ b/ietf/templates/mailinglists/list_type_message2.txt @@ -0,0 +1,25 @@ +{% ifequal list.mail_type 1 %} +create the WG email list <{{ list.mlist_name }}@ietf.org> +{% else %} +{% ifequal list.mail_type 2 %} +move the WG email list for {{ list.mlist_name }} to ietf.org +{% else %} +{% ifequal list.mail_type 3 %} +move the non-WG email list {{ list.mlist_name }} to {{ list.domain_name }} +{% else %} +{% ifequal list.mail_type 4 %} +create the non-WG email list <{{ list.mlist_name }}@{{ list.domain_name }}> +{% else %} +{% ifequal list.mail_type 5 %} +close the WG email list <{{ list.mlist_name }}@ietf.org> +{% else %} +{% ifequal list.mail_type 6 %} +close the non-WG email list <{{ list.mlist_name }}@{{ list.domain_name }}> +{% else %} +** programming error ** +{% endifequal %} +{% endifequal %} +{% endifequal %} +{% endifequal %} +{% endifequal %} +{% endifequal %}