Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Only consider ietf meetings as "next" for agenda_ical or agenda_json #5238

Merged
merged 7 commits into from
Feb 28, 2023
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