Merged in [19647] from jennifer@painless-security.com:

Guard against None in agenda session buttons template / template tags.
 - Legacy-Id: 19651
Note: SVN reference [19647] has been migrated to Git commit fe2ce7f12a
This commit is contained in:
Robert Sparks 2021-11-12 13:05:59 +00:00
commit 6ba323473b
2 changed files with 17 additions and 4 deletions

View file

@ -646,8 +646,11 @@ def is_regular_agenda_item(assignment):
>>> any(is_regular_agenda_item(factory(t)) for t in ['plenary', 'break', 'reg', 'other', 'officehours'])
False
>>> is_regular_agenda_item(None)
False
"""
return assignment.slot_type().slug == 'regular'
return assignment is not None and assignment.slot_type().slug == 'regular'
@register.filter
def is_plenary_agenda_item(assignment):
@ -664,8 +667,11 @@ def is_plenary_agenda_item(assignment):
>>> any(is_plenary_agenda_item(factory(t)) for t in ['regular', 'break', 'reg', 'other', 'officehours'])
False
>>> is_plenary_agenda_item(None)
False
"""
return assignment.slot_type().slug == 'plenary'
return assignment is not None and assignment.slot_type().slug == 'plenary'
@register.filter
def is_special_agenda_item(assignment):
@ -682,8 +688,11 @@ def is_special_agenda_item(assignment):
>>> any(is_special_agenda_item(factory(t)) for t in ['regular', 'plenary'])
False
>>> is_special_agenda_item(None)
False
"""
return assignment.slot_type().slug in [
return assignment is not None and assignment.slot_type().slug in [
'break',
'reg',
'other',
@ -711,7 +720,11 @@ def should_show_agenda_session_buttons(assignment):
>>> test_cases.extend([('113', 'acme office hours'), ('150', 'acme office hours')])
>>> all(should_show_agenda_session_buttons(factory(*tc)) for tc in test_cases)
True
>>> should_show_agenda_session_buttons(None)
False
"""
if assignment is None:
return False
num = assignment.meeting().number
if num.isdigit() and int(num) <= settings.MEETING_LEGACY_OFFICE_HOURS_END:
return not assignment.session.name.lower().endswith(' office hours')

View file

@ -5,7 +5,7 @@
{% load ietf_filters %}
{% origin %}
{% if item|should_show_agenda_session_buttons %}
{% if item and item|should_show_agenda_session_buttons %}
{% with slug=item.slug %}{% with session=item.session %}{% with timeslot=item.timeslot %}{% with meeting=schedule.meeting %}
<div id="session-buttons-{{session.pk}}" class="text-nowrap">
{% with acronym=session.historic_group.acronym %}