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

feat: Put agenda.csv in meeting TZ and add agenda-utc.csv endpoint #5226

Merged
merged 7 commits into from
Feb 28, 2023
27 changes: 27 additions & 0 deletions ietf/meeting/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,34 @@ def test_meeting_agenda(self):
self.assertContains(r, session.group.parent.acronym.upper())
self.assertContains(r, slot.location.name)
self.assertContains(r, registration_text)
start_time = slot.time.astimezone(meeting.tz())
end_time = slot.end_time().astimezone(meeting.tz())
self.assertContains(r, '"{}","{}","{}"'.format(
start_time.strftime("%Y-%m-%d"),
start_time.strftime("%H%M"),
end_time.strftime("%H%M"),
))
self.assertContains(r, session.materials.get(type='agenda').uploaded_filename)
self.assertContains(r, session.materials.filter(type='slides').exclude(states__type__slug='slides',states__slug='deleted').first().uploaded_filename)
self.assertNotContains(r, session.materials.filter(type='slides',states__type__slug='slides',states__slug='deleted').first().uploaded_filename)

# CSV, utc
r = self.client.get(urlreverse(
"ietf.meeting.views.agenda_plain",
kwargs=dict(num=meeting.number, ext=".csv", utc="-utc"),
))
self.assertContains(r, session.group.acronym)
self.assertContains(r, session.group.name)
self.assertContains(r, session.group.parent.acronym.upper())
self.assertContains(r, slot.location.name)
self.assertContains(r, registration_text)
start_time = slot.time.astimezone(datetime.timezone.utc)
end_time = slot.end_time().astimezone(datetime.timezone.utc)
self.assertContains(r, '"{}","{}","{}"'.format(
start_time.strftime("%Y-%m-%d"),
start_time.strftime("%H%M"),
end_time.strftime("%H%M"),
))
self.assertContains(r, session.materials.get(type='agenda').uploaded_filename)
self.assertContains(r, session.materials.filter(type='slides').exclude(states__type__slug='slides',states__slug='deleted').first().uploaded_filename)
self.assertNotContains(r, session.materials.filter(type='slides',states__type__slug='slides',states__slug='deleted').first().uploaded_filename)
Expand Down
3 changes: 1 addition & 2 deletions ietf/meeting/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ def get_redirect_url(self, *args, **kwargs):

type_ietf_only_patterns_id_optional = [
url(r'^agenda(?P<utc>-utc)?(?P<ext>\.html)?/?$', views.agenda, name='agenda'),
url(r'^agenda(?P<utc>-utc)?(?P<ext>\.txt)$', views.agenda_plain),
url(r'^agenda(?P<ext>\.csv)$', views.agenda_plain),
url(r'^agenda(?P<utc>-utc)?(?P<ext>\.txt|\.csv)$', views.agenda_plain),
url(r'^agenda/edit$',
RedirectView.as_view(pattern_name='ietf.meeting.views.edit_meeting_schedule', permanent=True),
name='ietf.meeting.views.edit_meeting_schedule'),
Expand Down
13 changes: 7 additions & 6 deletions ietf/meeting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ def agenda_plain(request, num=None, name=None, base=None, ext=None, owner=None,
person = get_person_by_email(owner)
schedule = get_schedule_by_name(meeting, person, name)

if schedule == None:
if schedule is None:
base = base.replace("-utc", "")
return render(request, "meeting/no-"+base+ext, {'meeting':meeting }, content_type=mimetype[ext])

Expand All @@ -1565,7 +1565,7 @@ def agenda_plain(request, num=None, name=None, base=None, ext=None, owner=None,

# Done processing for CSV output
if ext == ".csv":
return agenda_csv(schedule, filtered_assignments)
return agenda_csv(schedule, filtered_assignments, utc=utc is not None)

filter_organizer = AgendaFilterOrganizer(assignments=filtered_assignments)

Expand Down Expand Up @@ -1804,7 +1804,7 @@ def agenda_extract_slide (item):
"ext": item.file_extension()
}

def agenda_csv(schedule, filtered_assignments):
def agenda_csv(schedule, filtered_assignments, utc=False):
encoding = 'utf-8'
response = HttpResponse(content_type=f"text/csv; charset={encoding}")
writer = csv.writer(response, delimiter=str(','), quoting=csv.QUOTE_ALL)
Expand All @@ -1830,11 +1830,12 @@ def slides_field(item):

write_row(headings)

tz = datetime.timezone.utc if utc else schedule.meeting.tz()
for item in filtered_assignments:
row = []
row.append(item.timeslot.time.strftime("%Y-%m-%d"))
row.append(item.timeslot.time.strftime("%H%M"))
row.append(item.timeslot.end_time().strftime("%H%M"))
row.append(item.timeslot.time.astimezone(tz).strftime("%Y-%m-%d"))
row.append(item.timeslot.time.astimezone(tz).strftime("%H%M"))
row.append(item.timeslot.end_time().astimezone(tz).strftime("%H%M"))

if item.slot_type().slug == "break":
row.append(item.slot_type().name)
Expand Down