fix: Prevent ADs and chairs from being added to bethere constraint (#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 <rjsparks@nostrum.com>

---------

Co-authored-by: Robert Sparks <rjsparks@nostrum.com>
Co-authored-by: Jennifer Richards <jennifer@painless-security.com>
This commit is contained in:
Lars Eggert 2023-02-21 19:03:33 +02:00 committed by GitHub
parent 50601345aa
commit cb7abbceab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 6 deletions

View file

@ -3,6 +3,7 @@
from django import forms
from django.template.defaultfilters import pluralize
import debug # pyflakes:ignore
@ -235,6 +236,25 @@ class SessionForm(forms.Form):
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']

View file

@ -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:

View file

@ -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>

View file

@ -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">
@ -70,4 +70,4 @@
</tr>
{% endif %}
</tbody>
</table>
</table>

View file

@ -123,4 +123,4 @@
}
}
window.addEventListener('load', on_load, false);
})();
})();