1212from django .utils .html import strip_tags
1313from django .db .models import Max
1414from django .conf import settings
15+ from django .contrib .auth .decorators import login_required
1516
1617from ietf .utils .mail import send_mail_text , send_mail_message
1718from ietf .ietfauth .decorators import group_required
@@ -201,14 +202,21 @@ class ChangeStreamForm(forms.Form):
201202 stream = forms .ModelChoiceField (StreamName .objects .exclude (slug = "legacy" ), required = False )
202203 comment = forms .CharField (widget = forms .Textarea , required = False )
203204
204- @group_required ( 'Area_Director' , 'Secretariat' )
205+ @login_required
205206def change_stream (request , name ):
206207 """Change the stream of a Document of type 'draft' , notifying parties as necessary
207208 and logging the change as a comment."""
208209 doc = get_object_or_404 (Document , docalias__name = name )
209210 if not doc .type_id == 'draft' :
210211 raise Http404 ()
211212
213+ if not (has_role (request .user , ("Area Director" , "Secretariat" )) or
214+ (request .user .is_authenticated () and
215+ Role .objects .filter (name = "chair" ,
216+ group__acronym__in = StreamName .objects .values_list ("slug" , flat = True ),
217+ person__user = request .user ))):
218+ return HttpResponseForbidden ("You do not have permission to view this page" )
219+
212220 login = request .user .get_profile ()
213221
214222 if request .method == 'POST' :
@@ -224,7 +232,7 @@ def change_stream(request, name):
224232 doc .stream = new_stream
225233
226234 e = DocEvent (doc = doc ,by = login ,type = 'changed_document' )
227- e .desc = u"Stream changed to <b>%s</b> from %s" % (new_stream ,old_stream )
235+ e .desc = u"Stream changed to <b>%s</b> from %s" % (new_stream , old_stream or "None" )
228236 e .save ()
229237
230238 email_desc = e .desc
0 commit comments