mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 06:03:20 +00:00
Improve SAS moderation interface
This commit is contained in:
parent
39b7349034
commit
57d8926a3f
@ -7,41 +7,28 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<h3>{% trans %}SAS moderation{% endtrans %}</h3>
|
<h3>{% trans %}SAS moderation{% endtrans %}</h3>
|
||||||
<div id="moderation">
|
<div id="moderation">
|
||||||
<form action="" method="POST" enctype="multipart/form-data">
|
<h4>{% trans %}Albums{% endtrans %}</h4>
|
||||||
{% csrf_token %}
|
<ul>
|
||||||
{% for p in pictures %}
|
{% for a in albums_to_moderate %}
|
||||||
<div style="">
|
<li>{{ a }}:
|
||||||
{% if p.is_folder %}
|
<form action="" method="POST">
|
||||||
<strong>{% trans %}Album{% endtrans %}</strong>
|
{% csrf_token %}
|
||||||
{% else %}
|
<input type="hidden" name="album_id" value="{{ a.id }}" />
|
||||||
<strong>{% trans %}Picture{% endtrans %}</strong>
|
<input type="submit" name="moderate" value="{% trans %}Moderate{% endtrans %}" />
|
||||||
{% endif %}
|
<input type="submit" name="delete" value="{% trans %}Delete{% endtrans %}" />
|
||||||
<p>
|
</form>
|
||||||
<a href="{{ url("sas:picture", picture_id=p.id) }}">
|
</li>
|
||||||
<img src="{{ p.get_download_compressed_url() }}" alt="{{ p.name }}">
|
{% endfor %}
|
||||||
</a><br/>
|
</ul>
|
||||||
{% trans %}Full name: {% endtrans %}{{ p.get_parent_path()+'/'+p.name }}<br/>
|
{% for a in albums %}
|
||||||
{% trans %}Owner: {% endtrans %}{{ p.owner.get_display_name() }}<br/>
|
<h4>{{ a.get_display_name() }}</h4>
|
||||||
{% trans %}Date: {% endtrans %}{{ p.date|date(DATE_FORMAT) }} {{ p.date|time(TIME_FORMAT) }}<br/>
|
{% for p in pictures.filter(parent=a).order_by('id') %}
|
||||||
</p>
|
<div class="picture">
|
||||||
{% if p.asked_for_removal %}
|
<a href="{{ url("sas:picture", picture_id=p.id) }}">
|
||||||
<p class="important">{% trans %}Asked for removal{% endtrans %}</p>
|
<img src="{{ p.get_download_thumb_url() }}" alt="{{ p.name }}">
|
||||||
{% endif %}
|
</a>
|
||||||
<p>
|
|
||||||
<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="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>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<p><input type="submit" value="{% trans %}Go{% endtrans %}" /></p>
|
{% endfor %}
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -78,7 +78,9 @@
|
|||||||
<h5>{% trans %}Infos{% endtrans %}</h5>
|
<h5>{% trans %}Infos{% endtrans %}</h5>
|
||||||
<p>{% trans %}Date: {% endtrans %}{{ picture.date|date(DATETIME_FORMAT) }}</p>
|
<p>{% trans %}Date: {% endtrans %}{{ picture.date|date(DATETIME_FORMAT) }}</p>
|
||||||
<p>{% trans %}Owner: {% endtrans %}<a href="{{ picture.owner.get_absolute_url() }}">{{ picture.owner.get_short_name() }}</a></p>
|
<p>{% trans %}Owner: {% endtrans %}<a href="{{ picture.owner.get_absolute_url() }}">{{ picture.owner.get_short_name() }}</a></p>
|
||||||
|
{% if picture.moderator %}
|
||||||
<p>{% trans %}Moderator: {% endtrans %}<a href="{{ picture.moderator.get_absolute_url() }}">{{ picture.moderator.get_short_name() }}</a></p>
|
<p>{% trans %}Moderator: {% endtrans %}<a href="{{ picture.moderator.get_absolute_url() }}">{{ picture.moderator.get_short_name() }}</a></p>
|
||||||
|
{% endif %}
|
||||||
<p>{{ picture.parent.children.filter(id__lte=picture.id).count() }} / {{ picture.parent.children.count() }}</p>
|
<p>{{ picture.parent.children.filter(id__lte=picture.id).count() }} / {{ picture.parent.children.count() }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@ -105,6 +107,9 @@
|
|||||||
{% set next = next.get_absolute_url() + "#pict" %}
|
{% set next = next.get_absolute_url() + "#pict" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div style="background: lightgrey; padding: 2px;">
|
<div style="background: lightgrey; padding: 2px;">
|
||||||
|
{% if picture.asked_for_removal %}
|
||||||
|
<span class="important">{% trans %}Asked for removal{% endtrans %}</span>
|
||||||
|
{% endif %}
|
||||||
<a href="{{ url('core:file_moderate', file_id=picture.id) }}?next={{ next }}">
|
<a href="{{ url('core:file_moderate', file_id=picture.id) }}?next={{ next }}">
|
||||||
{% trans %}Moderate{% endtrans %}</a> |
|
{% trans %}Moderate{% endtrans %}</a> |
|
||||||
<a href="{{ url('core:file_delete', file_id=picture.id) }}?next={{ next }}">
|
<a href="{{ url('core:file_delete', file_id=picture.id) }}?next={{ next }}">
|
||||||
|
33
sas/views.py
33
sas/views.py
@ -41,6 +41,8 @@ class SASForm(forms.Form):
|
|||||||
for f in files:
|
for f in files:
|
||||||
new_file = Picture(parent=parent, name=f.name, file=f, owner=owner, mime_type=f.content_type, size=f._size,
|
new_file = Picture(parent=parent, name=f.name, file=f, owner=owner, mime_type=f.content_type, size=f._size,
|
||||||
is_folder=False, is_moderated=automodere)
|
is_folder=False, is_moderated=automodere)
|
||||||
|
if automodere:
|
||||||
|
new_file.moderator = owner
|
||||||
try:
|
try:
|
||||||
new_file.clean()
|
new_file.clean()
|
||||||
new_file.generate_thumbnails()
|
new_file.generate_thumbnails()
|
||||||
@ -193,26 +195,28 @@ class ModerationView(TemplateView):
|
|||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
if request.user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID):
|
if request.user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID):
|
||||||
for k,v in request.GET.items():
|
|
||||||
if k[:2] == "a_":
|
|
||||||
try:
|
|
||||||
pict = Picture.objects.filter(id=int(k[2:])).first()
|
|
||||||
if v == "delete":
|
|
||||||
pict.delete()
|
|
||||||
elif v == "moderate":
|
|
||||||
pict.is_moderated = True
|
|
||||||
pict.asked_for_removal = False
|
|
||||||
pict.save()
|
|
||||||
except: pass
|
|
||||||
return super(ModerationView, self).get(request, *args, **kwargs)
|
return super(ModerationView, self).get(request, *args, **kwargs)
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
return self.get(request, *args, **kwargs)
|
if request.user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID):
|
||||||
|
try:
|
||||||
|
a = Album.objects.filter(id=request.POST['album_id']).first()
|
||||||
|
if 'moderate' in request.POST.keys():
|
||||||
|
a.moderator = request.user
|
||||||
|
a.is_moderated = True
|
||||||
|
a.save()
|
||||||
|
elif 'delete' in request.POST.keys():
|
||||||
|
a.delete()
|
||||||
|
except: pass
|
||||||
|
return super(ModerationView, self).get(request, *args, **kwargs)
|
||||||
|
|
||||||
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'] = Picture.objects.filter(is_moderated=False, is_in_sas=True).order_by('id')
|
kwargs['albums_to_moderate'] = Album.objects.filter(is_moderated=False, is_in_sas=True,
|
||||||
|
is_folder=True).order_by('id')
|
||||||
|
kwargs['pictures'] = Picture.objects.filter(is_moderated=False, is_in_sas=True, is_folder=False)
|
||||||
|
kwargs['albums'] = Album.objects.filter(id__in=kwargs['pictures'].values('parent').distinct('parent'))
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
class PictureEditForm(forms.ModelForm):
|
class PictureEditForm(forms.ModelForm):
|
||||||
@ -224,8 +228,9 @@ class PictureEditForm(forms.ModelForm):
|
|||||||
class AlbumEditForm(forms.ModelForm):
|
class AlbumEditForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Album
|
model = Album
|
||||||
fields=['name', 'file', 'parent']
|
fields=['name', 'file', 'parent', 'edit_groups']
|
||||||
parent = make_ajax_field(Album, 'parent', 'files', help_text="")
|
parent = make_ajax_field(Album, 'parent', 'files', help_text="")
|
||||||
|
edit_groups = make_ajax_field(Album, 'edit_groups', 'groups', help_text="")
|
||||||
|
|
||||||
class PictureEditView(CanEditMixin, UpdateView):
|
class PictureEditView(CanEditMixin, UpdateView):
|
||||||
model=Picture
|
model=Picture
|
||||||
|
Loading…
Reference in New Issue
Block a user