From 934fbe8275ce937fd4acf3be431d5b33b7e311bd Mon Sep 17 00:00:00 2001 From: Deimos Date: Wed, 11 Sep 2019 14:34:19 -0600 Subject: [PATCH] Allow editing of topic titles for 5 minutes This allows all users to edit their own topics' titles for 5 minutes after posting, to be able to fix typos or other issues. Admins and people with the specifically-granted permission can still edit titles regardless of the topic's age. --- tildes/tildes/models/topic/topic.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tildes/tildes/models/topic/topic.py b/tildes/tildes/models/topic/topic.py index 5d0389a..456643b 100644 --- a/tildes/tildes/models/topic/topic.py +++ b/tildes/tildes/models/topic/topic.py @@ -300,6 +300,16 @@ class Topic(DatabaseModel): acl.append((Allow, "admin", "tag")) acl.append((Allow, "topic.tag", "tag")) + # edit_title: + # - allow admins or people with the "topic.edit_title" permission to always + # edit titles + # - allow users to edit their own topic's title for the first 5 minutes + acl.append((Allow, "admin", "edit_title")) + acl.append((Allow, "topic.edit_title", "edit_title")) + + if self.age < timedelta(minutes=5): + acl.append((Allow, self.user_id, "edit_title")) + # tools that require specifically granted permissions acl.append((Allow, "admin", "lock")) acl.append((Allow, "topic.lock", "lock")) @@ -310,9 +320,6 @@ class Topic(DatabaseModel): acl.append((Allow, "admin", "move")) acl.append((Allow, "topic.move", "move")) - acl.append((Allow, "admin", "edit_title")) - acl.append((Allow, "topic.edit_title", "edit_title")) - if self.is_link_type: acl.append((Allow, "admin", "edit_link")) acl.append((Allow, "topic.edit_link", "edit_link"))