Skip to content

Commit 0f81d3e

Browse files
committed
Retired non-WG mailing list update submission tool
- Legacy-Id: 1825
1 parent b6a2aef commit 0f81d3e

16 files changed

Lines changed: 16 additions & 670 deletions

ietf/mailinglists/forms.py

Lines changed: 0 additions & 103 deletions
This file was deleted.

ietf/mailinglists/models.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@ class NonWgMailingList(models.Model):
4242
msg_to_ad = models.TextField(blank=True)
4343
def __str__(self):
4444
return self.list_name
45-
def save(self, *args, **kwargs):
46-
if self.id is None:
47-
generate = True
48-
while generate:
49-
self.id = ''.join([random.choice('0123456789abcdefghijklmnopqrstuvwxyz') for i in range(35)])
50-
try:
51-
NonWgMailingList.objects.get(pk=self.id)
52-
except NonWgMailingList.DoesNotExist:
53-
generate = False
54-
super(NonWgMailingList, self).save(*args, **kwargs)
5545
def choices():
5646
return [(list.id, list.list_name) for list in NonWgMailingList.objects.all().filter(status__gt=0)]
5747
choices = staticmethod(choices)

ietf/mailinglists/tests.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -30,47 +30,9 @@
3030
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3131
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3232

33-
import unittest
34-
import re
35-
from django.test.client import Client
36-
from ietf.utils.test_utils import RealDatabaseTest
3733
from ietf.utils.test_utils import SimpleUrlTestCase
3834

3935
class MailingListsUrlTestCase(SimpleUrlTestCase):
4036
def testUrls(self):
4137
self.doTestUrls(__file__)
4238

43-
class NonWgWizardAddTest(unittest.TestCase):
44-
def testAddStep1(self):
45-
print "Testing /list/nonwg/update/ add step 1"
46-
c = Client()
47-
response = c.post('/list/nonwg/update/', {'0-add_edit':'add'})
48-
self.assertEquals(response.status_code, 200)
49-
self.assert_('input type="hidden" name="hash_0"' in response.content)
50-
self.assert_("Step 2" in response.content)
51-
self.assert_("List URL:" in response.content)
52-
53-
class NonWgWizardDeleteTest(unittest.TestCase, RealDatabaseTest):
54-
def setUp(self):
55-
self.setUpRealDatabase()
56-
def tearDown(self):
57-
self.tearDownRealDatabase()
58-
59-
def testDeleteStep1(self):
60-
print "Testing /list/nonwg/update/ delete step 1"
61-
62-
# First, get one valid list_id
63-
c = Client()
64-
response = c.get('/list/nonwg/update/')
65-
self.assertEquals(response.status_code, 200)
66-
p = re.compile(r'option value="(.+)">secdir', re.IGNORECASE)
67-
m = p.search(response.content)
68-
self.assert_(m != None)
69-
list_id = m.group(1)
70-
#print "Using list_id "+list_id
71-
72-
# Then attempt deleting it
73-
response = c.post('/list/nonwg/update/', {'0-add_edit':'delete', '0-list_id_delete':list_id})
74-
self.assertEquals(response.status_code, 200)
75-
self.assert_('input type="hidden" name="hash_0"' in response.content)
76-
self.assert_('Message to the Area Director' in response.content)

ietf/mailinglists/testurl.list

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
200 /list/area/
22
200 /list/wg/
33
200 /list/nonwg/
4-
200 /list/nonwg/update/
4+
301 /list/nonwg/update/
55
200 /list/request/

ietf/mailinglists/urls.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# Copyright The IETF Trust 2007, All Rights Reserved
22

33
from django.conf.urls.defaults import patterns
4-
from ietf.idtracker.models import Area
5-
from ietf.mailinglists import views
4+
from ietf.idtracker.models import Area, IETFWG
65
from ietf.mailinglists.models import NonWgMailingList
7-
#from ietf.mailinglists.forms import NonWgStep1
86

97
urlpatterns = patterns('django.views.generic.list_detail',
108
(r'^area/$', 'object_list', { 'queryset': Area.objects.filter(status=1).select_related().order_by('acronym.acronym'), 'template_name': 'mailinglists/areas_list.html' }),
119
(r'^nonwg/$', 'object_list', { 'queryset': NonWgMailingList.objects.filter(status__gt=0) }),
10+
(r'wg/$', 'object_list', { 'queryset': IETFWG.objects.filter(email_archive__startswith='http'), 'template_name': 'mailinglists/wgwebmail_list.html' }),
1211
)
1312
urlpatterns += patterns('',
14-
(r'^nonwg/update/$', views.non_wg_wizard),
13+
(r'^nonwg/update/$', 'django.views.generic.simple.redirect_to', { 'url': 'http://datatracker.ietf.org/list/nonwg/'}),
1514
(r'^request/$', 'django.views.generic.simple.direct_to_template', { 'template': 'mailinglists/instructions.html' }),
16-
(r'^wg/$', views.list_wgwebmail),
1715
)

ietf/mailinglists/views.py

Lines changed: 0 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,2 @@
11
# Copyright The IETF Trust 2007, All Rights Reserved
22

3-
from forms import NonWgStep1, PickApprover, DeletionPickApprover, UrlMultiWidget, Preview
4-
from models import NonWgMailingList
5-
from ietf.idtracker.models import Area, PersonOrOrgInfo, Role, IETFWG
6-
from django import newforms as forms
7-
from django.shortcuts import render_to_response
8-
from django.template import RequestContext
9-
from ietf.contrib import wizard, form_decorator
10-
from ietf.utils.mail import send_mail_subj
11-
12-
def get_approvers_from_area (area_id) :
13-
if not area_id :
14-
return [ad.person_id for ad in Role.objects.filter(role_name__in=("IETF", "IAB", ))]
15-
else :
16-
return [ad.person_id for ad in Area.objects.get(area_acronym=area_id).areadirector_set.all()]
17-
18-
def formchoice(form, field):
19-
if not(form.is_valid()):
20-
return None
21-
d = str(form.clean_data[field])
22-
for k, v in form.fields[field].choices:
23-
if str(k) == d:
24-
return v
25-
# oddly, one of the forms stores the translated value
26-
# in clean_data; the other stores the key. This second
27-
# if wouldn't be needed if both stored the key.
28-
# This whole function wouldn't be needed if both stored
29-
# the value.
30-
if str(v) == d:
31-
return v
32-
return None
33-
34-
nonwg_fields = {
35-
'id': None,
36-
'status': None,
37-
'ds_name': None,
38-
'ds_email': None,
39-
'msg_to_ad': None,
40-
'area': forms.ModelChoiceField(Area.objects.filter(status=1), required=False, empty_label='none'),
41-
}
42-
43-
nonwg_attrs = {
44-
's_name': {'size': 50},
45-
's_email': {'size': 50},
46-
'list_name': {'size': 80},
47-
}
48-
49-
nonwg_widgets = {
50-
'list_url': UrlMultiWidget(choices=(('http://', 'http://'), ('https://', 'https://'), ('mailto:', 'mailto:')), attrs = {'size': 50}),
51-
'admin': forms.Textarea(attrs = {'rows': 3, 'cols': 50}),
52-
'purpose': forms.Textarea(attrs = {'rows': 4, 'cols': 70}),
53-
'subscribe_url': UrlMultiWidget(choices=(('n/a', 'Not Applicable'), ('http://', 'http://'), ('https://', 'https://')), attrs = {'size': 50}),
54-
'subscribe_other': forms.Textarea(attrs = {'rows': 3, 'cols': 50}),
55-
}
56-
57-
nonwg_callback = form_decorator(fields=nonwg_fields, widgets=nonwg_widgets, attrs=nonwg_attrs)
58-
59-
def gen_approval(approvers, parent):
60-
class BoundApproval(parent):
61-
_approvers = approvers
62-
def __init__(self, *args, **kwargs):
63-
super(BoundApproval, self).__init__(self._approvers, *args, **kwargs)
64-
return BoundApproval
65-
66-
class NonWgWizard(wizard.Wizard):
67-
clean_forms = []
68-
def get_template(self):
69-
templates = []
70-
if self.step > 0:
71-
action = {'add': 'addedit', 'edit': 'addedit', 'delete': 'delete'}[self.clean_forms[0].clean_data['add_edit']]
72-
templates.append("mailinglists/nwg_wizard_%s_step%d.html" % (action, self.step))
73-
templates.append("mailinglists/nwg_wizard_%s.html" % (action))
74-
templates.append("mailinglists/nwg_wizard_step%d.html" % (self.step))
75-
templates.append("mailinglists/nwg_wizard.html")
76-
return templates
77-
def render_template(self, *args, **kwargs):
78-
self.extra_context['clean_forms'] = self.clean_forms
79-
if self.step == 3:
80-
form0 = self.clean_forms[0]
81-
add_edit = form0.clean_data['add_edit']
82-
if add_edit == 'add' or add_edit == 'edit':
83-
# Can't get the choice mapping directly from the form
84-
self.extra_context['area'] = formchoice(self.clean_forms[1], 'area')
85-
self.extra_context['approver'] = formchoice(self.clean_forms[2], 'approver')
86-
if self.step == 2:
87-
form0 = self.clean_forms[0]
88-
add_edit = form0.clean_data['add_edit']
89-
if add_edit == 'delete':
90-
self.extra_context['list_q'] = NonWgMailingList.objects.get(pk=self.clean_forms[0].clean_data['list_id_delete'])
91-
self.extra_context['approver'] = formchoice(self.clean_forms[1], 'approver')
92-
return super(NonWgWizard, self).render_template(*args, **kwargs)
93-
# def failed_hash(self, request, step):
94-
# raise NotImplementedError("step %d hash failed" % step)
95-
def process_step(self, request, form, step):
96-
97-
form.full_clean()
98-
99-
if step == 0:
100-
self.clean_forms = [ form ]
101-
if form.clean_data['add_edit'] == 'add':
102-
self.form_list.append(forms.form_for_model(NonWgMailingList, formfield_callback=nonwg_callback))
103-
elif form.clean_data['add_edit'] == 'edit':
104-
list = NonWgMailingList.objects.get(pk=form.clean_data['list_id'])
105-
f = forms.form_for_instance(list, formfield_callback=nonwg_callback)
106-
# form_decorator's method of copying the initial data
107-
# from form_for_instance() to the ModelChoiceField doesn't
108-
# work, so we set it explicitly here.
109-
f.base_fields['area'].initial = list.area_id
110-
self.form_list.append(f)
111-
elif form.clean_data['add_edit'] == 'delete':
112-
list = NonWgMailingList.objects.get(pk=form.clean_data['list_id_delete'])
113-
self.form_list.append(gen_approval(get_approvers_from_area(list.area is None or list.area_id), DeletionPickApprover))
114-
self.form_list.append(Preview)
115-
else:
116-
self.clean_forms.append(form)
117-
if step == 1:
118-
form0 = self.clean_forms[0]
119-
add_edit = form0.clean_data['add_edit']
120-
if add_edit == 'add' or add_edit == 'edit':
121-
self.form_list.append(gen_approval(get_approvers_from_area(form.clean_data['area']), PickApprover))
122-
self.form_list.append(Preview)
123-
super(NonWgWizard, self).process_step(request, form, step)
124-
def done(self, request, form_list):
125-
add_edit = self.clean_forms[0].clean_data['add_edit']
126-
list = None
127-
old = None
128-
if add_edit == 'add' or add_edit == 'edit':
129-
template = 'mailinglists/nwg_addedit_email.txt'
130-
approver = self.clean_forms[2].clean_data['approver']
131-
list = NonWgMailingList(**self.clean_forms[1].clean_data)
132-
list.__dict__.update(self.clean_forms[2].clean_data)
133-
list.id = None # create a new row no matter what
134-
list.status = 0
135-
if add_edit == 'edit':
136-
old = NonWgMailingList.objects.get(pk=self.clean_forms[0].clean_data['list_id'])
137-
else:
138-
template = 'mailinglists/nwg_delete_email.txt'
139-
approver = self.clean_forms[1].clean_data['approver']
140-
list = NonWgMailingList.objects.get(pk=self.clean_forms[0].clean_data['list_id_delete'])
141-
list.__dict__.update(self.clean_forms[1].clean_data)
142-
list.status = 1
143-
list.save()
144-
approver_email = PersonOrOrgInfo.objects.get(pk=approver).email()
145-
approver_name = PersonOrOrgInfo.objects.get(pk=approver)
146-
send_mail_subj(request, [ approver_email ], None, 'mailinglists/nwg_wizard_subject.txt', 'mailinglists/nwg_wizard_done_email.txt', {'add_edit': add_edit, 'old': old, 'list': list, 'forms': self.clean_forms})
147-
return render_to_response( 'mailinglists/nwg_wizard_done.html', {'approver': approver_name, 'add_edit': add_edit, 'old': old, 'list': list, 'forms': self.clean_forms}, context_instance=RequestContext(request) )
148-
149-
def non_wg_wizard(request):
150-
wiz = NonWgWizard([ NonWgStep1 ])
151-
return wiz(request)
152-
153-
def list_wgwebmail(request):
154-
wgs = IETFWG.objects.filter(email_archive__startswith='http')
155-
return render_to_response('mailinglists/wgwebmail_list.html', {'object_list': wgs})

0 commit comments

Comments
 (0)