mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Improve moderation tool in SAS
This commit is contained in:
parent
e681cc65fe
commit
b619619b85
@ -58,13 +58,16 @@
|
|||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{% if user.is_in_group(settings.SITH_GROUPS['communication-admin']['id']) %}
|
|
||||||
<hr>
|
<hr>
|
||||||
<h4>{% trans %}Communication{% endtrans %}</h4>
|
<h4>{% trans %}Communication{% endtrans %}</h4>
|
||||||
<ul>
|
<ul>
|
||||||
|
{% if user.is_in_group(settings.SITH_GROUPS['communication-admin']['id']) %}
|
||||||
<li><a href="{{ url('core:file_moderation') }}">{% trans %}Moderate files{% endtrans %}</a></li>
|
<li><a href="{{ url('core:file_moderation') }}">{% trans %}Moderate files{% endtrans %}</a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% if user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID) %}
|
||||||
|
<li><a href="{{ url('sas:moderation') }}">{% trans %}Moderate pictures{% endtrans %}</a></li>
|
||||||
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
@ -51,7 +51,7 @@ urlpatterns = [
|
|||||||
url(r'^file/(?P<file_id>[0-9]+)/prop/(?P<popup>popup)?$', FileEditPropView.as_view(), name='file_prop'),
|
url(r'^file/(?P<file_id>[0-9]+)/prop/(?P<popup>popup)?$', FileEditPropView.as_view(), name='file_prop'),
|
||||||
url(r'^file/(?P<file_id>[0-9]+)/delete/(?P<popup>popup)?$', FileDeleteView.as_view(), name='file_delete'),
|
url(r'^file/(?P<file_id>[0-9]+)/delete/(?P<popup>popup)?$', FileDeleteView.as_view(), name='file_delete'),
|
||||||
url(r'^file/moderation$', FileModerationView.as_view(), name='file_moderation'),
|
url(r'^file/moderation$', FileModerationView.as_view(), name='file_moderation'),
|
||||||
url(r'^file/(?P<file_id>[0-9]+)/moderate?$', FileModerateView.as_view(), name='file_moderate'),
|
url(r'^file/(?P<file_id>[0-9]+)/moderate$', FileModerateView.as_view(), name='file_moderate'),
|
||||||
url(r'^file/(?P<file_id>[0-9]+)/download$', send_file, name='download'),
|
url(r'^file/(?P<file_id>[0-9]+)/download$', send_file, name='download'),
|
||||||
|
|
||||||
# Page views
|
# Page views
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<h3>{% trans %}SAS moderation{% endtrans %}</h3>
|
<h3>{% trans %}SAS moderation{% endtrans %}</h3>
|
||||||
<div>
|
<div>
|
||||||
|
<form action="" method="get" enctype="multipart/form-data">
|
||||||
{% for p in pictures %}
|
{% for p in pictures %}
|
||||||
<div style="margin: 2px; padding: 2px; border: solid 1px red; text-align: center">
|
<div style="margin: 2px; padding: 2px; border: solid 1px red; text-align: center">
|
||||||
{% if p.is_folder %}
|
{% if p.is_folder %}
|
||||||
@ -22,9 +23,17 @@
|
|||||||
{% trans %}Owner: {% endtrans %}{{ p.owner.get_display_name() }}<br/>
|
{% trans %}Owner: {% endtrans %}{{ p.owner.get_display_name() }}<br/>
|
||||||
{% trans %}Date: {% endtrans %}{{ p.date|date(DATE_FORMAT) }} {{ p.date|time(TIME_FORMAT) }}<br/>
|
{% trans %}Date: {% endtrans %}{{ p.date|date(DATE_FORMAT) }} {{ p.date|time(TIME_FORMAT) }}<br/>
|
||||||
</p>
|
</p>
|
||||||
<p><a href="{{ url('core:file_moderate', file_id=p.id) }}?next={{ url('sas:moderation') }}">{% trans %}Moderate{% endtrans %}</a> -
|
<p>
|
||||||
<a href="{{ url('core:file_delete', file_id=p.id) }}?next={{ url('sas:moderation') }}">{% trans %}Delete{% endtrans %}</a></p>
|
<input type="radio" name="action_{{ 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"/>
|
||||||
|
<a href="{{ url('core:file_delete', file_id=p.id) }}?next={{ url('sas:moderation') }}">{% trans %}Delete{% endtrans %}</a>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
<p><input type="submit" value="{% trans %}Go{% endtrans %}" /></p>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
18
sas/views.py
18
sas/views.py
@ -6,6 +6,7 @@ from django.utils.translation import ugettext as _
|
|||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from django.core.exceptions import PermissionDenied
|
||||||
|
|
||||||
from ajax_select.fields import AutoCompleteSelectField, AutoCompleteSelectMultipleField
|
from ajax_select.fields import AutoCompleteSelectField, AutoCompleteSelectMultipleField
|
||||||
|
|
||||||
@ -109,9 +110,24 @@ class AlbumView(CanViewMixin, DetailView, FormMixin):
|
|||||||
class ModerationView(TemplateView):
|
class ModerationView(TemplateView):
|
||||||
template_name = "sas/moderation.jinja"
|
template_name = "sas/moderation.jinja"
|
||||||
|
|
||||||
|
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_":
|
||||||
|
try:
|
||||||
|
pict = Picture.objects.filter(id=int(k[7:])).first()
|
||||||
|
if v == "delete":
|
||||||
|
pict.delete()
|
||||||
|
elif v == "moderate":
|
||||||
|
pict.is_moderated = True
|
||||||
|
pict.save()
|
||||||
|
except: pass
|
||||||
|
return super(ModerationView, self).get(request, *args, **kwargs)
|
||||||
|
raise PermissionDenied
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs = super(ModerationView, self).get_context_data(**kwargs)
|
kwargs = super(ModerationView, self).get_context_data(**kwargs)
|
||||||
kwargs['pictures'] = [p for p in Picture.objects.filter(is_moderated=False).all() if p.is_in_sas]
|
kwargs['pictures'] = [p for p in Picture.objects.filter(is_moderated=False).order_by('id') if p.is_in_sas]
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user