Browse Source

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.
merge-requests/85/head
Deimos 5 years ago
parent
commit
934fbe8275
  1. 13
      tildes/tildes/models/topic/topic.py

13
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"))

Loading…
Cancel
Save