mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 02:54:20 +00:00
fix album order for user pictures
This commit is contained in:
parent
b25805e0a1
commit
b3fa6f352b
@ -22,17 +22,17 @@
|
|||||||
{% 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 a in albums %}
|
{% for album, album_pictures in pictures|groupby("album") %}
|
||||||
<h4>{{ a.name }}</h4>
|
<h4>{{ album }}</h4>
|
||||||
<div class="photos">
|
<div class="photos">
|
||||||
{% for p in pictures[a.id] %}
|
{% for picture in album_pictures %}
|
||||||
{% if p.can_be_viewed_by(user) %}
|
{% if picture.can_be_viewed_by(user) %}
|
||||||
<a href="{{ url("sas:picture", picture_id=p.id) }}#pict">
|
<a href="{{ url("sas:picture", picture_id=picture.id) }}#pict">
|
||||||
<div
|
<div
|
||||||
class="photo{% if not p.is_moderated %} not_moderated{% endif %}"
|
class="photo{% if not picture.is_moderated %} not_moderated{% endif %}"
|
||||||
style="background-image: url('{% if p.file %}{{ p.get_download_thumb_url() }}{% else %}{{ static('core/img/sas.jpg') }}{% endif %}');"
|
style="background-image: url('{% if picture.file %}{{ picture.get_download_thumb_url() }}{% else %}{{ static('core/img/sas.jpg') }}{% endif %}');"
|
||||||
>
|
>
|
||||||
{% if not p.is_moderated %}
|
{% if not picture.is_moderated %}
|
||||||
<div class="overlay"> </div>
|
<div class="overlay"> </div>
|
||||||
<div class="text">{% trans %}To be moderated{% endtrans %}</div>
|
<div class="text">{% trans %}To be moderated{% endtrans %}</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -31,6 +31,7 @@ from django.contrib.auth import login, views
|
|||||||
from django.contrib.auth.forms import PasswordChangeForm
|
from django.contrib.auth.forms import PasswordChangeForm
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.core.exceptions import PermissionDenied, ValidationError
|
from django.core.exceptions import PermissionDenied, ValidationError
|
||||||
|
from django.db.models import F
|
||||||
from django.forms import CheckboxSelectMultiple
|
from django.forms import CheckboxSelectMultiple
|
||||||
from django.forms.models import modelform_factory
|
from django.forms.models import modelform_factory
|
||||||
from django.http import Http404, HttpResponse
|
from django.http import Http404, HttpResponse
|
||||||
@ -311,21 +312,11 @@ 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["albums"] = []
|
kwargs["pictures"] = list(
|
||||||
kwargs["pictures"] = {}
|
|
||||||
picture_qs = (
|
|
||||||
Picture.objects.filter(people__user_id=self.object.id)
|
Picture.objects.filter(people__user_id=self.object.id)
|
||||||
.order_by("parent__date", "id")
|
.order_by("-parent__date", "id")
|
||||||
.all()
|
.annotate(album=F("parent__name"))
|
||||||
)
|
)
|
||||||
last_album = None
|
|
||||||
for picture in picture_qs:
|
|
||||||
album = picture.parent
|
|
||||||
if album.id != last_album and album not in kwargs["albums"]:
|
|
||||||
kwargs["albums"].append(album)
|
|
||||||
kwargs["pictures"][album.id] = []
|
|
||||||
last_album = album.id
|
|
||||||
kwargs["pictures"][album.id].append(picture)
|
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user