Skip to content

Commit

Permalink
show button to PostModerateView in post_update and topic_form templates
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Feb 26, 2025
1 parent fc8b157 commit d565de0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lacommunaute/templates/forum_conversation/partials/topic_form.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{% load i18n %}
{% load widget_tweaks %}
{% load forum_permission_tags %}
{% load permission_tags %}
<form method="post" action="." class="form" enctype="multipart/form-data" novalidate>
{% csrf_token %}
{% for error in post_form.non_field_errors %}
<div class="alert alert-danger">
<i class="icon-exclamation-sign"></i> {{ error }}
</div>
{% endfor %}
<input type="hidden" name="post_pk" value="{{ post.pk }}">
{% include "partials/form_field.html" with field=post_form.subject %}
{% include "partials/form_field.html" with field=post_form.content %}
{% if post_form.username %}
Expand Down Expand Up @@ -98,6 +100,14 @@
<a href="{% url 'forum_conversation:post_delete' forum.slug forum.pk topic.slug topic.pk post.pk %}" aria-label="{% trans "Delete" %}" role="button" class="btn btn-outline-danger">{% trans "Delete" %}</a>
</div>
{% endif %}
{% user_can_moderate_post request.user as user_can_moderate_post %}
{% if user_can_moderate_post %}
<div class="form-group col-auto" id="moderate">
<button type="submit" formaction="{% url 'forum_conversation_extension:post_moderate' forum.slug forum.pk topic.slug topic.pk %}" class="btn btn-outline-warning">
{% trans "Moderate" %}
</button>
</div>
{% endif %}
{% endif %}
</div>
</form>
10 changes: 10 additions & 0 deletions lacommunaute/templates/forum_conversation/post_update.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% load i18n %}
{% load forum_conversation_tags %}
{% load forum_permission_tags %}
{% load permission_tags %}
{% block sub_title %}
{% trans "Edit post" %}
{% endblock sub_title %}
Expand All @@ -20,6 +21,7 @@ <h3 class="m-0 h4 card-title">{% trans "Edit post" %}</h3>
<div class="card-body">
<form method="post" action="." class="form" enctype="multipart/form-data" novalidate>
{% csrf_token %}
<input type="hidden" name="post_pk" value="{{ post.pk }}">
{% include "forum_conversation/partials/post_form.html" %}
<div class="form-actions form-row">
<div class="form-group col-auto">
Expand All @@ -31,6 +33,14 @@ <h3 class="m-0 h4 card-title">{% trans "Edit post" %}</h3>
<a href="{% url 'forum_conversation:post_delete' forum.slug forum.pk topic.slug topic.pk post.pk %}" role="button" class="btn btn-outline-danger" value="{% trans "Delete" %}">{% trans "Delete" %}</a>
</div>
{% endif %}
{% user_can_moderate_post request.user as user_can_moderate_post %}
{% if user_can_moderate_post %}
<div class="form-group col-auto" id="moderate">
<button type="submit" formaction="{% url 'forum_conversation_extension:post_moderate' forum.slug forum.pk topic.slug topic.pk %}" class="btn btn-outline-warning">
{% trans "Moderate" %}
</button>
</div>
{% endif %}
</div>
</form>
</div>
Expand Down
11 changes: 11 additions & 0 deletions lacommunaute/utils/templatetags/permission_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.template import Library

from lacommunaute.forum_conversation.shortcuts import can_moderate_post


register = Library()


@register.simple_tag(takes_context=True)
def user_can_moderate_post(context, user):
return can_moderate_post(user)

0 comments on commit d565de0

Please sign in to comment.