mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 02:54:20 +00:00
fix grouping
This commit is contained in:
parent
d348e6314a
commit
3c76c5e0f1
@ -22,10 +22,10 @@
|
|||||||
{% if can_edit(profile, user) %}
|
{% if can_edit(profile, user) %}
|
||||||
<button disabled id="download" onclick="download('{{ url('api:pictures') }}?users_identified={{ object.id }}')">{% trans %}Download all my pictures{% endtrans %}</button>
|
<button disabled id="download" onclick="download('{{ url('api:pictures') }}?users_identified={{ object.id }}')">{% trans %}Download all my pictures{% endtrans %}</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for album, album_pictures in pictures|groupby("album") %}
|
{% for album, pictures in albums|items %}
|
||||||
<h4>{{ album }}</h4>
|
<h4>{{ album }}</h4>
|
||||||
<div class="photos">
|
<div class="photos">
|
||||||
{% for picture in album_pictures %}
|
{% for picture in pictures %}
|
||||||
{% if picture.can_be_viewed_by(user) %}
|
{% if picture.can_be_viewed_by(user) %}
|
||||||
<a href="{{ url("sas:picture", picture_id=picture.id) }}#pict">
|
<a href="{{ url("sas:picture", picture_id=picture.id) }}#pict">
|
||||||
<div
|
<div
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
import itertools
|
||||||
|
|
||||||
# This file contains all the views that concern the user model
|
# This file contains all the views that concern the user model
|
||||||
from datetime import date, timedelta
|
from datetime import date, timedelta
|
||||||
@ -312,11 +313,15 @@ class UserPicturesView(UserTabsMixin, CanViewMixin, DetailView):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs = super().get_context_data(**kwargs)
|
kwargs = super().get_context_data(**kwargs)
|
||||||
kwargs["pictures"] = list(
|
pictures = list(
|
||||||
Picture.objects.filter(people__user_id=self.object.id)
|
Picture.objects.filter(people__user_id=self.object.id)
|
||||||
.order_by("-parent__date", "-date")
|
.order_by("-parent__date", "-date")
|
||||||
.annotate(album=F("parent__name"))
|
.annotate(album=F("parent__name"))
|
||||||
)
|
)
|
||||||
|
kwargs["albums"] = {
|
||||||
|
album: list(picts)
|
||||||
|
for album, picts in itertools.groupby(pictures, lambda i: i.album)
|
||||||
|
}
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user