Skip to content

Commit

Permalink
Merge pull request #6354 from akatsoulas/extract-moderation-tool
Browse files Browse the repository at this point in the history
Extract moderation tool to a separate url
  • Loading branch information
akatsoulas authored Nov 15, 2024
2 parents 345ec81 + 1c98787 commit 8a157f7
Show file tree
Hide file tree
Showing 10 changed files with 230 additions and 135 deletions.
36 changes: 36 additions & 0 deletions kitsune/flagit/jinja2/flagit/content_moderation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% extends "flagit/flagit_base.html" %}

{% block flagged_items %}
{% for object in objects %}
<li class="{{ object.content_type }}">
<div class="flagged-item-content">
<hgroup>
<h2 class="sumo-card-heading">{{ _('Flagged {t} (Reason: {r})')|f(t=object.content_type, r=object.get_reason_display()) }}</h2>
{% if object.notes %}
<p class="notes">{{ _('Other reason:') }} {{ object.notes }}</p>
{% endif %}
</hgroup>
<div class="wrap">
{% if object.content_object %}
{% include 'flagit/includes/flagged_%s.html' % object.content_type.model %}
{% else %}
<p>{{ _('{t} with id={id} no longer exists.')|f(t=object.content_type, id=object.object_id) }}</p>
{% endif %}
<h3 class="sumo-card-heading"><br>{{ _('Update Status:') }}</h3>
<form class="update inline-form" action="{{ object.form_action }}" method="post">
{% csrf_token %}
<select name="status">
<option value="">{{ _('Please select...') }}</option>
<option value="1">{{ _('Content categorization is updated.') }}</option>
<option value="2">{{ _('Content is appropriately categorized.') }}</option>
</select>
<input id="update-status-button-{{ object.content_object.id }}" type="submit"
class="sumo-button primary-button button-lg btn" value={{ _('Update') }} />
</form>
</div>
</div>
</li>
{% else %}
<p>{{ _('There is no content pending moderation.') }}</p>
{% endfor %}
{% endblock %}
32 changes: 32 additions & 0 deletions kitsune/flagit/jinja2/flagit/flagit_base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% extends "questions/base.html" %} {# TODO: liberate - remove questions dependency #}
{% from "includes/common_macros.html" import for_contributors_sidebar %}
{% set title = _('Flagged Content Pending Moderation') %}
{% set classes = 'flagged' %}
{% set scripts = ('flagit', ) %}

{% block content %}
<div id="flagged-queue" class="sumo-page-section">
<h1 class="sumo-page-heading">{{ _('Content Pending Moderation') }}</h1>

<ul class="flagged-items">
{% block flagged_items %}
{% endblock %}
</ul>
{% block deactivation_log %}
<div class="sumo-button-wrap"></div>
<a class="sumo-button primary-button" rel="nofollow" href="{{ url('users.deactivation_log') }}">{{ _('View all deactivated users') }}</a>
</div>
{% endblock %}
</div>
{% endblock %}

{% block side_top %}
<nav id="doc-tools">
<ul class="sidebar-nav sidebar-folding">
{{ for_contributors_sidebar(user, settings.WIKI_DEFAULT_LANGUAGE, active="flagit.flagged_queue", menu="contributor-tools", locale=locale) }}
</ul>

{% block side_top_reason %}
{% endblock %}
</nav>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h3 class="flagged-content__subheading">{{ _('Updated:') }}</h3>
<h3 class="flagged-content__subheading">{{ _('Flagged:') }}</h3>
<p>{{ date_by_user(object.created, object.creator) }}</p>

{% if object.reason == 'bug_support' and question_model and user.has_perm('questions.change_question') %}
{% if object.reason == 'content_moderation' and question_model and user.has_perm('questions.change_question') %}
<h3 class="flagged-content__subheading">{{ _('Take Action:') }}</h3>
<div class="flagged-content__topic-update">
<label> {{ _('Current topic:') }} </label>
Expand Down
139 changes: 60 additions & 79 deletions kitsune/flagit/jinja2/flagit/queue.html
Original file line number Diff line number Diff line change
@@ -1,84 +1,65 @@
{% extends "questions/base.html" %} {# TODO: liberate - remove questions dependency #}
{% from "includes/common_macros.html" import for_contributors_sidebar %}
{% set title = _('Flagged Content Pending Moderation') %}
{% set classes = 'flagged' %}
{% set scripts = ('flagit', ) %}
{% extends "flagit/flagit_base.html" %}

{% block content %}
<div id="flagged-queue" class="sumo-page-section">
<h1 class="sumo-page-heading">{{ _('Content Pending Moderation') }}</h1>

<ul class="flagged-items">
{% for object in objects %}
<li class="{{ object.content_type }}">
<div class="flagged-item-content">
<hgroup>
<h2 class="sumo-card-heading">{{ _('Flagged {t} (Reason: {r})')|f(t=object.content_type, r=object.get_reason_display()) }}</h2>
{% if object.notes %}
<p class="notes">{{ _('Other reason:') }} {{ object.notes }}</p>
{% endif %}
</hgroup>
<div class="wrap">
{% if object.content_object %}
{% include 'flagit/includes/flagged_%s.html' % object.content_type.model %}
{% else %}
<p>{{ _('{t} with id={id} no longer exists.')|f(t=object.content_type, id=object.object_id) }}</p>
{% endif %}
<h3 class="sumo-card-heading"><br>{{ _('Update Status:') }}</h3>
<form class="update inline-form" action="{{ object.form_action }}" method="post">
{% csrf_token %}
<select name="status">
<option value="">{{ _('Please select...') }}</option>
{% if object.reason == "spam" %}
<option value="1">{{ _('Removed spam content.') }}</option>
<option value="2">{{ _('No spam found.') }}</option>
{% elif object.reason == "abuse" %}
<option value="1">{{ _('Addressed abusive content.') }}</option>
<option value="2">{{ _('No abuse detected.') }}</option>
{% elif object.reason == "bug_support" %}
<option value="1">{{ _('Redirected support request.') }}</option>
<option value="2">{{ _('Content is appropriately placed.') }}</option>
{% elif object.reason == "language" %}
<option value="1">{{ _('Corrected language.') }}</option>
<option value="2">{{ _('Language is appropriate.') }}</option>
{% else %}
<option value="1">{{ _('Issue resolved.') }}</option>
<option value="2">{{ _('No issues found.') }}</option>
{% endif %}
</select>
<input id="update-status-button-{{ object.content_object.id }}" type="submit"
class="sumo-button primary-button button-lg btn" value={{ _('Update') }} />
</form>
</div>
{% block flagged_items %}
{% for object in objects %}
<li class="{{ object.content_type }}">
<div class="flagged-item-content">
<hgroup>
<h2 class="sumo-card-heading">{{ _('Flagged {t} (Reason: {r})')|f(t=object.content_type, r=object.get_reason_display()) }}</h2>
{% if object.notes %}
<p class="notes">{{ _('Other reason:') }} {{ object.notes }}</p>
{% endif %}
</hgroup>
<div class="wrap">
{% if object.content_object %}
{% include 'flagit/includes/flagged_%s.html' % object.content_type.model %}
{% else %}
<p>{{ _('{t} with id={id} no longer exists.')|f(t=object.content_type, id=object.object_id) }}</p>
{% endif %}
<h3 class="sumo-card-heading"><br>{{ _('Update Status:') }}</h3>
<form class="update inline-form" action="{{ object.form_action }}" method="post">
{% csrf_token %}
<select name="status">
<option value="">{{ _('Please select...') }}</option>
{% if object.reason == "spam" %}
<option value="1">{{ _('Removed spam content.') }}</option>
<option value="2">{{ _('No spam found.') }}</option>
{% elif object.reason == "abuse" %}
<option value="1">{{ _('Addressed abusive content.') }}</option>
<option value="2">{{ _('No abuse detected.') }}</option>
{% elif object.reason == "bug_support" %}
<option value="1">{{ _('Request moved.') }}</option>
<option value="2">{{ _('Request is appropriately placed.') }}</option>
{% elif object.reason == "language" %}
<option value="1">{{ _('Corrected language.') }}</option>
<option value="2">{{ _('Language is appropriate.') }}</option>
{% else %}
<option value="1">{{ _('Issue resolved.') }}</option>
<option value="2">{{ _('No issues found.') }}</option>
{% endif %}
</select>
<input id="update-status-button-{{ object.content_object.id }}" type="submit"
class="sumo-button primary-button button-lg btn" value={{ _('Update') }} />
</form>
</div>
</li>
{% else %}
<p>{{ _('There is no content pending moderation.') }}</p>
{% endfor %}
</ul>

<div class="sumo-button-wrap">
<a class="sumo-button primary-button" rel="nofollow" href="{{ url('users.deactivation_log') }}">{{ _('View all deactivated users') }}</a>
</div>
</div>
</div>
</li>
{% else %}
<p>{{ _('There is no content pending moderation.') }}</p>
{% endfor %}
{% endblock %}

{% block side_top %}
<nav id="doc-tools">
<ul class="sidebar-nav sidebar-folding">
{{ for_contributors_sidebar(user, settings.WIKI_DEFAULT_LANGUAGE, active="flagit.flagged_queue", menu="contributor-tools", locale=locale) }}
</ul>
<!-- Dropdown filter for reasons -->
<div class="filter-reasons">
<form id="reason-filter-form" method="get" action="">
<label for="reason">{{ _('Filter by reason:') }}</label>
<select name="reason" id="flagit-reason-filter">
<option value="">{{ _('All reasons') }}</option>
{% for value, display in reasons %}
<option value="{{ value }}" {% if selected_reason == value %}selected{% endif %}>{{ display }}</option>
{% endfor %}
</select>
</form>
</div>
</nav>
{% block side_top_reason %}
<!-- Dropdown filter for reasons -->
<div class="filter-reasons">
<form id="reason-filter-form" method="get" action="">
<label for="reason">{{ _('Filter by reason:') }}</label>
<select name="reason" id="flagit-reason-filter">
<option value="">{{ _('All reasons') }}</option>
{% for value, display in reasons %}
<option value="{{ value }}" {% if selected_reason == value %}selected{% endif %}>{{ display }}</option>
{% endfor %}
</select>
</form>
</div>
{% endblock %}
16 changes: 11 additions & 5 deletions kitsune/flagit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ def pending(self):
class FlaggedObject(ModelBase):
"""A flag raised on an object."""

REASON_SPAM = "spam"
REASON_LANGUAGE = "language"
REASON_BUG_SUPPORT = "bug_support"
REASON_ABUSE = "abuse"
REASON_CONTENT_MODERATION = "content_moderation"
REASON_OTHER = "other"
REASONS = (
("spam", _lazy("Spam or other unrelated content")),
("language", _lazy("Inappropriate language/dialog")),
("bug_support", _lazy("Misplaced bug report or support request")),
("abuse", _lazy("Abusive content")),
("other", _lazy("Other (please specify)")),
(REASON_SPAM, _lazy("Spam or other unrelated content")),
(REASON_LANGUAGE, _lazy("Inappropriate language/dialog")),
(REASON_BUG_SUPPORT, _lazy("Misplaced bug report or support request")),
(REASON_ABUSE, _lazy("Abusive content")),
(REASON_OTHER, _lazy("Other (please specify)")),
)

FLAG_PENDING = 0
Expand Down
1 change: 1 addition & 0 deletions kitsune/flagit/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

urlpatterns = [
re_path(r"^flagged$", views.flagged_queue, name="flagit.flagged_queue"),
re_path(r"^moderate$", views.moderate_content, name="flagit.moderate_content"),
re_path(r"^flag$", views.flag, name="flagit.flag"),
re_path(r"^update/(?P<flagged_object_id>\d+)$", views.update, name="flagit.update"),
]
Loading

0 comments on commit 8a157f7

Please sign in to comment.