mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 02:54:20 +00:00
pedagogy: allow to deny removal request for comment in moderation
This commit is contained in:
parent
04009a6a5b
commit
806084e707
@ -130,8 +130,16 @@ class UVCommentModerationForm(forms.Form):
|
|||||||
Form handeling bulk comment deletion
|
Form handeling bulk comment deletion
|
||||||
"""
|
"""
|
||||||
|
|
||||||
reports = forms.ModelMultipleChoiceField(
|
accepted_reports = forms.ModelMultipleChoiceField(
|
||||||
UVCommentReport.objects.all(),
|
UVCommentReport.objects.all(),
|
||||||
label=_("Reported comments"),
|
label=_("Accepted reports"),
|
||||||
widget=forms.CheckboxSelectMultiple,
|
widget=forms.CheckboxSelectMultiple,
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
denied_reports = forms.ModelMultipleChoiceField(
|
||||||
|
UVCommentReport.objects.all(),
|
||||||
|
label=_("Denied reports"),
|
||||||
|
widget=forms.CheckboxSelectMultiple,
|
||||||
|
required=False,
|
||||||
)
|
)
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
{% endblock title %}
|
{% endblock title %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<form action="{{ url('pedagogy:moderation') }}", id="moderation_form" method="post" enctype="multipart/form-data">
|
<form action="{{ url('pedagogy:moderation') }}", id="moderation_delete_form" method="post" enctype="multipart/form-data">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<p style="margin-bottom: 1em;">{{ select_all_checkbox("moderation_form") }}</p>
|
<p style="margin-bottom: 1em;">{{ select_all_checkbox("moderation_delete_form") }}</p>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -19,8 +19,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% set queryset = form.reports.field.queryset %}
|
{% set queryset = form.accepted_reports.field.queryset %}
|
||||||
{% for widget in form.reports.subwidgets %}
|
{% for widget in form.accepted_reports.subwidgets %}
|
||||||
{% set report = queryset.get(id=widget.data.value) %}
|
{% set report = queryset.get(id=widget.data.value) %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ report.comment.uv }}</td>
|
<td>{{ report.comment.uv }}</td>
|
||||||
@ -33,4 +33,31 @@
|
|||||||
</table>
|
</table>
|
||||||
<p><input type="submit" value="{% trans %}Delete comments{% endtrans %}"></p>
|
<p><input type="submit" value="{% trans %}Delete comments{% endtrans %}"></p>
|
||||||
</form>
|
</form>
|
||||||
|
<form action="{{ url('pedagogy:moderation') }}", id="moderation_keep_form" method="post" enctype="multipart/form-data">
|
||||||
|
{% csrf_token %}
|
||||||
|
<p style="margin-bottom: 1em;">{{ select_all_checkbox("moderation_keep_form") }}</p>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>{% trans %}UV{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Comment{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Reason{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Delete{% endtrans %}</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% set queryset = form.denied_reports.field.queryset %}
|
||||||
|
{% for widget in form.denied_reports.subwidgets %}
|
||||||
|
{% set report = queryset.get(id=widget.data.value) %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ report.comment.uv }}</td>
|
||||||
|
<td>{{ report.comment.comment|markdown }}</td>
|
||||||
|
<td>{{ report.reason|markdown }}</td>
|
||||||
|
<td>{{ widget.tag() }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<p><input type="submit" value="{% trans %}Delete report{% endtrans %}"></p>
|
||||||
|
</form>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
@ -247,8 +247,10 @@ class UVModerationFormView(FormView):
|
|||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
form_clean = form.clean()
|
form_clean = form.clean()
|
||||||
for report in form_clean.get("reports", []):
|
for report in form_clean.get("accepted_reports", []):
|
||||||
report.comment.delete()
|
report.comment.delete() # Delete the related comment
|
||||||
|
for report in form_clean.get("denied_reports", []):
|
||||||
|
report.delete() # Delete the report itself
|
||||||
return super(UVModerationFormView, self).form_valid(form)
|
return super(UVModerationFormView, self).form_valid(form)
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user