Commit a02d5a65 authored by Skia's avatar Skia

Improve a bit SAS moderation

parent 80fa99d2
Pipeline #483 passed with stage
in 2 minutes and 45 seconds
This diff is collapsed.
......@@ -7,7 +7,8 @@
{% block content %}
<h3>{% trans %}SAS moderation{% endtrans %}</h3>
<div>
<form action="" method="get" enctype="multipart/form-data">
<form action="" method="POST" enctype="multipart/form-data">
{% csrf_token %}
{% for p in pictures %}
<div style="margin: 2px; padding: 2px; border: solid 1px red; text-align: center">
{% if p.is_folder %}
......@@ -27,13 +28,17 @@
<p class="important">{% trans %}Asked for removal{% endtrans %}</p>
{% endif %}
<p>
<input type="radio" name="action_{{ p.id }}" id="m_{{ p.id }}" value="moderate"/>
<input type="radio" name="a_{{ p.id }}" id="m_{{ p.id }}" value="moderate"/>
<a href="{{ url('core:file_moderate', file_id=p.id) }}?next={{ url('sas:moderation') }}">{% trans %}Moderate{% endtrans %}</a>
</p>
<p>
<input type="radio" name="action_{{ p.id }}" id="m_{{ p.id }}" value="delete"/>
<input type="radio" name="a_{{ p.id }}" id="m_{{ p.id }}" value="delete"/>
<a href="{{ url('core:file_delete', file_id=p.id) }}?next={{ url('sas:moderation') }}">{% trans %}Delete{% endtrans %}</a>
</p>
<p>
<input type="radio" name="a_{{ p.id }}" id="m_{{ p.id }}" value="nothing" checked/>
{% trans %}Do nothing{% endtrans %}
</p>
</div>
{% endfor %}
<p><input type="submit" value="{% trans %}Go{% endtrans %}" /></p>
......
......@@ -189,9 +189,9 @@ class ModerationView(TemplateView):
def get(self, request, *args, **kwargs):
if request.user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID):
for k,v in request.GET.items():
if k[:7] == "action_":
if k[:2] == "a_":
try:
pict = Picture.objects.filter(id=int(k[7:])).first()
pict = Picture.objects.filter(id=int(k[2:])).first()
if v == "delete":
pict.delete()
elif v == "moderate":
......@@ -202,6 +202,9 @@ class ModerationView(TemplateView):
return super(ModerationView, self).get(request, *args, **kwargs)
raise PermissionDenied
def post(self, request, *args, **kwargs):
return self.get(request, *args, **kwargs)
def get_context_data(self, **kwargs):
kwargs = super(ModerationView, self).get_context_data(**kwargs)
kwargs['pictures'] = Picture.objects.filter(is_moderated=False, is_in_sas=True).order_by('id')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment