@@ -382,30 +382,21 @@ class EditInfoFormREDESIGN(forms.Form):
382382 intended_std_level = forms .ModelChoiceField (IntendedStdLevelName .objects .all (), empty_label = None , required = True )
383383 status_date = forms .DateField (required = False , help_text = "Format is YYYY-MM-DD" )
384384 via_rfc_editor = forms .BooleanField (required = False , label = "Via IRTF or RFC Editor" )
385- ad = forms .ModelChoiceField (Person .objects .filter (email__role__name__in = ( "ad" , "ex-ad" )) .order_by ('email__role__name' , 'name' ), label = "Responsible AD" , empty_label = None , required = True )
385+ ad = forms .ModelChoiceField (Person .objects .filter (email__role__name = "ad" , email__role__group__state = "active" ) .order_by ('name' ), label = "Responsible AD" , empty_label = None , required = True )
386386 create_in_state = forms .ModelChoiceField (IesgDocStateName .objects .filter (slug__in = ("pub-req" , "watching" )), empty_label = None , required = True )
387387 notify = forms .CharField (max_length = 255 , label = "Notice emails" , help_text = "Separate email addresses with commas" , required = False )
388388 note = forms .CharField (widget = forms .Textarea , label = "IESG note" , required = False )
389389 telechat_date = forms .TypedChoiceField (coerce = lambda x : datetime .datetime .strptime (x , '%Y-%m-%d' ).date (), empty_value = None , required = False )
390390 returning_item = forms .BooleanField (required = False )
391391
392392 def __init__ (self , * args , ** kwargs ):
393- old_ads = kwargs .pop ('old_ads' )
394-
395393 super (self .__class__ , self ).__init__ (* args , ** kwargs )
396394
397- # fix up ad field
395+ # if previous AD is now ex-AD, append that person to the list
396+ ad_pk = self .initial .get ('ad' )
398397 choices = self .fields ['ad' ].choices
399- ex_ads = dict ((e .pk , e ) for e in Person .objects .filter (email__role__name = "ex-ad" ).distinct ())
400- if old_ads :
401- # separate active ADs from inactive
402- for i , t in enumerate (choices ):
403- if t [0 ] in ex_ads :
404- choices .insert (i , ("" , "----------------" ))
405- break
406- else :
407- # remove old ones
408- self .fields ['ad' ].choices = [t for t in choices if t [0 ] not in ex_ads ]
398+ if ad_pk and ad_pk not in [pk for pk , name in choices ]:
399+ self .fields ['ad' ].choices = list (choices ) + [("" , "-------" ), (ad_pk , Person .objects .get (pk = ad_pk ).name )]
409400
410401 # telechat choices
411402 dates = TelechatDates .objects .all ()[0 ].dates ()
@@ -473,8 +464,8 @@ def edit_infoREDESIGN(request, name):
473464
474465 if request .method == 'POST' :
475466 form = EditInfoForm (request .POST ,
476- old_ads = False ,
477- initial = dict ( telechat_date = initial_telechat_date ))
467+ initial = dict ( ad = doc . ad_id ,
468+ telechat_date = initial_telechat_date ))
478469 if form .is_valid ():
479470 save_document_in_history (doc )
480471
@@ -572,16 +563,16 @@ def diff(attr, name):
572563 else :
573564 e = doc .latest_event (StatusDateDocEvent )
574565 status = e .date if e else None
575- init = dict (intended_std_level = doc .intended_std_level ,
566+ init = dict (intended_std_level = doc .intended_std_level_id ,
576567 status_date = status ,
577- ad = doc .ad ,
568+ ad = doc .ad_id ,
578569 notify = doc .notify ,
579570 note = dehtmlify_textarea_text (doc .note ),
580571 telechat_date = initial_telechat_date ,
581572 returning_item = initial_returning_item ,
582573 )
583574
584- form = EditInfoForm (old_ads = False , initial = init )
575+ form = EditInfoForm (initial = init )
585576
586577 if not has_role (request .user , 'Secretariat' ):
587578 # filter out Via RFC Editor
0 commit comments