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 @@
{% if period %}

No topics in the selected time period

- {% if is_single_group and request.has_permission('post_topic', group) %} + {% if is_single_group and request.has_permission("topic.post", group) %}

Try choosing a longer time period, or break the silence by posting one yourself.

Post a new topic @@ -218,7 +218,7 @@ {{ render_group_subscription_box(group) }} - {% if request.has_permission('post_topic', group) %} + {% if request.has_permission("topic.post", group) %} Post a new topic {% endif %} diff --git a/tildes/tildes/views/topic.py b/tildes/tildes/views/topic.py index 715d5e0..faef389 100644 --- a/tildes/tildes/views/topic.py +++ b/tildes/tildes/views/topic.py @@ -45,7 +45,7 @@ from tildes.views.financials import get_financial_data DefaultSettings = namedtuple("DefaultSettings", ["order", "period"]) -@view_config(route_name="group_topics", request_method="POST", permission="post_topic") +@view_config(route_name="group_topics", request_method="POST", permission="topic.post") @use_kwargs(TopicSchema(only=("title", "markdown", "link")), location="form") @use_kwargs( {"tags": String(missing=""), "confirm_repost": Boolean(missing=False)}, @@ -379,7 +379,7 @@ def get_search( @view_config( - route_name="new_topic", renderer="new_topic.jinja2", permission="post_topic" + route_name="new_topic", renderer="new_topic.jinja2", permission="topic.post" ) def get_new_topic_form(request: Request) -> dict: """Form for entering a new topic to post."""