From b53531c3916fa1280909638d232206ccd4a96911 Mon Sep 17 00:00:00 2001
From: Skia
Date: Fri, 9 Dec 2016 19:35:23 +0100
Subject: [PATCH] Add another method to moderate pictures in SAS
---
core/static/core/style.css | 6 ++++++
sas/models.py | 15 +++++++++++----
sas/templates/sas/picture.jinja | 18 +++++++++++++++++-
3 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/core/static/core/style.css b/core/static/core/style.css
index 4d0548d0..1dd0c8bc 100644
--- a/core/static/core/style.css
+++ b/core/static/core/style.css
@@ -298,6 +298,12 @@ tbody>tr:hover {
#moderation img {
width: 500px;
}
+#pict {
+ display: inline-block;
+ width: 80%;
+ background: #333;
+ border: solid #333 2px;
+}
/*---------------------------------PAGE--------------------------------*/
.page_content {
display: block;
diff --git a/sas/models.py b/sas/models.py
index 0cf5d364..e999739f 100644
--- a/sas/models.py
+++ b/sas/models.py
@@ -69,12 +69,18 @@ class Picture(SithFile):
im.save(fp=file, format=self.mime_type.split('/')[-1].upper(), quality=90, optimize=True, progressive=True)
def get_next(self):
- return self.parent.children.filter(is_moderated=True, asked_for_removal=False, is_folder=False,
- id__gt=self.id).order_by('id').first()
+ if self.is_moderated:
+ return self.parent.children.filter(is_moderated=True, asked_for_removal=False, is_folder=False,
+ 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):
- return self.parent.children.filter(is_moderated=True, asked_for_removal=False, is_folder=False,
- id__lt=self.id).order_by('id').last()
+ if self.is_moderated:
+ return self.parent.children.filter(is_moderated=True, asked_for_removal=False, is_folder=False,
+ 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 Meta:
@@ -84,6 +90,7 @@ class Album(SithFile):
return user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID)
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
user.is_in_group(settings.SITH_MAIN_MEMBERS_GROUP))
diff --git a/sas/templates/sas/picture.jinja b/sas/templates/sas/picture.jinja
index cc2eed9c..3cef6a53 100644
--- a/sas/templates/sas/picture.jinja
+++ b/sas/templates/sas/picture.jinja
@@ -92,7 +92,23 @@
-
+{% if picture.is_moderated %}
+
+{% else %}
+
+{% set next = picture.get_next() %}
+{% if not next %}
+ {% set next = url('sas:moderation') %}
+{% else %}
+ {% set next = next.get_absolute_url() + "#pict" %}
+{% endif %}
+
+{% endif %}
{% if picture.is_vertical %}
![{{ picture.get_display_name() }}]({{ picture.get_download_compressed_url() }})
{% else %}