Add another method to moderate pictures in SAS

This commit is contained in:
Skia 2016-12-09 19:35:23 +01:00
parent 66d73d69ec
commit b53531c391
3 changed files with 34 additions and 5 deletions

View File

@ -298,6 +298,12 @@ tbody>tr:hover {
#moderation img { #moderation img {
width: 500px; width: 500px;
} }
#pict {
display: inline-block;
width: 80%;
background: #333;
border: solid #333 2px;
}
/*---------------------------------PAGE--------------------------------*/ /*---------------------------------PAGE--------------------------------*/
.page_content { .page_content {
display: block; display: block;

View File

@ -69,12 +69,18 @@ class Picture(SithFile):
im.save(fp=file, format=self.mime_type.split('/')[-1].upper(), quality=90, optimize=True, progressive=True) im.save(fp=file, format=self.mime_type.split('/')[-1].upper(), quality=90, optimize=True, progressive=True)
def get_next(self): def get_next(self):
if self.is_moderated:
return self.parent.children.filter(is_moderated=True, asked_for_removal=False, is_folder=False, return self.parent.children.filter(is_moderated=True, asked_for_removal=False, is_folder=False,
id__gt=self.id).order_by('id').first() id__gt=self.id).order_by('id').first()
else:
return Picture.objects.filter(id__gt=self.id, is_moderated=False, is_in_sas=True).order_by('id').first()
def get_previous(self): def get_previous(self):
if self.is_moderated:
return self.parent.children.filter(is_moderated=True, asked_for_removal=False, is_folder=False, return self.parent.children.filter(is_moderated=True, asked_for_removal=False, is_folder=False,
id__lt=self.id).order_by('id').last() id__lt=self.id).order_by('id').last()
else:
return Picture.objects.filter(id__lt=self.id, is_moderated=False, is_in_sas=True).order_by('-id').first()
class Album(SithFile): class Album(SithFile):
class Meta: class Meta:
@ -84,6 +90,7 @@ class Album(SithFile):
return user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID) return user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID)
def can_be_viewed_by(self, user): def can_be_viewed_by(self, user):
print(self.is_in_sas)
return self.can_be_edited_by(user) or (self.is_in_sas and self.is_moderated and return self.can_be_edited_by(user) or (self.is_in_sas and self.is_moderated and
user.is_in_group(settings.SITH_MAIN_MEMBERS_GROUP)) user.is_in_group(settings.SITH_MAIN_MEMBERS_GROUP))

View File

@ -92,7 +92,23 @@
</p> </p>
</div> </div>
</div> </div>
<div style="display: inline-block; width: 80%; background: #333; border: solid #333 2px;" id="pict"> {% if picture.is_moderated %}
<div id="pict">
{% else %}
<div id="pict" style="border: solid #f00 2px;">
{% set next = picture.get_next() %}
{% if not next %}
{% set next = url('sas:moderation') %}
{% else %}
{% set next = next.get_absolute_url() + "#pict" %}
{% endif %}
<div style="background: lightgrey; padding: 2px;">
<a href="{{ url('core:file_moderate', file_id=picture.id) }}?next={{ next }}">
{% trans %}Moderate{% endtrans %}</a> |
<a href="{{ url('core:file_delete', file_id=picture.id) }}?next={{ next }}">
{% trans %}Delete{% endtrans %}</a>
</div>
{% endif %}
{% if picture.is_vertical %} {% if picture.is_vertical %}
<img src="{{ picture.get_download_compressed_url() }}" alt="{{ picture.get_display_name() }}" style="width: 60%; display: block; margin: auto"/> <img src="{{ picture.get_download_compressed_url() }}" alt="{{ picture.get_display_name() }}" style="width: 60%; display: block; margin: auto"/>
{% else %} {% else %}