Skip to content

Commit 4e426de

Browse files
committed
Implement [most of] the approval side of mailing list requests.
Have to check the templates for deletion. - Legacy-Id: 209
1 parent 3ff684f commit 4e426de

15 files changed

Lines changed: 320 additions & 16 deletions

ietf/mailinglists/forms.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,5 @@ def clean(self, value):
194194
raise forms.ValidationError, "The following email addresses seem to be invalid: %s" % ", ".join(["'" + addr + "'" for addr in bad])
195195
return value
196196

197+
class ApprovalComment(forms.Form):
198+
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}))

ietf/mailinglists/models.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,27 @@ class Admin:
2323

2424
class MailingList(models.Model):
2525
SUBSCRIPTION_CHOICES = (
26-
('1', 'Confirm'),
27-
('2', 'Approval'),
28-
('3', 'Confirm+Approval'),
26+
(1, 'Confirm'),
27+
(2, 'Approval'),
28+
(3, 'Confirm+Approval'),
2929
)
3030
MAILTYPE_CHOICES = (
31-
('1', 'Create new WG email list at ietf.org'),
32-
('2', 'Move existing WG email list to ietf.org'),
33-
('3', 'Move existing non-WG email list to selected domain'),
34-
('4', 'Create new non-WG email list at selected domain'),
35-
('5', 'Close existing WG email list at ietf.org'),
36-
('6', 'Close existing non-WG email list at selected domain'),
31+
(1, 'Create new WG email list at ietf.org'),
32+
(2, 'Move existing WG email list to ietf.org'),
33+
(3, 'Move existing non-WG email list to selected domain'),
34+
(4, 'Create new non-WG email list at selected domain'),
35+
(5, 'Close existing WG email list at ietf.org'),
36+
(6, 'Close existing non-WG email list at selected domain'),
3737
)
3838
# I don't understand the reasoning behind 2 vs 3.
3939
# this is set in the javascript and not editable,
4040
# so I think there's a 1:1 mapping from mail_type -> mail_cat.
4141
# The existing database doesn't help much since many
4242
# mail_cat values are NULL.
4343
MAILCAT_CHOICES = (
44-
('1', 'WG Mailing List'),
45-
('2', 'Non-WG Mailing List'),
46-
('3', 'Close Non-WG Mailing List'),
44+
(1, 'WG Mailing List'),
45+
(2, 'Non-WG Mailing List'),
46+
(3, 'Close Non-WG Mailing List'),
4747
)
4848
mailing_list_id = models.CharField('Unique ID', primary_key=True, maxlength=25, editable=False)
4949
request_date = models.DateField(default=datetime.now, editable=False)

ietf/mailinglists/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
urlpatterns += patterns('',
1212
(r'^nonwg_lists/submit/$', views.non_wg_wizard),
1313
(r'^request/$', views.list_req_wizard),
14+
(r'^approve/(?P<object_id>[^/]+)/$', views.list_approve),
1415
)

ietf/mailinglists/views.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
from forms import NonWgStep1, ListReqStep1, PickApprover, DeletionPickApprover, UrlMultiWidget, Preview, ListReqAuthorized, ListReqClose, MultiEmailField, AdminRequestor
1+
from forms import NonWgStep1, ListReqStep1, PickApprover, DeletionPickApprover, UrlMultiWidget, Preview, ListReqAuthorized, ListReqClose, MultiEmailField, AdminRequestor, ApprovalComment
22
from models import NonWgMailingList, MailingList
33
from ietf.idtracker.models import Area, PersonOrOrgInfo
44
from django import newforms as forms
5-
from django.shortcuts import render_to_response
5+
from django.shortcuts import get_object_or_404, render_to_response
66
from django.template import RequestContext
7+
from django.db.models import Q
78
from ietf.contrib import wizard, form_decorator
89
from ietf.utils.mail import send_mail_subj
10+
from datetime import datetime
911

1012
def formchoice(form, field):
1113
if not(form.is_valid()):
@@ -152,8 +154,7 @@ def non_wg_wizard(request):
152154
'post_who': 'Who is allowed to post to this list?',
153155
}
154156

155-
# can I do a multiwidget for the mailing list admins?
156-
# and something to display @domain after the email list name?
157+
# would like something to display @domain after the email list name?
157158
list_widgets = {
158159
'subscription': forms.Select(choices=MailingList.SUBSCRIPTION_CHOICES),
159160
'post_who': forms.Select(choices=(('1', 'List members only'), ('0', 'Open'))),
@@ -187,6 +188,7 @@ def get_template(self):
187188
templates.append("mailinglists/list_wizard_%s.html" % (c))
188189
templates.append("mailinglists/list_wizard_step%d.html" % (self.step))
189190
templates.append("mailinglists/list_wizard.html")
191+
print templates
190192
return templates
191193
# want to implement parse_params to get domain for list
192194
def process_step(self, request, form, step):
@@ -208,3 +210,35 @@ def process_step(self, request, form, step):
208210
def list_req_wizard(request):
209211
wiz = ListReqWizard([ ListReqStep1 ])
210212
return wiz(request)
213+
214+
def list_approve(request, object_id):
215+
list = get_object_or_404(MailingList, mailing_list_id=object_id)
216+
action = 'toapprove'
217+
email_to = None
218+
if request.method == 'POST':
219+
if request.POST.has_key('approved'):
220+
list.approved=1
221+
list.approved_date = datetime.now()
222+
list.add_comment = request.POST['add_comment']
223+
list.save()
224+
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))):
226+
nonwg.status = -1
227+
nonwg.save()
228+
email_to = 'ietf-action@ietf.org'
229+
email_cc = [(list.requestor, list.requestor_email)]
230+
action = 'approved'
231+
elif request.POST.has_key('disapprove'):
232+
list.approved = -1
233+
list.approved_date = datetime.now()
234+
list.add_comment = request.POST['add_comment']
235+
list.save()
236+
email_to = [(list.requestor, list.requestor_email)]
237+
email_cc = None
238+
action = 'denied'
239+
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)
241+
# fall through
242+
form = ApprovalComment()
243+
return render_to_response('mailinglists/list_%s.html' % action, {'list': list, 'form': form},
244+
context_instance=RequestContext(request) )
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{% ifequal list.mail_type 1 %}
2+
create this new
3+
{% else %}
4+
{% ifequal list.mail_type 2 %}
5+
move the
6+
{% else %}
7+
{% ifequal list.mail_type 3 %}
8+
move the
9+
{% else %}
10+
{% ifequal list.mail_type 4 %}
11+
create this new
12+
{% else %}
13+
{% ifequal list.mail_type 5 %}
14+
close the
15+
{% else %}
16+
{% ifequal list.mail_type 6 %}
17+
close the
18+
{% else %}
19+
** programming error **
20+
{% endifequal %}
21+
{% endifequal %}
22+
{% endifequal %}
23+
{% endifequal %}
24+
{% endifequal %}
25+
{% endifequal %}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{% extends "base.html" %}
2+
3+
{% block title %}Mailing list request approval note.{% endblock %}
4+
5+
{% block css %}
6+
table {
7+
margin:0;
8+
padding:0;
9+
font-family: Verdana, Arial, sans-serif;
10+
font-size: 13px;
11+
color: #022D66;
12+
font-style: normal;
13+
}
14+
th {
15+
font-weight: normal;
16+
text-align: left;
17+
}
18+
{% endblock %}
19+
20+
{% block content %}
21+
<table bgcolor="#88AED2" cellspacing="1" border="0" width="594">
22+
<tr><td>
23+
<table bgcolor="f3f8fd" cellpadding="3" cellspacing="0" border="0">
24+
<tr>
25+
<td><img src="/images/ietf_topleft.gif" border="0"><img src="/images/blue_title.
26+
gif" border="0"></td>
27+
</tr>
28+
<tr><td>
29+
<img src="/images/mail_title.gif" border="0">
30+
</td></tr>
31+
<tr><td valign="top">
32+
<img src="/images/t_un.gif" border="0">
33+
</td></tr>
34+
<tr><td>
35+
{% block innercontent %}{% endblock %}
36+
</td></tr>
37+
</table>
38+
</table>
39+
{% endblock %}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% extends "mailinglists/list_approval_base.html" %}
2+
3+
{% block innercontent %}
4+
<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>
5+
It will take up to two business days for the Secretariat to {% include "mailinglists/list_action.txt" %} email list.</font><br><br>
6+
{% endblock %}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% extends "mailinglists/list_approval_base.html" %}
2+
3+
{% block innercontent %}
4+
<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>
5+
{% endblock %}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Dear list requestor,
2+
3+
{% filter wordwrap:"72" %}
4+
Your request to {% spaceless %}{% include "mailinglists/list_type_message2.txt" %}{% endspaceless %}
5+
has been {{ action }} by {{ list.auth_person }}, {{ list.auth_person.email }}.
6+
{% endfilter %}
7+
8+
{% 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 %}
14+
The mailing list will be closed within two business days.
15+
{% else %}
16+
Your list will be created and the archives will be tested.
17+
You will receive a welcome E-mail containing your administrator's
18+
password within two business days.
19+
For security reasons we suggest that you change this password.
20+
Please remember to forward this changed password to any other list
21+
admins.
22+
{% endifequal %}
23+
{% endifequal %}
24+
{% 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 }}
31+
32+
{% include "mailinglists/list_summary.txt" %}
33+
34+
{% if list.add_comments %}
35+
Comments by {{ list.auth_person }}, {{ list.auth_person.email }}:
36+
{{ list.add_comments }}
37+
{% endif %}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% include "mailinglists/list_type_message.txt" %} has been {{ action }}

0 commit comments

Comments
 (0)