Skip to content

Commit

Permalink
fix: Prevent ADs and chairs from being added to bethere constraint (#…
Browse files Browse the repository at this point in the history
…5169)

* fix: Prevent ADs and chairs from added to `bethere` constraint

Fixes #5163 and #3890

* Fix tests and change from "people" to "participants", to hopefully make it
clearer it's not ADs and chairs.

* Rewrap

* Update ietf/secr/sreq/forms.py

Co-authored-by: Robert Sparks <[email protected]>

---------

Co-authored-by: Robert Sparks <[email protected]>
Co-authored-by: Jennifer Richards <[email protected]>
  • Loading branch information
3 people authored Feb 21, 2023
1 parent 5060134 commit cb7abbc
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
20 changes: 20 additions & 0 deletions ietf/secr/sreq/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


from django import forms
from django.template.defaultfilters import pluralize

import debug # pyflakes:ignore

Expand Down Expand Up @@ -235,6 +236,25 @@ def clean_joint_with_groups(self):
def clean_comments(self):
return clean_text_field(self.cleaned_data['comments'])

def clean_bethere(self):
bethere = self.cleaned_data["bethere"]
if bethere:
extra = set(
Person.objects.filter(
role__group=self.group, role__name__in=["chair", "ad"]
)
& bethere
)
if extra:
extras = ", ".join(e.name for e in extra)
raise forms.ValidationError(
(
f"Please remove the following person{pluralize(len(extra))}, the system "
f"tracks their availability due to their role{pluralize(len(extra))}: {extras}."
)
)
return bethere

def clean_send_notifications(self):
return True if not self.notifications_optional else self.cleaned_data['send_notifications']

Expand Down
2 changes: 1 addition & 1 deletion ietf/secr/templates/includes/session_info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Conflicts to Avoid:
{% if session.adjacent_with_wg %} Adjacent with WG: {{ session.adjacent_with_wg }}{% endif %}
{% if session.timeranges_display %} Can't meet: {{ session.timeranges_display|join:", " }}{% endif %}

People who must be present:
Participants who must be present:
{% for person in session.bethere %} {{ person.ascii_name }}
{% endfor %}
Resources Requested:
Expand Down
4 changes: 2 additions & 2 deletions ietf/secr/templates/includes/sessions_request_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
{% endif %}
<tr class="bg1"><td>Number of Attendees:{% if not is_virtual %}<span class="required">*</span>{% endif %}</td><td>{{ form.attendees.errors }}{{ form.attendees }}</td></tr>
<tr class="bg2">
<td>People who must be present:</td>
<td>Participants who must be present:</td>
<td>
{{ form.bethere.errors }}
{{ form.bethere }}
<p class="fw-bold text-danger">
You should not include the Area Directors; they will be added automatically.
Do not include Area Directors and WG Chairs; the system already tracks their availability.
</p>
</td>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions ietf/secr/templates/includes/sessions_request_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</tr>
{% endif %}
<tr class="row1">
<td>People who must be present:</td>
<td>Participants who must be present:</td>
<td>{% if session.bethere %}<ul>{% for person in session.bethere %}<li>{{ person }}</li>{% endfor %}</ul>{% else %}<i>None</i>{% endif %}</td>
</tr>
<tr class="row2">
Expand Down Expand Up @@ -70,4 +70,4 @@
</tr>
{% endif %}
</tbody>
</table>
</table>
2 changes: 1 addition & 1 deletion ietf/static/js/session_details_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@
}
}
window.addEventListener('load', on_load, false);
})();
})();

0 comments on commit cb7abbc

Please sign in to comment.