diff --git a/ietf/mailinglists/forms.py b/ietf/mailinglists/forms.py index 0919e9dd4..3a526c16a 100644 --- a/ietf/mailinglists/forms.py +++ b/ietf/mailinglists/forms.py @@ -1,6 +1,7 @@ from django import newforms as forms from models import NonWgMailingList, ImportedMailingList from ietf.idtracker.models import PersonOrOrgInfo, IETFWG, Acronym +import re class NonWgStep1(forms.Form): add_edit = forms.ChoiceField(choices=( @@ -42,28 +43,27 @@ class ListReqStep1(forms.Form): ('newnon', 'Create new non-WG email list at selected domain above'), ('movenon', 'Move existing non-WG email list to selected domain above'), ('closenon', 'Close existing non-WG email list at selected domain above'), - ), widget=forms.RadioSelect) + ), widget=forms.RadioSelect()) #group = forms.ChoiceField(required=False) group = forms.ModelChoiceField(queryset=IETFWG.objects.all().select_related().order_by('acronym.acronym'), required=False, empty_label="-- Select Working Group") - domain_name = forms.ChoiceField(choices=DOMAIN_CHOICES, required=False) + domain_name = forms.ChoiceField(choices=DOMAIN_CHOICES, required=False, widget = forms.Select(attrs={'onChange': 'set_domain(this)'})) list_to_close = forms.ModelChoiceField(queryset=ImportedMailingList.objects.all(), required=False, empty_label="-- Select List To Close") def mail_type_fields(self): field = self['mail_type'] - return field.as_widget(field.field.widget) + # RadioSelect() doesn't pass its attributes through to the + # elements, so in order to get the javascript onClick we add it here. + return [re.sub(r'input ','input onClick="activate_widgets()" ',str(i)) for i in field.as_widget(field.field.widget)] def __init__(self, *args, **kwargs): - dname = 'ietf.org' - if args and args[0]: - dn = 'domain_name' - if kwargs.has_key('prefix'): - dn = kwargs['prefix'] + '-' + dn - dname = args[0][dn] - dname = kwargs.get('dname', dname) + initial = kwargs.get('initial', None) + # could pass initial = None, so can't use a trick on the + # above get. + if initial: + dname = initial.get('domain_name', 'ietf.org') + else: + dname = 'ietf.org' super(ListReqStep1, self).__init__(*args, **kwargs) - #self.fields['group'].choices = [('', '-- Select Working Group')] + IETFWG.choices() - #self.fields['list_to_close'].choices = [('', '-- Select List To Close')] + ImportedMailingList.choices(dname) - #XXX This doesn't work yet. Maybe switch back to choices. self.fields['list_to_close'].queryset = ImportedMailingList.choices(dname) - print "dname %s list_to_close values: %s" % (dname, self.fields['list_to_close'].queryset) + self.fields['list_to_close'].widget.choices = self.fields['list_to_close'].choices self.fields['domain_name'].initial = dname def clean_group(self): group = self.clean_data['group'] @@ -181,7 +181,7 @@ class AdminRequestor(forms.MultiWidget): # check the checkbox, but for now let's try this. return ['', '', value] def __init__(self, attrs=None): - widgets = (forms.CheckboxInput(), forms.TextInput(attrs={'size': 55, 'disabled': True}), forms.Textarea(attrs=attrs)) + widgets = (forms.CheckboxInput(attrs={'onClick': 'checkthis()'}), forms.TextInput(attrs={'size': 55, 'disabled': True}), forms.Textarea(attrs=attrs)) super(AdminRequestor, self).__init__(widgets, attrs) def format_output(self, rendered_widgets): return u'
\n'.join(["" % rendered_widgets[0]] + rendered_widgets[1:]) diff --git a/ietf/mailinglists/views.py b/ietf/mailinglists/views.py index 1048b3a62..635b20d0c 100644 --- a/ietf/mailinglists/views.py +++ b/ietf/mailinglists/views.py @@ -192,19 +192,14 @@ class ListReqWizard(wizard.Wizard): requestor_is_approver = False mlist_known = True def get_template(self): + '''Start with form class, then step number, then the base form.''' 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") - print templates return templates def render_template(self, *args, **kwargs): - #self.extra_context['clean_forms'] = self.clean_forms self.extra_context['mlist_known'] = self.mlist_known if self.step > self.main_step: self.extra_context['main_form'] = self.clean_forms[self.main_step] @@ -212,7 +207,11 @@ class ListReqWizard(wizard.Wizard): if self.step == self.main_step + 1: self.extra_context['list'] = self.getlist() return super(ListReqWizard, self).render_template(*args, **kwargs) - # want to implement parse_params to get domain for list + def parse_params(self, request, *args, **kwargs): + super(ListReqWizard, self).parse_params(request, *args, **kwargs) + if self.step == 0: + # allow javascript "redirects" to set initial values + self.initial[0] = request.GET def process_step(self, request, form, step): form.full_clean() if step == 0: diff --git a/ietf/templates/mailinglists/list_wizard_step0.html b/ietf/templates/mailinglists/list_wizard_step0.html new file mode 100644 index 000000000..7a8fa8b3d --- /dev/null +++ b/ietf/templates/mailinglists/list_wizard_step0.html @@ -0,0 +1,84 @@ +{% extends "mailinglists/list_wizard_base.html" %} + +{% block head %} + +{% endblock %} + +{% block body_attributes %}onLoad="activate_widgets()"{% endblock %} + +{% block mlform %} +

WG email list +                       +{{ form.group }} +{% if form.group.errors %} + +{% endif %} +

+ +{% if form.mail_type.errors %} + +{% endif %} +{{ form.mail_type_fields.0 }}
+{{ form.mail_type_fields.1 }}
+{{ form.mail_type_fields.2 }}
+ + +

Non-WG email list

+Select Domain Name: {{ form.domain_name }}
+{{ form.mail_type_fields.3 }}
+{{ form.mail_type_fields.4 }}
+{{ form.mail_type_fields.5 }}
+{{ form.list_to_close }} +{% if form.list_to_close.errors %} + +{% endif %} +
+ + +Note: Only members of the IAB (or their designees) and active +participants in the IRTF may create or close a mailing list at iab.org and irtf. +org, respectively, or move an existing list to one of these domains." +

+ + +{% endblock %}