A little progress on the mailing list request tool.
- Legacy-Id: 177
This commit is contained in:
parent
2f56324baa
commit
e38f1dc967
|
@ -1,6 +1,6 @@
|
||||||
from django import newforms as forms
|
from django import newforms as forms
|
||||||
from models import NonWgMailingList, ImportedMailingList
|
from models import NonWgMailingList, ImportedMailingList
|
||||||
from ietf.idtracker.models import PersonOrOrgInfo, GroupIETF
|
from ietf.idtracker.models import PersonOrOrgInfo, GroupIETF, Acronym
|
||||||
|
|
||||||
class NonWgStep1(forms.Form):
|
class NonWgStep1(forms.Form):
|
||||||
add_edit = forms.ChoiceField(choices=(
|
add_edit = forms.ChoiceField(choices=(
|
||||||
|
@ -56,9 +56,20 @@ class ListReqStep1(forms.Form):
|
||||||
self.fields['list_to_close'].choices = [('', '-- Select List To Close')] + ImportedMailingList.choices(dname)
|
self.fields['list_to_close'].choices = [('', '-- Select List To Close')] + ImportedMailingList.choices(dname)
|
||||||
self.fields['domain_name'].initial = dname
|
self.fields['domain_name'].initial = dname
|
||||||
def clean_group(self):
|
def clean_group(self):
|
||||||
if self.clean_data.get('mail_type', '').endswith('wg'):
|
group = self.clean_data['group']
|
||||||
|
action = self.clean_data.get('mail_type', '')
|
||||||
|
if action.endswith('wg'):
|
||||||
if not self.clean_data.get('group'):
|
if not self.clean_data.get('group'):
|
||||||
raise forms.ValidationError, 'Please pick a working group'
|
raise forms.ValidationError, 'Please pick a working group'
|
||||||
|
group_name = Acronym.objects.get(pk=group).acronym
|
||||||
|
#group_list_exists = ImportedMailingList.objects.filter(acronym=group_name).count()
|
||||||
|
group_list_exists = ImportedMailingList.objects.filter(group_acronym=group).count()
|
||||||
|
if action.startswith('close'):
|
||||||
|
if group_list_exists == 0:
|
||||||
|
raise forms.ValidationError, 'The %s mailing list does not exist.' % group_name
|
||||||
|
else:
|
||||||
|
if group_list_exists:
|
||||||
|
raise forms.ValidationError, 'The %s mailing list already exists.' % group_name
|
||||||
return self.clean_data['group']
|
return self.clean_data['group']
|
||||||
def clean_list_to_close(self):
|
def clean_list_to_close(self):
|
||||||
if self.clean_data.get('mail_type', '') == 'closenon':
|
if self.clean_data.get('mail_type', '') == 'closenon':
|
||||||
|
@ -122,4 +133,16 @@ class DeletionPickApprover(PickApprover):
|
||||||
|
|
||||||
# A form with no required fields, to allow a preview action
|
# A form with no required fields, to allow a preview action
|
||||||
class Preview(forms.Form):
|
class Preview(forms.Form):
|
||||||
preview = forms.BooleanField(required=False)
|
#preview = forms.BooleanField(required=False)
|
||||||
|
pass
|
||||||
|
|
||||||
|
class ListReqAuthorized(forms.Form):
|
||||||
|
authorized = forms.BooleanField()
|
||||||
|
def clean_authorized(self):
|
||||||
|
if not(self.clean_data.get('authorized', 0)):
|
||||||
|
raise forms.ValidationError, 'You must assert that you are authorized to perform this action.'
|
||||||
|
return self.clean_data['authorized']
|
||||||
|
|
||||||
|
# subclass pickapprover here too?
|
||||||
|
class ListReqClose(forms.Form):
|
||||||
|
pass
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from ietf.idtracker.models import Acronym, Areas, PersonOrOrgInfo
|
from ietf.idtracker.models import Acronym, Area, PersonOrOrgInfo
|
||||||
import random
|
import random
|
||||||
|
|
||||||
class ImportedMailingList(models.Model):
|
class ImportedMailingList(models.Model):
|
||||||
|
@ -44,7 +44,7 @@ class MailingList(models.Model):
|
||||||
('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)
|
mailing_list_id = models.CharField('Unique ID', primary_key=True, maxlength=25, editable=False)
|
||||||
request_date = models.DateField()
|
request_date = models.DateField()
|
||||||
mlist_name = models.CharField('Mailing list name', maxlength=250)
|
mlist_name = models.CharField('Mailing list name', maxlength=250)
|
||||||
short_desc = models.CharField(maxlength=250)
|
short_desc = models.CharField(maxlength=250)
|
||||||
|
@ -68,7 +68,7 @@ class MailingList(models.Model):
|
||||||
approved = models.BooleanField()
|
approved = models.BooleanField()
|
||||||
approved_date = models.DateField(null=True, blank=True)
|
approved_date = models.DateField(null=True, blank=True)
|
||||||
reason_to_delete = models.TextField(blank=True)
|
reason_to_delete = models.TextField(blank=True)
|
||||||
domain_name = models.CharField(blank=True, maxlength=10)
|
domain_name = models.CharField(maxlength=10)
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.mlist_name
|
return self.mlist_name
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
|
@ -94,7 +94,7 @@ class NonWgMailingList(models.Model):
|
||||||
list_url = models.CharField("List URL", maxlength=255)
|
list_url = models.CharField("List URL", maxlength=255)
|
||||||
admin = models.TextField("Administrator(s)' Email Address(es)", blank=True)
|
admin = models.TextField("Administrator(s)' Email Address(es)", blank=True)
|
||||||
purpose = models.TextField(blank=True)
|
purpose = models.TextField(blank=True)
|
||||||
area = models.ForeignKey(Areas, db_column='area_acronym_id')
|
area = models.ForeignKey(Area, db_column='area_acronym_id')
|
||||||
subscribe_url = models.CharField("Subscribe URL", blank=True, maxlength=255)
|
subscribe_url = models.CharField("Subscribe URL", blank=True, maxlength=255)
|
||||||
subscribe_other = models.TextField("Subscribe Other", blank=True)
|
subscribe_other = models.TextField("Subscribe Other", blank=True)
|
||||||
# Can be 0, 1, -1, or what looks like a person_or_org_tag, positive or neg.
|
# Can be 0, 1, -1, or what looks like a person_or_org_tag, positive or neg.
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
from django.conf.urls.defaults import *
|
from django.conf.urls.defaults import *
|
||||||
from ietf.idtracker.models import Areas
|
from ietf.idtracker.models import Area
|
||||||
from ietf.mailinglists import views
|
from ietf.mailinglists import views
|
||||||
from ietf.mailinglists.models import NonWgMailingList
|
from ietf.mailinglists.models import NonWgMailingList
|
||||||
from ietf.mailinglists.forms import NonWgStep1
|
from ietf.mailinglists.forms import NonWgStep1
|
||||||
|
|
||||||
urlpatterns = patterns('django.views.generic.list_detail',
|
urlpatterns = patterns('django.views.generic.list_detail',
|
||||||
(r'^area_lists/$', 'object_list', { 'queryset': Areas.objects.filter(status=1).select_related().order_by('acronym.acronym'), 'template_name': 'mailinglists/areas_list.html' }),
|
(r'^area_lists/$', 'object_list', { 'queryset': Area.objects.filter(status=1).select_related().order_by('acronym.acronym'), 'template_name': 'mailinglists/areas_list.html' }),
|
||||||
(r'^nonwg_lists/$', 'object_list', { 'queryset': NonWgMailingList.objects.filter(status__gt=0) }),
|
(r'^nonwg_lists/$', 'object_list', { 'queryset': NonWgMailingList.objects.filter(status__gt=0) }),
|
||||||
)
|
)
|
||||||
urlpatterns += patterns('',
|
urlpatterns += patterns('',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from forms import NonWgStep1, ListReqStep1, PickApprover, DeletionPickApprover, UrlMultiWidget, Preview
|
from forms import NonWgStep1, ListReqStep1, PickApprover, DeletionPickApprover, UrlMultiWidget, Preview, ListReqAuthorized, ListReqClose
|
||||||
from models import NonWgMailingList
|
from models import NonWgMailingList, MailingList
|
||||||
from ietf.idtracker.models import Areas, 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 render_to_response
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
|
@ -46,7 +46,7 @@ nonwg_widgets = {
|
||||||
}
|
}
|
||||||
|
|
||||||
nonwg_querysets = {
|
nonwg_querysets = {
|
||||||
'area': Areas.objects.filter(status=1)
|
'area': Area.objects.filter(status=1)
|
||||||
}
|
}
|
||||||
|
|
||||||
nonwg_callback = form_decorator(fields=nonwg_fields, widgets=nonwg_widgets, attrs=nonwg_attrs, querysets=nonwg_querysets)
|
nonwg_callback = form_decorator(fields=nonwg_fields, widgets=nonwg_widgets, attrs=nonwg_attrs, querysets=nonwg_querysets)
|
||||||
|
@ -102,7 +102,7 @@ class NonWgWizard(wizard.Wizard):
|
||||||
form0 = self.clean_forms[0]
|
form0 = self.clean_forms[0]
|
||||||
add_edit = form0.clean_data['add_edit']
|
add_edit = form0.clean_data['add_edit']
|
||||||
if add_edit == 'add' or add_edit == 'edit':
|
if add_edit == 'add' or add_edit == 'edit':
|
||||||
self.form_list.append(gen_approval([ad.person_id for ad in Areas.objects.get(area_acronym=form.clean_data['area']).areadirectors_set.all()], PickApprover))
|
self.form_list.append(gen_approval([ad.person_id for ad in Area.objects.get(area_acronym=form.clean_data['area']).areadirectors_set.all()], PickApprover))
|
||||||
self.form_list.append(Preview)
|
self.form_list.append(Preview)
|
||||||
super(NonWgWizard, self).process_step(request, form, step)
|
super(NonWgWizard, self).process_step(request, form, step)
|
||||||
def done(self, request, form_list):
|
def done(self, request, form_list):
|
||||||
|
@ -133,18 +133,52 @@ def non_wg_wizard(request):
|
||||||
wiz = NonWgWizard([ NonWgStep1 ])
|
wiz = NonWgWizard([ NonWgStep1 ])
|
||||||
return wiz(request)
|
return wiz(request)
|
||||||
|
|
||||||
|
list_fields = {
|
||||||
|
'mailing_list_id': None,
|
||||||
|
'request_date': None,
|
||||||
|
'auth_person': None,
|
||||||
|
'approved': None,
|
||||||
|
'approved_date': None,
|
||||||
|
'reason_to_delete': None,
|
||||||
|
}
|
||||||
|
|
||||||
|
list_widgets = {
|
||||||
|
}
|
||||||
|
|
||||||
|
list_attrs = {
|
||||||
|
}
|
||||||
|
|
||||||
|
list_callback = form_decorator(fields=list_fields, widgets=list_widgets, attrs=list_attrs)
|
||||||
|
|
||||||
class ListReqWizard(wizard.Wizard):
|
class ListReqWizard(wizard.Wizard):
|
||||||
def get_template(self):
|
def get_template(self):
|
||||||
return "mailinglists/nwg_wizard.html"
|
templates = []
|
||||||
|
#if self.step > 0:
|
||||||
|
# action = {'add': 'addedit', 'edit': 'addedit', 'delete': 'delete'}[self.clean_forms[0].clean_data['add_edit']]
|
||||||
|
# templates.append("mailinglists/nwg_wizard_%s_step%d.html" % (action, self.step))
|
||||||
|
# templates.append("mailinglists/nwg_wizard_%s.html" % (action))
|
||||||
|
c = self.form_list[self.step].__name__
|
||||||
|
templates.append("mailinglists/list_wizard_%s.html" % (c))
|
||||||
|
templates.append("mailinglists/list_wizard_step%d.html" % (self.step))
|
||||||
|
templates.append("mailinglists/list_wizard.html")
|
||||||
|
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):
|
||||||
form.full_clean()
|
form.full_clean()
|
||||||
|
if step == 0:
|
||||||
|
self.clean_forms = [ form ]
|
||||||
|
else:
|
||||||
|
self.clean_forms.append(form)
|
||||||
|
if step == 0:
|
||||||
|
if form.clean_data['mail_type'].endswith('non') and form.clean_data['domain_name'] != 'ietf.org':
|
||||||
|
self.form_list.append(ListReqAuthorized)
|
||||||
|
if form.clean_data['mail_type'].startswith('close'):
|
||||||
|
self.form_list.append(ListReqClose)
|
||||||
|
else:
|
||||||
|
self.form_list.append(forms.form_for_model(MailingList))
|
||||||
|
#XXX not quite
|
||||||
super(ListReqWizard, self).process_step(request, form, step)
|
super(ListReqWizard, self).process_step(request, form, step)
|
||||||
|
|
||||||
def list_req_wizard(request):
|
def list_req_wizard(request):
|
||||||
wiz = ListReqWizard([ ListReqStep1 ])
|
wiz = ListReqWizard([ ListReqStep1 ])
|
||||||
return wiz(request)
|
return wiz(request)
|
||||||
|
|
||||||
def non_wg_submit(request):
|
|
||||||
form = NonWgStep1()
|
|
||||||
return render_to_response('mailinglists/step1.html', { 'form': form })
|
|
||||||
|
|
Loading…
Reference in a new issue