From 5897318cc6992e8a139842e73a908fe52c147557 Mon Sep 17 00:00:00 2001 From: Skia Date: Thu, 23 Feb 2017 00:27:53 +0100 Subject: [PATCH] Fix user picture view with Jinja update --- core/templates/core/user_pictures.jinja | 20 ++++++-------------- core/views/user.py | 4 ++-- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/core/templates/core/user_pictures.jinja b/core/templates/core/user_pictures.jinja index c435e26d..4cae6f78 100644 --- a/core/templates/core/user_pictures.jinja +++ b/core/templates/core/user_pictures.jinja @@ -5,27 +5,19 @@ {% endblock %} {% block content %} -{% set album = None %} -{% set new_album = True %} -{% for r in profile.pictures.exclude(picture=None).order_by('-picture__parent__id', 'id') -%} - {%- if album != r.picture.parent %} - {%- if album %} - - {% endif -%} - {% set new_album = True %} - {% set album = r.picture.parent %} +{% set picture_qs = profile.pictures.exclude(picture=None).order_by('-picture__parent__id', 'id').select_related('picture__parent__parent__name') %} +{% for a in picture_qs.distinct('picture__parent') %}
-

{{ album.name }}

+

{{ a.picture.parent.name }}


- {% else %} - {% set new_album = False %} - {%- endif %} + {% for r in picture_qs.filter(picture__parent=a.picture.parent) -%} -{%- endfor %} + {% endfor %}
+{% endfor %} {% endblock %} diff --git a/core/views/user.py b/core/views/user.py index 95a67c7e..32988906 100644 --- a/core/views/user.py +++ b/core/views/user.py @@ -502,8 +502,8 @@ class UserAccountView(UserAccountBase): (lambda q: q.amount) ) kwargs['etickets'] = self.object.customer.buyings.exclude(product__eticket=None).all() - except: - pass + except Exception as e: + print(repr(e)) return kwargs class UserAccountDetailView(UserAccountBase, YearMixin, MonthMixin):