mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-16 11:13:23 +00:00
core: refactor user picture page algorithm
Signed-off-by: Skia <skia@libskia.so>
This commit is contained in:
parent
3eea8ed4e3
commit
61d2765510
@ -5,15 +5,14 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% set picture_qs = profile.pictures.exclude(picture=None).order_by('-picture__parent__id', 'id').select_related('picture__parent__parent__name') %}
|
{% for a in albums %}
|
||||||
{% for a in picture_qs.distinct('picture__parent') %}
|
|
||||||
<div style="padding: 10px">
|
<div style="padding: 10px">
|
||||||
<h4>{{ a.picture.parent.name }}</h4>
|
<h4>{{ a.name }}</h4>
|
||||||
<hr>
|
<hr>
|
||||||
{% for r in picture_qs.filter(picture__parent=a.picture.parent) -%}
|
{% for picture in pictures[a.id] %}
|
||||||
<div class="picture">
|
<div class="picture">
|
||||||
<a href="{{ url("sas:picture", picture_id=r.picture.id) }}#pict">
|
<a href="{{ url("sas:picture", picture_id=picture.id) }}#pict">
|
||||||
<img src="{{ r.picture.get_download_thumb_url() }}" alt="{{ r.picture.get_display_name() }}" style="max-width: 100%"/>
|
<img src="{{ picture.get_download_thumb_url() }}" alt="{{ picture.get_display_name() }}" style="max-width: 100%"/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -258,6 +258,21 @@ class UserPicturesView(UserTabsMixin, CanViewMixin, DetailView):
|
|||||||
template_name = "core/user_pictures.jinja"
|
template_name = "core/user_pictures.jinja"
|
||||||
current_tab = 'pictures'
|
current_tab = 'pictures'
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
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')
|
||||||
|
last_album = None
|
||||||
|
for pict_relation in picture_qs:
|
||||||
|
album = pict_relation.picture.parent
|
||||||
|
if album.id != last_album:
|
||||||
|
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
|
||||||
|
|
||||||
class UserGodfathersView(UserTabsMixin, CanViewMixin, DetailView):
|
class UserGodfathersView(UserTabsMixin, CanViewMixin, DetailView):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user