From c3c3a073d2c1cd8ae35703e4bc2b75e4a0999e6a Mon Sep 17 00:00:00 2001 From: Deimos Date: Sun, 9 Feb 2020 13:47:02 -0700 Subject: [PATCH] Hide "View Markdown" when user can edit the post If a user can edit a post, they don't need the ability to view the markdown separately, so the button doesn't need to be shown in those cases. I'm not sure if this should be a separate permission defined inside the ACL or not. --- tildes/tildes/templates/macros/comments.jinja2 | 3 +++ tildes/tildes/templates/topic.jinja2 | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tildes/tildes/templates/macros/comments.jinja2 b/tildes/tildes/templates/macros/comments.jinja2 index f5c65f4..bd8cea0 100644 --- a/tildes/tildes/templates/macros/comments.jinja2 +++ b/tildes/tildes/templates/macros/comments.jinja2 @@ -202,6 +202,8 @@ {% endif %} + {# Don't show the "View Markdown" button (or dropdown) if the user can edit #} + {% if not request.has_permission("edit", comment) %}
  • + {% endif %}
    {% endif %} diff --git a/tildes/tildes/templates/topic.jinja2 b/tildes/tildes/templates/topic.jinja2 index 99dc818..8f1dd71 100644 --- a/tildes/tildes/templates/topic.jinja2 +++ b/tildes/tildes/templates/topic.jinja2 @@ -173,7 +173,11 @@ {{ post_action_toggle_button("remove", topic, topic.is_removed) }} {% endif %} - {% if topic.is_text_type and request.has_permission("view_content", topic) %} + {# Only show "View Markdown" (and dropdown) when it's a text topic and the user is + allowed to view the content, but can't edit it #} + {% if topic.is_text_type + and request.has_permission("view_content", topic) + and not request.has_permission("edit", topic) %}