Skip to content

Commit

Permalink
fix: Only consider ietf meetings as "next" for agenda_ical or agenda_…
Browse files Browse the repository at this point in the history
…json (#5238)

* style: Clean up get_meeting() signature and code style

* chore: Remove unused parameter from agenda_ical() view's signature

* fix: Only consider ietf meetings as "next" in agenda_ical

* fix: Only consider ietf meetings as "next" in agenda_json

* test: Test agenda_json "next meeting" and clean up agenda_ical test

* style: Reformat new tests using Black style
  • Loading branch information
jennifer-richards authored Feb 28, 2023
1 parent cf94b89 commit 9a1de57
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 9 deletions.
10 changes: 6 additions & 4 deletions ietf/meeting/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@
from ietf.utils.text import xslugify


def get_meeting(num=None,type_in=['ietf',],days=28):
def get_meeting(num=None, type_in=('ietf',), days=28):
meetings = Meeting.objects
if type_in:
if type_in is not None:
meetings = meetings.filter(type__in=type_in)
if num == None:
meetings = meetings.filter(date__gte=timezone.now()-datetime.timedelta(days=days)).order_by('date')
if num is None:
meetings = meetings.filter(
date__gte=timezone.now() - datetime.timedelta(days=days)
).order_by('date')
else:
meetings = meetings.filter(number=num)
if meetings.exists():
Expand Down
33 changes: 33 additions & 0 deletions ietf/meeting/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,39 @@ def test_meeting_agenda(self):
r = self.client.get(urlreverse('floor-plan', kwargs=dict(num=meeting.number)))
self.assertEqual(r.status_code, 200)

def test_agenda_ical_next_meeting_type(self):
# start with no upcoming IETF meetings, just an interim
MeetingFactory(
type_id="interim", date=date_today() + datetime.timedelta(days=15)
)
r = self.client.get(urlreverse("ietf.meeting.views.agenda_ical", kwargs={}))
self.assertEqual(
r.status_code, 404, "Should not return an interim meeting as next meeting"
)
# create an IETF meeting after the interim - it should be found as "next"
ietf_meeting = MeetingFactory(
type_id="ietf", date=date_today() + datetime.timedelta(days=30)
)
SessionFactory(meeting=ietf_meeting, name="Session at IETF meeting")
r = self.client.get(urlreverse("ietf.meeting.views.agenda_ical", kwargs={}))
self.assertContains(r, "Session at IETF meeting", status_code=200)

def test_agenda_json_next_meeting_type(self):
# start with no upcoming IETF meetings, just an interim
MeetingFactory(
type_id="interim", date=date_today() + datetime.timedelta(days=15)
)
r = self.client.get(urlreverse("ietf.meeting.views.agenda_json", kwargs={}))
self.assertEqual(
r.status_code, 404, "Should not return an interim meeting as next meeting"
)
# create an IETF meeting after the interim - it should be found as "next"
ietf_meeting = MeetingFactory(
type_id="ietf", date=date_today() + datetime.timedelta(days=30)
)
SessionFactory(meeting=ietf_meeting, name="Session at IETF meeting")
r = self.client.get(urlreverse("ietf.meeting.views.agenda_json", kwargs={}))
self.assertContains(r, "Session at IETF meeting", status_code=200)

@override_settings(PROCEEDINGS_V1_BASE_URL='https://example.com/{meeting.number}')
def test_agenda_redirects_for_old_meetings(self):
Expand Down
23 changes: 18 additions & 5 deletions ietf/meeting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2041,10 +2041,13 @@ def should_include_assignment(filter_params, assignment):
hidden = len(set(filter_params['hide']).intersection(assignment.filter_keywords)) > 0
return shown and not hidden

def agenda_ical(request, num=None, name=None, acronym=None, session_id=None):
def agenda_ical(request, num=None, acronym=None, session_id=None):
"""Agenda ical view
By default, all agenda items will be shown. A filter can be specified in
If num is None, looks for the next IETF meeting. Otherwise, uses the requested meeting
regardless of its type.
By default, all agenda items will be shown. A filter can be specified in
the querystring. It has the format
?show=...&hide=...&showtypes=...&hidetypes=...
Expand All @@ -2059,8 +2062,13 @@ def agenda_ical(request, num=None, name=None, acronym=None, session_id=None):
Hiding (by wg or type) takes priority over showing.
"""
meeting = get_meeting(num, type_in=None)
schedule = get_schedule(meeting, name)
if num is None:
meeting = get_ietf_meeting()
if meeting is None:
raise Http404
else:
meeting = get_meeting(num, type_in=None) # get requested meeting, whatever its type
schedule = get_schedule(meeting)
updated = meeting.updated()

if schedule is None and acronym is None and session_id is None:
Expand Down Expand Up @@ -2099,7 +2107,12 @@ def agenda_ical(request, num=None, name=None, acronym=None, session_id=None):

@cache_page(15 * 60)
def agenda_json(request, num=None):
meeting = get_meeting(num, type_in=['ietf','interim'])
if num is None:
meeting = get_ietf_meeting()
if meeting is None:
raise Http404
else:
meeting = get_meeting(num, type_in=None) # get requested meeting, whatever its type

sessions = []
locations = set()
Expand Down

0 comments on commit 9a1de57

Please sign in to comment.