From 8a43f7aedfb08f361905bc3e7073ba598cacc71c Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Mon, 4 Dec 2017 13:55:16 +0000 Subject: [PATCH] Added better handling for attempted (mistaken) uploads to unscheduled sessions. - Legacy-Id: 14388 --- ietf/meeting/tests_views.py | 21 +++++++++++++++++++++ ietf/meeting/views.py | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/ietf/meeting/tests_views.py b/ietf/meeting/tests_views.py index 18c4061bf..ed05853c0 100644 --- a/ietf/meeting/tests_views.py +++ b/ietf/meeting/tests_views.py @@ -1655,6 +1655,27 @@ class MaterialsTests(TestCase): self.assertEqual(doc.rev,'01') self.assertTrue(session2.sessionpresentation_set.filter(document__type_id=doctype)) + def test_upload_minutes_agenda_unscheduled(self): + for doctype in ('minutes','agenda'): + session = SessionFactory(meeting__type_id='ietf', add_to_schedule=False) + if doctype == 'minutes': + url = urlreverse('ietf.meeting.views.upload_session_minutes',kwargs={'num':session.meeting.number,'session_id':session.id}) + else: + url = urlreverse('ietf.meeting.views.upload_session_agenda',kwargs={'num':session.meeting.number,'session_id':session.id}) + self.client.logout() + login_testing_unauthorized(self,"secretary",url) + r = self.client.get(url) + self.assertEqual(r.status_code, 200) + q = PyQuery(r.content) + self.assertTrue('Upload' in unicode(q("Title"))) + self.assertFalse(session.sessionpresentation_set.exists()) + self.assertFalse(q('form input[type="checkbox"]')) + + test_file = StringIO('this is some text for a test') + test_file.name = "not_really.txt" + r = self.client.post(url,dict(file=test_file,apply_to_all=False)) + self.assertEqual(r.status_code, 410) + def test_upload_minutes_agenda_interim(self): session=SessionFactory(meeting__type_id='interim') for doctype in ('minutes','agenda'): diff --git a/ietf/meeting/views.py b/ietf/meeting/views.py index 08829d182..d4582bf8d 100644 --- a/ietf/meeting/views.py +++ b/ietf/meeting/views.py @@ -1163,6 +1163,8 @@ def upload_session_bluesheets(request, session_id, num): else: ota = session.official_timeslotassignment() sess_time = ota and ota.timeslot.time + if not sess_time: + return HttpResponse("Cannot receive uploads for an unscheduled session. Please check the session ID.", status=410, content_type="text/plain") if session.meeting.type_id=='ietf': name = 'bluesheets-%s-%s-%s' % (session.meeting.number, session.group.acronym, @@ -1253,6 +1255,8 @@ def upload_session_minutes(request, session_id, num): else: ota = session.official_timeslotassignment() sess_time = ota and ota.timeslot.time + if not sess_time: + return HttpResponse("Cannot receive uploads for an unscheduled session. Please check the session ID.", status=410, content_type="text/plain") if session.meeting.type_id=='ietf': name = 'minutes-%s-%s' % (session.meeting.number, session.group.acronym) @@ -1359,6 +1363,8 @@ def upload_session_agenda(request, session_id, num): else: ota = session.official_timeslotassignment() sess_time = ota and ota.timeslot.time + if not sess_time: + return HttpResponse("Cannot receive uploads for an unscheduled session. Please check the session ID.", status=410, content_type="text/plain") if session.meeting.type_id=='ietf': name = 'agenda-%s-%s' % (session.meeting.number, session.group.acronym)