Repository: ietf-tools/datatracker

Issue:
Conflicts to Avoid field is empty in Session Request Tool email notifications
### Describe the issue

When we receive email notifications of session requests or updates to session requests, it seems the "Conflicts to Avoid" field in the email message is always empty, even when we have submitted conflicts when requesting the session or updating the session request.

For example, my cochair added conflicts to avoid and this is the resulting email notification:

On Mon, Sep 19, 2022 at 10:53 AM IETF Meeting Session Request Tool
<session-request@ietf.org> wrote:
>
>
>
> An update to a meeting session request has just been submitted by Mirja Kuehlewind, a Chair of the maprg working group.
>
>
> ---------------------------------------------------------
> Working Group Name: Measurement and Analysis for Protocols
> Area Name: IRTF
> Session Requester: Mirja Kühlewind
>
>
> Number of Sessions: 1
> Length of Session(s): 2 Hours
> Number of Attendees: 100
> Conflicts to Avoid:
>
>
>
>
> People who must be present:
>   Mirja Kuehlewind
>   Dave Plonka
>
> Resources Requested:
>
> Special Requests:
>
> ---------------------------------------------------------
>
>

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:
Also see https://mailarchive.ietf.org/arch/msg/tools-discuss/Q8r_D087CwCd_qHA94XWXSkNsYM
I see this happening when updating an existing session request, but I'm not able to reproduce the problem for new requests. These correctly list the conflicts, at least on my dev system.

Resolving patch:
diff --git a/ietf/secr/sreq/views.py b/ietf/secr/sreq/views.py
--- a/ietf/secr/sreq/views.py
+++ b/ietf/secr/sreq/views.py
@@ -267,6 +267,16 @@ def status_slug_for_new_session(session, session_number):
     return 'schedw'
 
 
+def get_outbound_conflicts(form: SessionForm):
+    """extract wg conflict constraint data from a SessionForm"""
+    outbound_conflicts = []
+    for conflictname, cfield_id in form.wg_constraint_field_ids():
+        conflict_groups = form.cleaned_data[cfield_id]
+        if len(conflict_groups) > 0:
+            outbound_conflicts.append(dict(name=conflictname, groups=conflict_groups))
+    return outbound_conflicts
+
+
 @role_required(*AUTHORIZED_ROLES)
 def confirm(request, acronym):
     '''
@@ -299,12 +309,8 @@ def confirm(request, acronym):
         session_data['timeranges_display'] = [t.desc for t in form.cleaned_data['timeranges']]
     session_data['resources'] = [ ResourceAssociation.objects.get(pk=pk) for pk in request.POST.getlist('resources') ]
 
-    # extract wg conflict constraint data for the view
-    outbound_conflicts = []
-    for conflictname, cfield_id in form.wg_constraint_field_ids():
-        conflict_groups = form.cleaned_data[cfield_id]
-        if len(conflict_groups) > 0:
-            outbound_conflicts.append(dict(name=conflictname, groups=conflict_groups))
+    # extract wg conflict constraint data for the view / notifications
+    outbound_conflicts = get_outbound_conflicts(form)
 
     button_text = request.POST.get('submit', '')
     if button_text == 'Cancel':
@@ -534,11 +540,14 @@ def edit(request, acronym, num=None):
                 #add_session_activity(group,'Session Request was updated',meeting,user)
 
                 # send notification
+                outbound_conflicts = get_outbound_conflicts(form)
+                session_data = form.cleaned_data.copy()  # do not add things to the original cleaned_data
+                session_data['outbound_conflicts'] = [f"{d['name']}: {d['groups']}" for d in outbound_conflicts]
                 send_notification(
                     group,
                     meeting,
                     login,
-                    form.cleaned_data,
+                    session_data,
                     [sf.cleaned_data for sf in form.session_forms.forms_to_keep],
                     'update',
                 )


Test patch: