From 5c4a16d14c145167eabb025d1ccd25c3e53d7a84 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Sun, 10 Jun 2018 18:43:39 +0200 Subject: [PATCH] Fix user pictures display --- core/views/user.py | 5 +++-- sas/models.py | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/views/user.py b/core/views/user.py index c812fd5c..ad441650 100644 --- a/core/views/user.py +++ b/core/views/user.py @@ -254,7 +254,7 @@ class UserPicturesView(UserTabsMixin, CanViewMixin, DetailView): kwargs = super(UserPicturesView, self).get_context_data(**kwargs) kwargs['albums'] = [] kwargs['pictures'] = {} - picture_qs = self.object.pictures.exclude(picture=None).order_by('-picture__parent__date', 'id').select_related('picture__parent__name') + picture_qs = self.object.pictures.exclude(picture=None).order_by('-picture__parent__date', 'id').select_related('picture__parent') last_album = None for pict_relation in picture_qs: album = pict_relation.picture.parent @@ -262,10 +262,10 @@ class UserPicturesView(UserTabsMixin, CanViewMixin, DetailView): kwargs['albums'].append(album) kwargs['pictures'][album.id] = [] last_album = album.id - print(album, album.date) kwargs['pictures'][album.id].append(pict_relation.picture) return kwargs + def DeleteUserGodfathers(request, user_id, godfather_id, is_father): user = User.objects.get(id=user_id) if ((user == request.user) or @@ -280,6 +280,7 @@ def DeleteUserGodfathers(request, user_id, godfather_id, is_father): raise PermissionDenied return redirect('core:user_godfathers', user_id=user_id) + class UserGodfathersView(UserTabsMixin, CanViewMixin, DetailView): """ Display a user's godfathers diff --git a/sas/models.py b/sas/models.py index e562a144..dafe9ece 100644 --- a/sas/models.py +++ b/sas/models.py @@ -35,15 +35,18 @@ import os from core.models import SithFile, User from core.utils import resize_image, exif_auto_rotate + class SASPictureManager(models.Manager): def get_queryset(self): return super(SASPictureManager, self).get_queryset().filter(is_in_sas=True, - is_folder=False) + is_folder=False) + class SASAlbumManager(models.Manager): def get_queryset(self): return super(SASAlbumManager, self).get_queryset().filter(is_in_sas=True, - is_folder=True) + is_folder=True) + class Picture(SithFile): class Meta: @@ -163,6 +166,7 @@ class Album(SithFile): self.file.name = self.name + '/thumb.jpg' self.save() + def sas_notification_callback(notif): count = Picture.objects.filter(is_moderated=False).count() if count: @@ -172,6 +176,7 @@ def sas_notification_callback(notif): notif.param = "%s" % count notif.date = timezone.now() + class PeoplePictureRelation(models.Model): """ The PeoplePictureRelation class makes the connection between User and Picture