Skip to content

Commit d67b298

Browse files
Use reworked filtering for ical agendas; refactor filter UI with office hours buttons and nicer formatting
- Legacy-Id: 18619
1 parent 1b1bc24 commit d67b298

11 files changed

Lines changed: 879 additions & 308 deletions

File tree

ietf/meeting/helpers.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,21 +245,22 @@ def tag_assignments_with_filter_keywords(assignments):
245245
Keywords are all lower case.
246246
"""
247247
for a in assignments:
248-
a.filter_keywords = [a.timeslot.type.slug.lower()]
249-
a.filter_keywords.extend(filter_keywords_for_session(a.session))
248+
a.filter_keywords = {a.timeslot.type.slug.lower()}
249+
a.filter_keywords.update(filter_keywords_for_session(a.session))
250250

251251
def filter_keywords_for_session(session):
252-
keywords = []
252+
keywords = {session.type.slug.lower()}
253253
group = getattr(session, 'historic_group', session.group)
254254
if group is not None:
255255
if group.state_id == 'bof':
256-
keywords.append('bof')
257-
keywords.append(group.acronym.lower())
256+
keywords.add('bof')
257+
keywords.add(group.acronym.lower())
258258
area = getattr(group, 'historic_parent', group.parent)
259259
if area is not None:
260-
keywords.append(area.acronym.lower())
261-
if session.name.lower().endswith('office hours'):
262-
keywords.append('adofficehours')
260+
keywords.add(area.acronym.lower())
261+
office_hours_match = re.match(r'^ *\w+(?: +\w+)* +office hours *$', session.name, re.IGNORECASE)
262+
if office_hours_match is not None:
263+
keywords.update(['officehours', session.name.lower().replace(' ', '')])
263264
return keywords
264265

265266
def read_session_file(type, num, doc):
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright The IETF Trust 2020, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
4+
"""Custom tags for the agenda filter template"""
5+
6+
from django import template
7+
8+
register = template.Library()
9+
10+
@register.filter
11+
def agenda_width_scale(filter_categories, spacer_scale):
12+
"""Compute the width scale for the agenda filter button table
13+
14+
Button columns are spacer_scale times as wide as the spacer columns between
15+
categories. There is one fewer spacer column than categories.
16+
"""
17+
category_count = len(filter_categories)
18+
column_count = sum([len(cat) for cat in filter_categories])
19+
# Refuse to return less than 1 to avoid width calculation problems.
20+
return max(spacer_scale * column_count + category_count - 1, 1)

ietf/meeting/tests_helpers.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,21 @@ def do_test_tag_assignments_with_filter_keywords(self, bof=False, historic=None)
6666
expected_area = group.parent
6767

6868
for assignment in assignments:
69-
expected_filter_keywords = [assignment.timeslot.type.slug]
69+
expected_filter_keywords = {assignment.timeslot.type.slug, assignment.session.type.slug}
7070

7171
if assignment.session == office_hours:
72-
expected_filter_keywords.extend([
72+
expected_filter_keywords.update([
7373
group.parent.acronym,
74-
'adofficehours',
74+
'officehours',
75+
'someofficehours',
7576
])
7677
else:
77-
expected_filter_keywords.extend([
78+
expected_filter_keywords.update([
7879
expected_group.acronym,
7980
expected_area.acronym
8081
])
8182
if bof:
82-
expected_filter_keywords.append('bof')
83+
expected_filter_keywords.add('bof')
8384

8485
self.assertCountEqual(
8586
assignment.filter_keywords,

0 commit comments

Comments
 (0)