@@ -288,7 +288,7 @@ def confirm(request, acronym):
288288 if len (group .features .session_purposes ) == 0 :
289289 raise Http404 (f'Cannot request sessions for group "{ acronym } "' )
290290 meeting = get_meeting (days = 14 )
291- form = SessionForm (group , meeting , request .POST , hidden = True )
291+ form = SessionForm (group , meeting , request .POST , hidden = True , notifications_optional = has_role ( request . user , "Secretariat" ) )
292292 form .is_valid ()
293293
294294 login = request .user .person
@@ -366,15 +366,16 @@ def confirm(request, acronym):
366366 add_event_info_to_session_qs (Session .objects .filter (group = group , meeting = meeting )).filter (current_status = 'notmeet' ).delete ()
367367
368368 # send notification
369- session_data ['outbound_conflicts' ] = [f"{ d ['name' ]} : { d ['groups' ]} " for d in outbound_conflicts ]
370- send_notification (
371- group ,
372- meeting ,
373- login ,
374- session_data ,
375- [sf .cleaned_data for sf in form .session_forms [:num_sessions ]],
376- 'new' ,
377- )
369+ if form .cleaned_data .get ("send_notifications" ):
370+ session_data ['outbound_conflicts' ] = [f"{ d ['name' ]} : { d ['groups' ]} " for d in outbound_conflicts ]
371+ send_notification (
372+ group ,
373+ meeting ,
374+ login ,
375+ session_data ,
376+ [sf .cleaned_data for sf in form .session_forms [:num_sessions ]],
377+ 'new' ,
378+ )
378379
379380 status_text = 'IETF Agenda to be scheduled'
380381 messages .success (request , 'Your request has been sent to %s' % status_text )
@@ -385,7 +386,6 @@ def confirm(request, acronym):
385386 outbound = outbound_conflicts , # each is a dict with name and groups as keys
386387 inbound = inbound_session_conflicts_as_string (group , meeting ),
387388 )
388-
389389 return render (request , 'sreq/confirm.html' , {
390390 'form' : form ,
391391 'session' : session_data ,
@@ -449,7 +449,7 @@ def edit(request, acronym, num=None):
449449 if button_text == 'Cancel' :
450450 return redirect ('ietf.secr.sreq.views.view' , acronym = acronym )
451451
452- form = SessionForm (group , meeting , request .POST , initial = initial )
452+ form = SessionForm (group , meeting , request .POST , initial = initial , notifications_optional = has_role ( request . user , "Secretariat" ) )
453453 if form .is_valid ():
454454 if form .has_changed ():
455455 changed_session_forms = [sf for sf in form .session_forms .forms_to_keep if sf .has_changed ()]
@@ -540,17 +540,18 @@ def edit(request, acronym, num=None):
540540 #add_session_activity(group,'Session Request was updated',meeting,user)
541541
542542 # send notification
543- outbound_conflicts = get_outbound_conflicts (form )
544- session_data = form .cleaned_data .copy () # do not add things to the original cleaned_data
545- session_data ['outbound_conflicts' ] = [f"{ d ['name' ]} : { d ['groups' ]} " for d in outbound_conflicts ]
546- send_notification (
547- group ,
548- meeting ,
549- login ,
550- session_data ,
551- [sf .cleaned_data for sf in form .session_forms .forms_to_keep ],
552- 'update' ,
553- )
543+ if form .cleaned_data .get ("send_notifications" ):
544+ outbound_conflicts = get_outbound_conflicts (form )
545+ session_data = form .cleaned_data .copy () # do not add things to the original cleaned_data
546+ session_data ['outbound_conflicts' ] = [f"{ d ['name' ]} : { d ['groups' ]} " for d in outbound_conflicts ]
547+ send_notification (
548+ group ,
549+ meeting ,
550+ login ,
551+ session_data ,
552+ [sf .cleaned_data for sf in form .session_forms .forms_to_keep ],
553+ 'update' ,
554+ )
554555
555556 messages .success (request , 'Session Request updated' )
556557 return redirect ('ietf.secr.sreq.views.view' , acronym = acronym )
@@ -565,7 +566,7 @@ def edit(request, acronym, num=None):
565566
566567 if not sessions :
567568 return redirect ('ietf.secr.sreq.views.new' , acronym = acronym )
568- form = SessionForm (group , meeting , initial = initial )
569+ form = SessionForm (group , meeting , initial = initial , notifications_optional = has_role ( request . user , "Secretariat" ) )
569570
570571 return render (request , 'sreq/edit.html' , {
571572 'is_locked' : is_locked and not has_role (request .user ,'Secretariat' ),
@@ -665,7 +666,7 @@ def new(request, acronym):
665666 if button_text == 'Cancel' :
666667 return redirect ('ietf.secr.sreq.views.main' )
667668
668- form = SessionForm (group , meeting , request .POST )
669+ form = SessionForm (group , meeting , request .POST , notifications_optional = has_role ( request . user , "Secretariat" ) )
669670 if form .is_valid ():
670671 return confirm (request , acronym )
671672
@@ -689,12 +690,12 @@ def new(request, acronym):
689690 add_essential_people (group ,initial )
690691 if 'resources' in initial :
691692 initial ['resources' ] = [x .pk for x in initial ['resources' ]]
692- form = SessionForm (group , meeting , initial = initial )
693+ form = SessionForm (group , meeting , initial = initial , notifications_optional = has_role ( request . user , "Secretariat" ) )
693694
694695 else :
695696 initial = {}
696697 add_essential_people (group ,initial )
697- form = SessionForm (group , meeting , initial = initial )
698+ form = SessionForm (group , meeting , initial = initial , notifications_optional = has_role ( request . user , "Secretariat" ) )
698699
699700 return render (request , 'sreq/new.html' , {
700701 'meeting' : meeting ,
0 commit comments