From e3ee3709812c2bc35e95e9d43880b4cda877190d Mon Sep 17 00:00:00 2001 From: "Mark J. Donnelly" Date: Fri, 21 May 2021 20:38:51 +0000 Subject: [PATCH] First swipe at making past sessions unchangable for official schedules This change locks down the schedule of any meeting that is fully in the past. It leaves open sessions that have finished for meetings that have not yet finished. Addresses (partially) issue #3083. Commit ready for merge. - Legacy-Id: 19030 --- ietf/meeting/helpers.py | 2 +- ietf/meeting/models.py | 5 ++ ietf/meeting/tests_views.py | 50 ++++++++++++++++++- .../meeting/edit_meeting_schedule.html | 8 ++- ietf/templates/meeting/landscape_edit.html | 3 ++ 5 files changed, 65 insertions(+), 3 deletions(-) diff --git a/ietf/meeting/helpers.py b/ietf/meeting/helpers.py index ae295842f..283a57b9d 100644 --- a/ietf/meeting/helpers.py +++ b/ietf/meeting/helpers.py @@ -358,7 +358,7 @@ def schedule_permissions(meeting, schedule, user): if user_is_person(user, schedule.owner): cansee = True - canedit = True + canedit = not schedule.is_official_record return cansee, canedit, secretariat diff --git a/ietf/meeting/models.py b/ietf/meeting/models.py index ebbf3033e..cdfedd107 100644 --- a/ietf/meeting/models.py +++ b/ietf/meeting/models.py @@ -684,6 +684,11 @@ class Schedule(models.Model): def is_official(self): return (self.meeting.schedule == self) + @property + def is_official_record(self): + return (self.is_official and + self.meeting.end_date() <= datetime.date.today() ) + # returns a dictionary {group -> [schedtimesessassignment+]} # and it has [] if the session is not placed. # if there is more than one session for that group, diff --git a/ietf/meeting/tests_views.py b/ietf/meeting/tests_views.py index 1c0db1299..e45a1de18 100644 --- a/ietf/meeting/tests_views.py +++ b/ietf/meeting/tests_views.py @@ -1221,7 +1221,55 @@ class EditTests(TestCase): self.client.login(username="secretary", password="secretary+password") r = self.client.get(urlreverse("ietf.meeting.views.edit_schedule", kwargs=dict(num=meeting.number))) self.assertContains(r, "load_assignments") - + + def test_official_record_schedule_is_read_only(self): + def _set_date_offset_and_retrieve_page(meeting, days_offset, client): + meeting.date = datetime.date.today() + datetime.timedelta(days=days_offset) + meeting.save() + client.login(username="secretary", password="secretary+password") + url = urlreverse("ietf.meeting.views.edit_meeting_schedule", kwargs=dict(num=meeting.number)) + r = client.get(url) + q = PyQuery(r.content) + return(r, q) + + # Setup + #################################################################################### + + # Basic test data + meeting = make_meeting_test_data() + + # Set the secretary as the owner of the schedule + schedule = meeting.schedule + schedule.owner = Person.objects.get(user__username="secretary") + schedule.save() + + # Tests + #################################################################################### + + # 1) Check that we get told the page is not editable + ####################################################### + r, q = _set_date_offset_and_retrieve_page(meeting, + 0 - 2 - meeting.days, # Meeting ended 2 days ago + self.client) + self.assertTrue(q("""eem:contains("You can't edit this schedule")""")) + self.assertTrue(q("""em:contains("This is the official schedule for a meeting in the past")""")) + + # 2) An ongoing meeting + ####################################################### + r, q = _set_date_offset_and_retrieve_page(meeting, + 0, # Meeting starts today + self.client) + self.assertFalse(q("""em:contains("You can't edit this schedule")""")) + self.assertFalse(q("""em:contains("This is the official schedule for a meeting in the past")""")) + + # 3) A meeting in the future + ####################################################### + r, q = _set_date_offset_and_retrieve_page(meeting, + 7, # Meeting starts next week + self.client) + self.assertFalse(q("""em:contains("You can't edit this schedule")""")) + self.assertFalse(q("""em:contains("This is the official schedule for a meeting in the past")""")) + def test_edit_meeting_schedule(self): meeting = make_meeting_test_data() diff --git a/ietf/templates/meeting/edit_meeting_schedule.html b/ietf/templates/meeting/edit_meeting_schedule.html index 47b252c54..3daced86f 100644 --- a/ietf/templates/meeting/edit_meeting_schedule.html +++ b/ietf/templates/meeting/edit_meeting_schedule.html @@ -46,7 +46,13 @@ {% if not can_edit %} · - You can't edit this schedule. Make a new agenda from this. + + + You can't edit this schedule. + {% if schedule.is_official_record %}This is the official schedule for a meeting in the past.{% endif %} + Make a new agenda from this. + + {% endif %}
diff --git a/ietf/templates/meeting/landscape_edit.html b/ietf/templates/meeting/landscape_edit.html index 16e7e93a4..85e0ef9d6 100644 --- a/ietf/templates/meeting/landscape_edit.html +++ b/ietf/templates/meeting/landscape_edit.html @@ -107,6 +107,9 @@ promiselist.push(ss_promise); {% origin %}You do not have write permission to agenda: {{schedule.name}}
+ {% if schedule.is_official_record %} +This is the official schedule for a meeting in the past.
+ {% endif %}Please save this agenda to your account first.