Skip to content

Commit 1b1bc24

Browse files
Rework agenda filters with show/hide keywords in place of 'types' and add bof / AD office hours buttons
- Legacy-Id: 18563
1 parent 97dd600 commit 1b1bc24

10 files changed

Lines changed: 351 additions & 607 deletions

File tree

ietf/meeting/helpers.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,29 @@ def preprocess_assignments_for_agenda(assignments_queryset, meeting, extra_prefe
239239

240240
return assignments
241241

242+
def tag_assignments_with_filter_keywords(assignments):
243+
"""Add keywords for agenda filtering
244+
245+
Keywords are all lower case.
246+
"""
247+
for a in assignments:
248+
a.filter_keywords = [a.timeslot.type.slug.lower()]
249+
a.filter_keywords.extend(filter_keywords_for_session(a.session))
250+
251+
def filter_keywords_for_session(session):
252+
keywords = []
253+
group = getattr(session, 'historic_group', session.group)
254+
if group is not None:
255+
if group.state_id == 'bof':
256+
keywords.append('bof')
257+
keywords.append(group.acronym.lower())
258+
area = getattr(group, 'historic_parent', group.parent)
259+
if area is not None:
260+
keywords.append(area.acronym.lower())
261+
if session.name.lower().endswith('office hours'):
262+
keywords.append('adofficehours')
263+
return keywords
264+
242265
def read_session_file(type, num, doc):
243266
# XXXX FIXME: the path fragment in the code below should be moved to
244267
# settings.py. The *_PATH settings should be generalized to format()

ietf/meeting/tests_helpers.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Copyright The IETF Trust 2020, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
from ietf.group.factories import GroupFactory
4+
from ietf.meeting.factories import SessionFactory, MeetingFactory
5+
from ietf.meeting.helpers import tag_assignments_with_filter_keywords
6+
from ietf.utils.test_utils import TestCase
7+
8+
9+
class HelpersTests(TestCase):
10+
def do_test_tag_assignments_with_filter_keywords(self, bof=False, historic=None):
11+
"""Assignments should be tagged properly
12+
13+
The historic param can be None, group, or parent, to specify whether to test
14+
with no historic_group, a historic_group but no historic_parent, or both.
15+
"""
16+
meeting_types = ['regular', 'plenary']
17+
group_state_id = 'bof' if bof else 'active'
18+
group = GroupFactory(state_id=group_state_id)
19+
historic_group = GroupFactory(state_id=group_state_id)
20+
historic_parent = GroupFactory(type_id='area')
21+
22+
if historic == 'parent':
23+
historic_group.historic_parent = historic_parent
24+
25+
# Create meeting and sessions
26+
meeting = MeetingFactory()
27+
for meeting_type in meeting_types:
28+
sess = SessionFactory(group=group, meeting=meeting, type_id=meeting_type)
29+
ts = sess.timeslotassignments.first().timeslot
30+
ts.type = sess.type
31+
ts.save()
32+
33+
# Create an office hours session in the group's area (i.e., parent). This is not
34+
# currently really needed, but will protect against areas and groups diverging
35+
# in a way that breaks keywording.
36+
office_hours = SessionFactory(
37+
name='some office hours',
38+
group=group.parent,
39+
meeting=meeting,
40+
type_id='other'
41+
)
42+
ts = office_hours.timeslotassignments.first().timeslot
43+
ts.type = office_hours.type
44+
ts.save()
45+
46+
assignments = meeting.schedule.assignments.all()
47+
orig_num_assignments = len(assignments)
48+
49+
# Set up historic groups if needed
50+
if historic:
51+
for a in assignments:
52+
if a.session != office_hours:
53+
a.session.historic_group = historic_group
54+
55+
# Execute the method under test
56+
tag_assignments_with_filter_keywords(assignments)
57+
58+
# Assert expected results
59+
self.assertEqual(len(assignments), orig_num_assignments, 'Should not change number of assignments')
60+
61+
if historic:
62+
expected_group = historic_group
63+
expected_area = historic_parent if historic == 'parent' else historic_group.parent
64+
else:
65+
expected_group = group
66+
expected_area = group.parent
67+
68+
for assignment in assignments:
69+
expected_filter_keywords = [assignment.timeslot.type.slug]
70+
71+
if assignment.session == office_hours:
72+
expected_filter_keywords.extend([
73+
group.parent.acronym,
74+
'adofficehours',
75+
])
76+
else:
77+
expected_filter_keywords.extend([
78+
expected_group.acronym,
79+
expected_area.acronym
80+
])
81+
if bof:
82+
expected_filter_keywords.append('bof')
83+
84+
self.assertCountEqual(
85+
assignment.filter_keywords,
86+
expected_filter_keywords,
87+
'Assignment has incorrect filter keywords'
88+
)
89+
90+
def test_tag_assignments_with_filter_keywords(self):
91+
self.do_test_tag_assignments_with_filter_keywords()
92+
self.do_test_tag_assignments_with_filter_keywords(historic='group')
93+
self.do_test_tag_assignments_with_filter_keywords(historic='parent')
94+
self.do_test_tag_assignments_with_filter_keywords(bof=True)
95+
self.do_test_tag_assignments_with_filter_keywords(bof=True, historic='group')
96+
self.do_test_tag_assignments_with_filter_keywords(bof=True, historic='parent')

ietf/meeting/tests_js.py

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,14 @@ def test_agenda_view_filter_show_area(self):
466466
area = mars.parent
467467
self.do_agenda_view_filter_test('?show=%s' % area.acronym, ['ames', 'mars'])
468468

469+
def test_agenda_view_filter_bof(self):
470+
mars = Group.objects.get(acronym='mars')
471+
mars.state_id = 'bof'
472+
mars.save()
473+
self.do_agenda_view_filter_test('?show=bof', ['mars'])
474+
self.do_agenda_view_filter_test('?show=bof,mars', ['mars'])
475+
self.do_agenda_view_filter_test('?show=bof,ames', ['mars','ames'])
476+
469477
def test_agenda_view_filter_show_two(self):
470478
"""Filtered agenda view should display only matching rows (two groups selected)"""
471479
self.do_agenda_view_filter_test('?show=mars,ames', ['mars', 'ames'])
@@ -482,43 +490,6 @@ def test_agenda_view_filter_hide_area(self):
482490
area = mars.parent
483491
self.do_agenda_view_filter_test('?show=mars&hide=%s' % area.acronym, [])
484492

485-
def test_agenda_view_filter_show_and_hide(self):
486-
self.do_agenda_view_filter_test('?show=mars&hide=ietf', ['mars'])
487-
488-
def test_agenda_view_filter_show_and_hide_same_group(self):
489-
self.do_agenda_view_filter_test('?show=mars&hide=mars', [])
490-
491-
def test_agenda_view_filter_showtypes(self):
492-
self.do_agenda_view_filter_test('?showtypes=plenary', ['ietf']) # ietf has a plenary session
493-
494-
def test_agenda_view_filter_hidetypes(self):
495-
self.do_agenda_view_filter_test('?hidetypes=plenary', [])
496-
497-
def test_agenda_view_filter_showtypes_and_hidetypes(self):
498-
self.do_agenda_view_filter_test('?showtypes=plenary&hidetypes=regular', ['ietf']) # ietf has a plenary session
499-
500-
def test_agenda_view_filter_showtypes_and_hidetypes_same_type(self):
501-
self.do_agenda_view_filter_test('?showtypes=plenary&hidetypes=plenary', [])
502-
503-
def test_agenda_view_filter_show_and_showtypes(self):
504-
self.do_agenda_view_filter_test('?show=mars&showtypes=plenary', ['mars', 'ietf']) # ietf has a plenary session
505-
506-
def test_agenda_view_filter_show_and_hidetypes(self):
507-
self.do_agenda_view_filter_test('?show=ietf,mars&hidetypes=plenary', ['mars']) # ietf has a plenary session
508-
509-
def test_agenda_view_filter_hide_and_hidetypes(self):
510-
self.do_agenda_view_filter_test('?hide=ietf,mars&hidetypes=plenary', [])
511-
512-
def test_agenda_view_filter_show_hide_and_showtypes(self):
513-
self.do_agenda_view_filter_test('?show=mars&hide=ames&showtypes=plenary,regular', ['mars', 'ietf']) # ietf has plenary session
514-
515-
def test_agenda_view_filter_show_hide_and_hidetypes(self):
516-
self.do_agenda_view_filter_test('?show=mars,ietf&hide=ames&hidetypes=plenary', ['mars']) # ietf has plenary session
517-
518-
def test_agenda_view_filter_all_params(self):
519-
self.do_agenda_view_filter_test('?show=secretariat,ietf&hide=ames&showtypes=regular&hidetypes=plenary',
520-
['secretariat', 'mars'])
521-
522493
def assert_agenda_item_visibility(self, visible_groups=None):
523494
"""Assert that correct items are visible in current browser window
524495
@@ -692,19 +663,20 @@ def assert_upcoming_meeting_visibility(self, visible_meetings=None):
692663
not_visible = set()
693664
unexpected = set()
694665
entries = self.driver.find_elements_by_css_selector(
695-
'table#upcoming-meeting-table > tbody > tr.entry'
666+
'table#upcoming-meeting-table a.ietf-meeting-link, table#upcoming-meeting-table a.interim-meeting-link'
696667
)
697668
for entry in entries:
698-
nums = [n for n in expected if n in entry.text]
669+
entry_text = entry.get_attribute('innerHTML').strip() # gets text, even if element is hidden
670+
nums = [n for n in expected if n in entry_text]
699671
self.assertLessEqual(len(nums), 1, 'Multiple matching meeting numbers')
700672
if len(nums) > 0: # asserted that it's at most 1, so if it's not 0, it's 1.
701673
expected.remove(nums[0])
702674
if not entry.is_displayed():
703675
not_visible.add(nums[0])
704676
continue
705-
# Found an unexpected row - this is ok as long as it's hidden
677+
# Found an unexpected row - this is only a problem if it is visible
706678
if entry.is_displayed():
707-
unexpected.add(entry.text)
679+
unexpected.add(entry_text)
708680

709681
self.assertEqual(expected, set(), "Missing entries for expected iterim meetings.")
710682
self.assertEqual(not_visible, set(), "Hidden rows for expected interim meetings.")

0 commit comments

Comments
 (0)