Commit a4628343 authored by Deimos's avatar Deimos

Rename "post_topic" permission to "topic.post"

This permission was a strange exception, with every other permission
being of a format like "topic.lock", "comment.remove", and so on.
parent 036d46d5
"""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'"
)
......@@ -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
......
......@@ -36,7 +36,7 @@
{% if request.user %}
<div class="divider"></div>
{% if request.has_permission('post_topic', group) %}
{% if request.has_permission("topic.post", group) %}
<a href="/~{{ group.path }}/new_topic" class="btn btn-primary">Post a new topic</a>
{% endif %}
......
......@@ -148,7 +148,7 @@
<div class="empty">
{% if period %}
<h2 class="empty-title">No topics in the selected time period</h2>
{% if is_single_group and request.has_permission('post_topic', group) %}
{% if is_single_group and request.has_permission("topic.post", group) %}
<p class="empty-subtitle">Try choosing a longer time period, or break the silence by posting one yourself.</p>
<div class="empty-action">
<a href="/~{{ group.path }}/new_topic" class="btn btn-primary">Post a new topic</a>
......@@ -218,7 +218,7 @@
{{ render_group_subscription_box(group) }}
{% if request.has_permission('post_topic', group) %}
{% if request.has_permission("topic.post", group) %}
<a href="/~{{ group.path }}/new_topic" class="btn btn-primary">Post a new topic</a>
{% endif %}
......
......@@ -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."""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment