Skip to content

Commit 8a157f7

Browse files
authored
Merge pull request #6354 from akatsoulas/extract-moderation-tool
Extract moderation tool to a separate url
2 parents 345ec81 + 1c98787 commit 8a157f7

File tree

10 files changed

+230
-135
lines changed

10 files changed

+230
-135
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{% extends "flagit/flagit_base.html" %}
2+
3+
{% block flagged_items %}
4+
{% for object in objects %}
5+
<li class="{{ object.content_type }}">
6+
<div class="flagged-item-content">
7+
<hgroup>
8+
<h2 class="sumo-card-heading">{{ _('Flagged {t} (Reason: {r})')|f(t=object.content_type, r=object.get_reason_display()) }}</h2>
9+
{% if object.notes %}
10+
<p class="notes">{{ _('Other reason:') }} {{ object.notes }}</p>
11+
{% endif %}
12+
</hgroup>
13+
<div class="wrap">
14+
{% if object.content_object %}
15+
{% include 'flagit/includes/flagged_%s.html' % object.content_type.model %}
16+
{% else %}
17+
<p>{{ _('{t} with id={id} no longer exists.')|f(t=object.content_type, id=object.object_id) }}</p>
18+
{% endif %}
19+
<h3 class="sumo-card-heading"><br>{{ _('Update Status:') }}</h3>
20+
<form class="update inline-form" action="{{ object.form_action }}" method="post">
21+
{% csrf_token %}
22+
<select name="status">
23+
<option value="">{{ _('Please select...') }}</option>
24+
<option value="1">{{ _('Content categorization is updated.') }}</option>
25+
<option value="2">{{ _('Content is appropriately categorized.') }}</option>
26+
</select>
27+
<input id="update-status-button-{{ object.content_object.id }}" type="submit"
28+
class="sumo-button primary-button button-lg btn" value={{ _('Update') }} />
29+
</form>
30+
</div>
31+
</div>
32+
</li>
33+
{% else %}
34+
<p>{{ _('There is no content pending moderation.') }}</p>
35+
{% endfor %}
36+
{% endblock %}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{% extends "questions/base.html" %} {# TODO: liberate - remove questions dependency #}
2+
{% from "includes/common_macros.html" import for_contributors_sidebar %}
3+
{% set title = _('Flagged Content Pending Moderation') %}
4+
{% set classes = 'flagged' %}
5+
{% set scripts = ('flagit', ) %}
6+
7+
{% block content %}
8+
<div id="flagged-queue" class="sumo-page-section">
9+
<h1 class="sumo-page-heading">{{ _('Content Pending Moderation') }}</h1>
10+
11+
<ul class="flagged-items">
12+
{% block flagged_items %}
13+
{% endblock %}
14+
</ul>
15+
{% block deactivation_log %}
16+
<div class="sumo-button-wrap"></div>
17+
<a class="sumo-button primary-button" rel="nofollow" href="{{ url('users.deactivation_log') }}">{{ _('View all deactivated users') }}</a>
18+
</div>
19+
{% endblock %}
20+
</div>
21+
{% endblock %}
22+
23+
{% block side_top %}
24+
<nav id="doc-tools">
25+
<ul class="sidebar-nav sidebar-folding">
26+
{{ for_contributors_sidebar(user, settings.WIKI_DEFAULT_LANGUAGE, active="flagit.flagged_queue", menu="contributor-tools", locale=locale) }}
27+
</ul>
28+
29+
{% block side_top_reason %}
30+
{% endblock %}
31+
</nav>
32+
{% endblock %}

kitsune/flagit/jinja2/flagit/includes/flagged_question.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ <h3 class="flagged-content__subheading">{{ _('Updated:') }}</h3>
2121
<h3 class="flagged-content__subheading">{{ _('Flagged:') }}</h3>
2222
<p>{{ date_by_user(object.created, object.creator) }}</p>
2323

24-
{% if object.reason == 'bug_support' and question_model and user.has_perm('questions.change_question') %}
24+
{% if object.reason == 'content_moderation' and question_model and user.has_perm('questions.change_question') %}
2525
<h3 class="flagged-content__subheading">{{ _('Take Action:') }}</h3>
2626
<div class="flagged-content__topic-update">
2727
<label> {{ _('Current topic:') }} </label>
Lines changed: 60 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,65 @@
1-
{% extends "questions/base.html" %} {# TODO: liberate - remove questions dependency #}
2-
{% from "includes/common_macros.html" import for_contributors_sidebar %}
3-
{% set title = _('Flagged Content Pending Moderation') %}
4-
{% set classes = 'flagged' %}
5-
{% set scripts = ('flagit', ) %}
1+
{% extends "flagit/flagit_base.html" %}
62

7-
{% block content %}
8-
<div id="flagged-queue" class="sumo-page-section">
9-
<h1 class="sumo-page-heading">{{ _('Content Pending Moderation') }}</h1>
10-
11-
<ul class="flagged-items">
12-
{% for object in objects %}
13-
<li class="{{ object.content_type }}">
14-
<div class="flagged-item-content">
15-
<hgroup>
16-
<h2 class="sumo-card-heading">{{ _('Flagged {t} (Reason: {r})')|f(t=object.content_type, r=object.get_reason_display()) }}</h2>
17-
{% if object.notes %}
18-
<p class="notes">{{ _('Other reason:') }} {{ object.notes }}</p>
19-
{% endif %}
20-
</hgroup>
21-
<div class="wrap">
22-
{% if object.content_object %}
23-
{% include 'flagit/includes/flagged_%s.html' % object.content_type.model %}
24-
{% else %}
25-
<p>{{ _('{t} with id={id} no longer exists.')|f(t=object.content_type, id=object.object_id) }}</p>
26-
{% endif %}
27-
<h3 class="sumo-card-heading"><br>{{ _('Update Status:') }}</h3>
28-
<form class="update inline-form" action="{{ object.form_action }}" method="post">
29-
{% csrf_token %}
30-
<select name="status">
31-
<option value="">{{ _('Please select...') }}</option>
32-
{% if object.reason == "spam" %}
33-
<option value="1">{{ _('Removed spam content.') }}</option>
34-
<option value="2">{{ _('No spam found.') }}</option>
35-
{% elif object.reason == "abuse" %}
36-
<option value="1">{{ _('Addressed abusive content.') }}</option>
37-
<option value="2">{{ _('No abuse detected.') }}</option>
38-
{% elif object.reason == "bug_support" %}
39-
<option value="1">{{ _('Redirected support request.') }}</option>
40-
<option value="2">{{ _('Content is appropriately placed.') }}</option>
41-
{% elif object.reason == "language" %}
42-
<option value="1">{{ _('Corrected language.') }}</option>
43-
<option value="2">{{ _('Language is appropriate.') }}</option>
44-
{% else %}
45-
<option value="1">{{ _('Issue resolved.') }}</option>
46-
<option value="2">{{ _('No issues found.') }}</option>
47-
{% endif %}
48-
</select>
49-
<input id="update-status-button-{{ object.content_object.id }}" type="submit"
50-
class="sumo-button primary-button button-lg btn" value={{ _('Update') }} />
51-
</form>
52-
</div>
3+
{% block flagged_items %}
4+
{% for object in objects %}
5+
<li class="{{ object.content_type }}">
6+
<div class="flagged-item-content">
7+
<hgroup>
8+
<h2 class="sumo-card-heading">{{ _('Flagged {t} (Reason: {r})')|f(t=object.content_type, r=object.get_reason_display()) }}</h2>
9+
{% if object.notes %}
10+
<p class="notes">{{ _('Other reason:') }} {{ object.notes }}</p>
11+
{% endif %}
12+
</hgroup>
13+
<div class="wrap">
14+
{% if object.content_object %}
15+
{% include 'flagit/includes/flagged_%s.html' % object.content_type.model %}
16+
{% else %}
17+
<p>{{ _('{t} with id={id} no longer exists.')|f(t=object.content_type, id=object.object_id) }}</p>
18+
{% endif %}
19+
<h3 class="sumo-card-heading"><br>{{ _('Update Status:') }}</h3>
20+
<form class="update inline-form" action="{{ object.form_action }}" method="post">
21+
{% csrf_token %}
22+
<select name="status">
23+
<option value="">{{ _('Please select...') }}</option>
24+
{% if object.reason == "spam" %}
25+
<option value="1">{{ _('Removed spam content.') }}</option>
26+
<option value="2">{{ _('No spam found.') }}</option>
27+
{% elif object.reason == "abuse" %}
28+
<option value="1">{{ _('Addressed abusive content.') }}</option>
29+
<option value="2">{{ _('No abuse detected.') }}</option>
30+
{% elif object.reason == "bug_support" %}
31+
<option value="1">{{ _('Request moved.') }}</option>
32+
<option value="2">{{ _('Request is appropriately placed.') }}</option>
33+
{% elif object.reason == "language" %}
34+
<option value="1">{{ _('Corrected language.') }}</option>
35+
<option value="2">{{ _('Language is appropriate.') }}</option>
36+
{% else %}
37+
<option value="1">{{ _('Issue resolved.') }}</option>
38+
<option value="2">{{ _('No issues found.') }}</option>
39+
{% endif %}
40+
</select>
41+
<input id="update-status-button-{{ object.content_object.id }}" type="submit"
42+
class="sumo-button primary-button button-lg btn" value={{ _('Update') }} />
43+
</form>
5344
</div>
54-
</li>
55-
{% else %}
56-
<p>{{ _('There is no content pending moderation.') }}</p>
57-
{% endfor %}
58-
</ul>
59-
60-
<div class="sumo-button-wrap">
61-
<a class="sumo-button primary-button" rel="nofollow" href="{{ url('users.deactivation_log') }}">{{ _('View all deactivated users') }}</a>
62-
</div>
63-
</div>
45+
</div>
46+
</li>
47+
{% else %}
48+
<p>{{ _('There is no content pending moderation.') }}</p>
49+
{% endfor %}
6450
{% endblock %}
6551

66-
{% block side_top %}
67-
<nav id="doc-tools">
68-
<ul class="sidebar-nav sidebar-folding">
69-
{{ for_contributors_sidebar(user, settings.WIKI_DEFAULT_LANGUAGE, active="flagit.flagged_queue", menu="contributor-tools", locale=locale) }}
70-
</ul>
71-
<!-- Dropdown filter for reasons -->
72-
<div class="filter-reasons">
73-
<form id="reason-filter-form" method="get" action="">
74-
<label for="reason">{{ _('Filter by reason:') }}</label>
75-
<select name="reason" id="flagit-reason-filter">
76-
<option value="">{{ _('All reasons') }}</option>
77-
{% for value, display in reasons %}
78-
<option value="{{ value }}" {% if selected_reason == value %}selected{% endif %}>{{ display }}</option>
79-
{% endfor %}
80-
</select>
81-
</form>
82-
</div>
83-
</nav>
52+
{% block side_top_reason %}
53+
<!-- Dropdown filter for reasons -->
54+
<div class="filter-reasons">
55+
<form id="reason-filter-form" method="get" action="">
56+
<label for="reason">{{ _('Filter by reason:') }}</label>
57+
<select name="reason" id="flagit-reason-filter">
58+
<option value="">{{ _('All reasons') }}</option>
59+
{% for value, display in reasons %}
60+
<option value="{{ value }}" {% if selected_reason == value %}selected{% endif %}>{{ display }}</option>
61+
{% endfor %}
62+
</select>
63+
</form>
64+
</div>
8465
{% endblock %}

kitsune/flagit/models.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ def pending(self):
1818
class FlaggedObject(ModelBase):
1919
"""A flag raised on an object."""
2020

21+
REASON_SPAM = "spam"
22+
REASON_LANGUAGE = "language"
23+
REASON_BUG_SUPPORT = "bug_support"
24+
REASON_ABUSE = "abuse"
25+
REASON_CONTENT_MODERATION = "content_moderation"
26+
REASON_OTHER = "other"
2127
REASONS = (
22-
("spam", _lazy("Spam or other unrelated content")),
23-
("language", _lazy("Inappropriate language/dialog")),
24-
("bug_support", _lazy("Misplaced bug report or support request")),
25-
("abuse", _lazy("Abusive content")),
26-
("other", _lazy("Other (please specify)")),
28+
(REASON_SPAM, _lazy("Spam or other unrelated content")),
29+
(REASON_LANGUAGE, _lazy("Inappropriate language/dialog")),
30+
(REASON_BUG_SUPPORT, _lazy("Misplaced bug report or support request")),
31+
(REASON_ABUSE, _lazy("Abusive content")),
32+
(REASON_OTHER, _lazy("Other (please specify)")),
2733
)
2834

2935
FLAG_PENDING = 0

kitsune/flagit/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

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

0 commit comments

Comments
 (0)