diff --git a/tildes/alembic/versions/82e9801eb2d6_update_post_topic_permission_to_topic_.py b/tildes/alembic/versions/82e9801eb2d6_update_post_topic_permission_to_topic_.py new file mode 100644 index 0000000..50f2e62 --- /dev/null +++ b/tildes/alembic/versions/82e9801eb2d6_update_post_topic_permission_to_topic_.py @@ -0,0 +1,28 @@ +"""Update post_topic permission to topic.post + +Revision ID: 82e9801eb2d6 +Revises: 0435c46f64d8 +Create Date: 2020-08-05 00:05:46.690188 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "82e9801eb2d6" +down_revision = "0435c46f64d8" +branch_labels = None +depends_on = None + + +def upgrade(): + op.execute( + "update user_permissions set permission = 'topic.post' where permission = 'post_topic'" + ) + + +def downgrade(): + op.execute( + "update user_permissions set permission = 'post_topic' where permission = 'topic.post'" + ) diff --git a/tildes/tildes/models/group/group.py b/tildes/tildes/models/group/group.py index eedbc4c..dfa9cdc 100644 --- a/tildes/tildes/models/group/group.py +++ b/tildes/tildes/models/group/group.py @@ -124,15 +124,15 @@ class Group(DatabaseModel): # - all groups can be subscribed to by logged-in users acl.append((Allow, Authenticated, "subscribe")) - # post_topic: + # topic.post: # - only users with specifically-granted permission can post topics in groups # that require permission to post # - otherwise, all logged-in users can post if self.requires_permission_to_post_topics: - acl.append((Allow, f"{self.group_id}:post_topic", "post_topic")) - acl.append((Deny, Everyone, "post_topic")) + acl.append((Allow, f"{self.group_id}:topic.post", "topic.post")) + acl.append((Deny, Everyone, "topic.post")) - acl.append((Allow, Authenticated, "post_topic")) + acl.append((Allow, Authenticated, "topic.post")) # wiki_page_create: # - requires being granted the "wiki.edit" permission diff --git a/tildes/tildes/templates/search.jinja2 b/tildes/tildes/templates/search.jinja2 index 2cf2a85..721b0f9 100644 --- a/tildes/tildes/templates/search.jinja2 +++ b/tildes/tildes/templates/search.jinja2 @@ -36,7 +36,7 @@ {% if request.user %}
- {% if request.has_permission('post_topic', group) %} + {% if request.has_permission("topic.post", group) %} Post a new topic {% endif %} diff --git a/tildes/tildes/templates/topic_listing.jinja2 b/tildes/tildes/templates/topic_listing.jinja2 index d613fe3..f3b1b44 100644 --- a/tildes/tildes/templates/topic_listing.jinja2 +++ b/tildes/tildes/templates/topic_listing.jinja2 @@ -148,7 +148,7 @@Try choosing a longer time period, or break the silence by posting one yourself.