Implement [most of] the approval side of mailing list requests.

Have to check the templates for deletion.
 - Legacy-Id: 209
This commit is contained in:
Bill Fenner 2007-06-01 18:34:57 +00:00
parent 3ff684ff06
commit 4e426dec4c
15 changed files with 320 additions and 16 deletions

View file

@ -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]) raise forms.ValidationError, "The following email addresses seem to be invalid: %s" % ", ".join(["'" + addr + "'" for addr in bad])
return value 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}))

View file

@ -23,17 +23,17 @@ class ImportedMailingList(models.Model):
class MailingList(models.Model): class MailingList(models.Model):
SUBSCRIPTION_CHOICES = ( SUBSCRIPTION_CHOICES = (
('1', 'Confirm'), (1, 'Confirm'),
('2', 'Approval'), (2, 'Approval'),
('3', 'Confirm+Approval'), (3, 'Confirm+Approval'),
) )
MAILTYPE_CHOICES = ( MAILTYPE_CHOICES = (
('1', 'Create new WG email list at ietf.org'), (1, 'Create new WG email list at ietf.org'),
('2', 'Move existing WG email list to ietf.org'), (2, 'Move existing WG email list to ietf.org'),
('3', 'Move existing non-WG email list to selected domain'), (3, 'Move existing non-WG email list to selected domain'),
('4', 'Create new non-WG email list at selected domain'), (4, 'Create new non-WG email list at selected domain'),
('5', 'Close existing WG email list at ietf.org'), (5, 'Close existing WG email list at ietf.org'),
('6', 'Close existing non-WG email list at selected domain'), (6, 'Close existing non-WG email list at selected domain'),
) )
# I don't understand the reasoning behind 2 vs 3. # I don't understand the reasoning behind 2 vs 3.
# this is set in the javascript and not editable, # 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 # The existing database doesn't help much since many
# mail_cat values are NULL. # mail_cat values are NULL.
MAILCAT_CHOICES = ( MAILCAT_CHOICES = (
('1', 'WG Mailing List'), (1, 'WG Mailing List'),
('2', 'Non-WG Mailing List'), (2, 'Non-WG Mailing List'),
('3', 'Close Non-WG Mailing List'), (3, 'Close Non-WG Mailing List'),
) )
mailing_list_id = models.CharField('Unique ID', primary_key=True, maxlength=25, editable=False) mailing_list_id = models.CharField('Unique ID', primary_key=True, maxlength=25, editable=False)
request_date = models.DateField(default=datetime.now, editable=False) request_date = models.DateField(default=datetime.now, editable=False)

View file

@ -11,4 +11,5 @@ urlpatterns = patterns('django.views.generic.list_detail',
urlpatterns += patterns('', urlpatterns += patterns('',
(r'^nonwg_lists/submit/$', views.non_wg_wizard), (r'^nonwg_lists/submit/$', views.non_wg_wizard),
(r'^request/$', views.list_req_wizard), (r'^request/$', views.list_req_wizard),
(r'^approve/(?P<object_id>[^/]+)/$', views.list_approve),
) )

View file

@ -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 models import NonWgMailingList, MailingList
from ietf.idtracker.models import Area, PersonOrOrgInfo from ietf.idtracker.models import Area, PersonOrOrgInfo
from django import newforms as forms 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.template import RequestContext
from django.db.models import Q
from ietf.contrib import wizard, form_decorator from ietf.contrib import wizard, form_decorator
from ietf.utils.mail import send_mail_subj from ietf.utils.mail import send_mail_subj
from datetime import datetime
def formchoice(form, field): def formchoice(form, field):
if not(form.is_valid()): if not(form.is_valid()):
@ -152,8 +154,7 @@ list_labels = {
'post_who': 'Who is allowed to post to this list?', 'post_who': 'Who is allowed to post to this list?',
} }
# can I do a multiwidget for the mailing list admins? # would like something to display @domain after the email list name?
# and something to display @domain after the email list name?
list_widgets = { list_widgets = {
'subscription': forms.Select(choices=MailingList.SUBSCRIPTION_CHOICES), 'subscription': forms.Select(choices=MailingList.SUBSCRIPTION_CHOICES),
'post_who': forms.Select(choices=(('1', 'List members only'), ('0', 'Open'))), '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_%s.html" % (c))
templates.append("mailinglists/list_wizard_step%d.html" % (self.step)) templates.append("mailinglists/list_wizard_step%d.html" % (self.step))
templates.append("mailinglists/list_wizard.html") templates.append("mailinglists/list_wizard.html")
print templates
return templates return templates
# want to implement parse_params to get domain for list # want to implement parse_params to get domain for list
def process_step(self, request, form, step): def process_step(self, request, form, step):
@ -208,3 +210,35 @@ class ListReqWizard(wizard.Wizard):
def list_req_wizard(request): def list_req_wizard(request):
wiz = ListReqWizard([ ListReqStep1 ]) wiz = ListReqWizard([ ListReqStep1 ])
return wiz(request) 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) )

View file

@ -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 %}

View file

@ -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 %}
<table bgcolor="#88AED2" cellspacing="1" border="0" width="594">
<tr><td>
<table bgcolor="f3f8fd" cellpadding="3" cellspacing="0" border="0">
<tr>
<td><img src="/images/ietf_topleft.gif" border="0"><img src="/images/blue_title.
gif" border="0"></td>
</tr>
<tr><td>
<img src="/images/mail_title.gif" border="0">
</td></tr>
<tr><td valign="top">
<img src="/images/t_un.gif" border="0">
</td></tr>
<tr><td>
{% block innercontent %}{% endblock %}
</td></tr>
</table>
</table>
{% endblock %}

View file

@ -0,0 +1,6 @@
{% extends "mailinglists/list_approval_base.html" %}
{% block innercontent %}
<font color="#022d66"> Your note approving the request to {% filter escape %}{% include "mailinglists/list_type_message2.txt" %}{% endfilter %} has been sent to the Secretariat and the requestor.<br>
It will take up to two business days for the Secretariat to {% include "mailinglists/list_action.txt" %} email list.</font><br><br>
{% endblock %}

View file

@ -0,0 +1,5 @@
{% extends "mailinglists/list_approval_base.html" %}
{% block innercontent %}
<font color="#022d66"> 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).<br>
{% endblock %}

View file

@ -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 %}

View file

@ -0,0 +1 @@
{% include "mailinglists/list_type_message.txt" %} has been {{ action }}

View file

@ -0,0 +1,16 @@
<tr><td colspan="2">Request to {{ list.get_mail_type_display }}</td></tr>
<tr><td> Requestor: </td><td>{{ list.requestor|escape }}</td></tr>
<tr><td> Requestor's email address: </td><td>{{ list.requestor_email|urlize }}</td></tr>
<tr><td> Email list name: </td><td>{{ list.mlist_name }}@{{ list.domain_name }}</td></tr>
{# probably here is where add/move vs. delete comes in? #}
<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> 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> 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> Required steps for subscription: </td><td>{{ list.get_subscription_display }}</td></tr>
<tr><td> Messages to this list can be posted by:</td><td>{{ list.post_who|yesno:"List members only,Open" }}</td></tr>
<tr><td> Administrator approval required for posts: </td><td>{{ list.post_admin|yesno:"YES,NO" }}</td></tr>
<tr><td> Private Archive: </td><td>{{ list.archive_private|yesno:"YES,NO" }}</td></tr>
<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>

View file

@ -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 %}

View file

@ -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 %}
<form action="." method="POST">
<table bgcolor="#88AED2" cellspacing="1" border="0" width="594">
<tr><td>
<table bgcolor="f3f8fd" cellpadding="3" cellspacing="0" border="0">
<tr>
<td colspan="2"><img src="/images/ietf_topleft.gif" border="0"><img src="/images/blue_title.gif" border="0"></td>
</tr>
<tr><td colspan="2">
<img src="/images/mail_title.gif" border="0">
</td></tr>
<tr><td colspan="2">
<img src="/images/t_un.gif" border="0">
</td></tr>
{% include "mailinglists/list_summary.html" %}
{{ form }}
<tr><td colspan="2" align="center"><br><br><input type="submit" name="approved" value="Approve Request and Notify Secretariat"><input type="submit" name="disapprove" value="Deny Request and Notify Requestor"></td></tr>
</table>
</table>
</form>
{% endif %}
{% endblock %}

View file

@ -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 %}

View file

@ -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 %}