@@ -1209,6 +1209,7 @@ def request_publication(request, name):
12091209
12101210class AdoptDraftForm (forms .Form ):
12111211 group = forms .ModelChoiceField (queryset = Group .objects .filter (type__in = ["wg" , "rg" ], state = "active" ).order_by ("-type" , "acronym" ), required = True , empty_label = None )
1212+ newstate = forms .ModelChoiceField (queryset = State .objects .filter (type__in = ['draft-stream-ietf' ,'draft-stream-irtf' ],slug__in = ['wg-cand' , 'c-adopt' , 'adopt-wg' , 'info' , 'wg-doc' , 'candidat' ,'active' ]),required = True ,label = "State" )
12121213 comment = forms .CharField (widget = forms .Textarea , required = False , label = "Comment" , help_text = "Optional comment explaining the reasons for the adoption" )
12131214 weeks = forms .IntegerField (required = False , label = "Expected weeks in adoption state" )
12141215
@@ -1218,17 +1219,21 @@ def __init__(self, *args, **kwargs):
12181219 super (AdoptDraftForm , self ).__init__ (* args , ** kwargs )
12191220
12201221 if has_role (user , "Secretariat" ):
1221- pass # all groups
1222+ state_choices = State . objects . filter ( type__in = [ 'draft-stream-ietf' , 'draft-stream-irtf' ], slug__in = [ 'wg-cand' , 'c-adopt' , 'adopt-wg' , 'info' , 'wg-doc' , 'candidat' , 'active' ])
12221223 elif has_role (user , "IRTF Chair" ):
12231224 #The IRTF chair can adopt a draft into any RG
12241225 group_ids = list (Group .objects .filter (type = "rg" , state = "active" ).values_list ('id' , flat = True ))
12251226 group_ids .extend (list (Group .objects .filter (type = "wg" , state = "active" , role__person__user = user , role__name__in = ("chair" , "delegate" , "secr" )).values_list ('id' , flat = True )))
12261227 self .fields ["group" ].queryset = self .fields ["group" ].queryset .filter (id__in = group_ids ).distinct ()
1228+ state_choices = State .objects .filter (type__in = ['draft-stream-ietf' ,'draft-stream-irtf' ],slug__in = ['wg-cand' , 'c-adopt' , 'adopt-wg' , 'info' , 'wg-doc' , 'candidat' ,'active' ])
12271229 else :
12281230 self .fields ["group" ].queryset = self .fields ["group" ].queryset .filter (role__person__user = user , role__name__in = ("chair" , "delegate" , "secr" )).distinct ()
1231+ state_choices = State .objects .filter (type__in = ['draft-stream-ietf' ,'draft-stream-irtf' ],slug__in = ['wg-cand' , 'c-adopt' , 'adopt-wg' , 'info' , 'wg-doc' ])
12291232
12301233 self .fields ['group' ].choices = [(g .pk , '%s - %s' % (g .acronym , g .name )) for g in self .fields ["group" ].queryset ]
12311234
1235+ self .fields ['newstate' ].choices = [(x .pk ,x .name ) for x in state_choices ]
1236+ self .fields ['newstate' ].choices .insert (0 ,('' ,'--------' ))
12321237
12331238@login_required
12341239def adopt_draft (request , name ):
@@ -1251,10 +1256,10 @@ def adopt_draft(request, name):
12511256 group = form .cleaned_data ["group" ]
12521257 if group .type .slug == "rg" :
12531258 new_stream = StreamName .objects .get (slug = "irtf" )
1254- adopt_state_slug = "active"
12551259 else :
12561260 new_stream = StreamName .objects .get (slug = "ietf" )
1257- adopt_state_slug = "c-adopt"
1261+
1262+ new_state = form .cleaned_data ["newstate" ]
12581263
12591264 # stream
12601265 if doc .stream != new_stream :
@@ -1287,7 +1292,6 @@ def adopt_draft(request, name):
12871292
12881293 # state
12891294 prev_state = doc .get_state ("draft-stream-%s" % doc .stream_id )
1290- new_state = State .objects .get (slug = adopt_state_slug , type = "draft-stream-%s" % doc .stream_id , used = True )
12911295 if new_state != prev_state :
12921296 doc .set_state (new_state )
12931297 e = add_state_change_event (doc , by , prev_state , new_state , timestamp = doc .time )
0 commit comments