From fe2ce7f12a79ebee24c3941c40c6443c9445db58 Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Thu, 11 Nov 2021 22:44:31 +0000 Subject: [PATCH] Guard against None in agenda session buttons template / template tags. Commit ready for merge. - Legacy-Id: 19647 --- ietf/doc/templatetags/ietf_filters.py | 19 ++++++++++++++++--- .../meeting/session_buttons_include.html | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ietf/doc/templatetags/ietf_filters.py b/ietf/doc/templatetags/ietf_filters.py index f4b472c35..d5b541fb7 100644 --- a/ietf/doc/templatetags/ietf_filters.py +++ b/ietf/doc/templatetags/ietf_filters.py @@ -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') diff --git a/ietf/templates/meeting/session_buttons_include.html b/ietf/templates/meeting/session_buttons_include.html index 1ce2f2090..30245b514 100644 --- a/ietf/templates/meeting/session_buttons_include.html +++ b/ietf/templates/meeting/session_buttons_include.html @@ -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 %}
{% with acronym=session.historic_group.acronym %}