Skip to content

Commit fe2ce7f

Browse files
Guard against None in agenda session buttons template / template tags. Commit ready for merge.
- Legacy-Id: 19647
1 parent 9e7cb30 commit fe2ce7f

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

ietf/doc/templatetags/ietf_filters.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,11 @@ def is_regular_agenda_item(assignment):
646646
647647
>>> any(is_regular_agenda_item(factory(t)) for t in ['plenary', 'break', 'reg', 'other', 'officehours'])
648648
False
649+
650+
>>> is_regular_agenda_item(None)
651+
False
649652
"""
650-
return assignment.slot_type().slug == 'regular'
653+
return assignment is not None and assignment.slot_type().slug == 'regular'
651654

652655
@register.filter
653656
def is_plenary_agenda_item(assignment):
@@ -664,8 +667,11 @@ def is_plenary_agenda_item(assignment):
664667
665668
>>> any(is_plenary_agenda_item(factory(t)) for t in ['regular', 'break', 'reg', 'other', 'officehours'])
666669
False
670+
671+
>>> is_plenary_agenda_item(None)
672+
False
667673
"""
668-
return assignment.slot_type().slug == 'plenary'
674+
return assignment is not None and assignment.slot_type().slug == 'plenary'
669675

670676
@register.filter
671677
def is_special_agenda_item(assignment):
@@ -682,8 +688,11 @@ def is_special_agenda_item(assignment):
682688
683689
>>> any(is_special_agenda_item(factory(t)) for t in ['regular', 'plenary'])
684690
False
691+
692+
>>> is_special_agenda_item(None)
693+
False
685694
"""
686-
return assignment.slot_type().slug in [
695+
return assignment is not None and assignment.slot_type().slug in [
687696
'break',
688697
'reg',
689698
'other',
@@ -711,7 +720,11 @@ def should_show_agenda_session_buttons(assignment):
711720
>>> test_cases.extend([('113', 'acme office hours'), ('150', 'acme office hours')])
712721
>>> all(should_show_agenda_session_buttons(factory(*tc)) for tc in test_cases)
713722
True
723+
>>> should_show_agenda_session_buttons(None)
724+
False
714725
"""
726+
if assignment is None:
727+
return False
715728
num = assignment.meeting().number
716729
if num.isdigit() and int(num) <= settings.MEETING_LEGACY_OFFICE_HOURS_END:
717730
return not assignment.session.name.lower().endswith(' office hours')

ietf/templates/meeting/session_buttons_include.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{% load ietf_filters %}
66
{% origin %}
77

8-
{% if item|should_show_agenda_session_buttons %}
8+
{% if item and item|should_show_agenda_session_buttons %}
99
{% with slug=item.slug %}{% with session=item.session %}{% with timeslot=item.timeslot %}{% with meeting=schedule.meeting %}
1010
<div id="session-buttons-{{session.pk}}" class="text-nowrap">
1111
{% with acronym=session.historic_group.acronym %}

0 commit comments

Comments
 (0)