diff --git a/core/migrations/0008_sithfile_asked_for_removal.py b/core/migrations/0008_sithfile_asked_for_removal.py new file mode 100644 index 00000000..a5fa30f7 --- /dev/null +++ b/core/migrations/0008_sithfile_asked_for_removal.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0007_auto_20161108_1703'), + ] + + operations = [ + migrations.AddField( + model_name='sithfile', + name='asked_for_removal', + field=models.BooleanField(default=False, verbose_name='asked for removal'), + ), + ] diff --git a/core/models.py b/core/models.py index 1e1c66e4..901e3e59 100644 --- a/core/models.py +++ b/core/models.py @@ -503,6 +503,7 @@ class SithFile(models.Model): size = models.IntegerField(_("size"), default=0) date = models.DateTimeField(_('date'), auto_now=True) is_moderated = models.BooleanField(_("is moderated"), default=False) + asked_for_removal = models.BooleanField(_("asked for removal"), default=False) class Meta: verbose_name = _("file") diff --git a/core/views/__init__.py b/core/views/__init__.py index 66f27717..aeaceb08 100644 --- a/core/views/__init__.py +++ b/core/views/__init__.py @@ -58,6 +58,8 @@ class CanEditPropMixin(View): """ def dispatch(self, request, *arg, **kwargs): res = super(CanEditPropMixin, self).dispatch(request, *arg, **kwargs) + if res.__class__.status_code == 302: + return res if hasattr(self, 'object'): obj = self.object elif hasattr(self, 'object_list'): @@ -76,6 +78,8 @@ class CanEditMixin(View): """ def dispatch(self, request, *arg, **kwargs): res = super(CanEditMixin, self).dispatch(request, *arg, **kwargs) + if res.__class__.status_code == 302: + return res if hasattr(self, 'object'): obj = self.object elif hasattr(self, 'object_list'): @@ -94,6 +98,8 @@ class CanViewMixin(View): """ def dispatch(self, request, *arg, **kwargs): res = super(CanViewMixin, self).dispatch(request, *arg, **kwargs) + if res.__class__.status_code == 302: + return res if hasattr(self, 'object'): obj = self.object elif hasattr(self, 'object_list'): diff --git a/sas/migrations/0002_auto_20161119_1241.py b/sas/migrations/0002_auto_20161119_1241.py new file mode 100644 index 00000000..ff51d24c --- /dev/null +++ b/sas/migrations/0002_auto_20161119_1241.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +from django.conf import settings + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('sas', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='PeoplePictureRelation', + fields=[ + ('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)), + ('picture', models.ForeignKey(related_name='people', to='sas.Picture', verbose_name='picture')), + ('user', models.ForeignKey(related_name='pictures', to=settings.AUTH_USER_MODEL, verbose_name='user')), + ], + ), + migrations.AlterUniqueTogether( + name='peoplepicturerelation', + unique_together=set([('user', 'picture')]), + ), + ] diff --git a/sas/models.py b/sas/models.py index 08bfc567..7a786797 100644 --- a/sas/models.py +++ b/sas/models.py @@ -1,6 +1,7 @@ from django.db import models from django.conf import settings from django.core.urlresolvers import reverse +from django.utils.translation import ugettext_lazy as _ from core.models import SithFile, User @@ -23,6 +24,12 @@ class Picture(SithFile): def get_download_url(self): return reverse('sas:download', kwargs={'picture_id': self.id}) + def get_next(self): + return self.parent.children.exclude(is_moderated=False, asked_for_removal=True).filter(id__gt=self.id).order_by('id').first() + + def get_previous(self): + return self.parent.children.exclude(is_moderated=False, asked_for_removal=True).filter(id__lt=self.id).order_by('id').last() + class Album(SithFile): class Meta: proxy = True @@ -42,3 +49,13 @@ class Album(SithFile): def get_absolute_url(self): return reverse('sas:album', kwargs={'album_id': self.id}) +class PeoplePictureRelation(models.Model): + """ + The PeoplePictureRelation class makes the connection between User and Picture + + """ + user = models.ForeignKey(User, verbose_name=_('user'), related_name="pictures", null=False, blank=False) + picture = models.ForeignKey(Picture, verbose_name=_('picture'), related_name="people", null=False, blank=False) + + class Meta: + unique_together = ['user', 'picture'] diff --git a/sas/templates/sas/album.jinja b/sas/templates/sas/album.jinja index 1a400b9e..5555ff55 100644 --- a/sas/templates/sas/album.jinja +++ b/sas/templates/sas/album.jinja @@ -6,11 +6,6 @@ {% block content %}
{% trans %}Asked for removal{% endtrans %}
+ {% endif %}{% trans %}Moderate{% endtrans %} diff --git a/sas/templates/sas/picture.jinja b/sas/templates/sas/picture.jinja index 39feee7d..3b261d68 100644 --- a/sas/templates/sas/picture.jinja +++ b/sas/templates/sas/picture.jinja @@ -1,16 +1,97 @@ {% extends "core/base.jinja" %} +{% block head %} +{{ super() }} + +{% endblock %} + {% block title %} {% trans %}SAS{% endtrans %} {% endblock %} +{% macro print_path(file) %} +{% if file %} +{{ print_path(file.parent) }} +{{ file.get_display_name() }} > +{% endif %} +{% endmacro %} + {% block content %} +{{ print_path(picture.parent) }} {{ picture.get_display_name() }}