@@ -16,7 +16,7 @@ def add_edit_fields(self):
1616 return field .as_widget (field .field .widget )
1717 def __init__ (self , * args , ** kwargs ):
1818 super (NonWgStep1 , self ).__init__ (* args , ** kwargs )
19- choices = [('' , '-- Select an item from the list below ' )] + NonWgMailingList .choices ()
19+ choices = [('' , '--Select a list here ' )] + NonWgMailingList .choices ()
2020 self .fields ['list_id' ].choices = choices
2121 self .fields ['list_id_delete' ].choices = choices
2222 def clean_list_id (self ):
@@ -45,25 +45,21 @@ class ListReqStep1(forms.Form):
4545 ('closenon' , 'Close existing non-WG email list at selected domain above' ),
4646 ), widget = forms .RadioSelect ())
4747 group = forms .ModelChoiceField (queryset = IETFWG .objects .all ().filter (status = IETFWG .ACTIVE ).select_related (depth = 1 ).order_by ('acronym.acronym' ), required = False , empty_label = "-- Select Working Group" )
48- domain_name = forms .ChoiceField (choices = DOMAIN_CHOICES , required = False , widget = forms .Select (attrs = {'onChange' : 'set_domain(this)' }))
48+ domain_name = forms .ChoiceField (choices = DOMAIN_CHOICES , required = False , widget = forms .Select (attrs = {'onChange' : 'set_domain(this)' }), initial = 'ietf.org' )
4949 list_to_close = forms .ModelChoiceField (queryset = ImportedMailingList .objects .all (), required = False , empty_label = "-- Select List To Close" )
5050 def mail_type_fields (self ):
5151 field = self ['mail_type' ]
5252 # RadioSelect() doesn't pass its attributes through to the <input>
5353 # elements, so in order to get the javascript onClick we add it here.
5454 return [re .sub (r'input ' ,'input onClick="activate_widgets()" ' ,str (i )) for i in field .as_widget (field .field .widget )]
5555 def __init__ (self , * args , ** kwargs ):
56- initial = kwargs .get ('initial' , None )
57- # could pass initial = None, so can't use a trick on the
58- # above get.
59- if initial :
60- dname = initial .get ('domain_name' , 'ietf.org' )
61- else :
62- dname = 'ietf.org'
6356 super (ListReqStep1 , self ).__init__ (* args , ** kwargs )
64- self .fields ['list_to_close' ].queryset = ImportedMailingList .choices (dname )
57+ # Base the queryset for list_to_close on the initial value
58+ # for the domain_name field.
59+ self .fields ['list_to_close' ].queryset = ImportedMailingList .choices (self .initial .get ('domain_name' , 'ietf.org' ))
60+ # This is necessary after changing a ModelChoiceField's
61+ # queryset.
6562 self .fields ['list_to_close' ].widget .choices = self .fields ['list_to_close' ].choices
66- self .fields ['domain_name' ].initial = dname
6763 def clean_group (self ):
6864 group = self .clean_data ['group' ]
6965 action = self .clean_data .get ('mail_type' , '' )
0 commit comments