mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 02:54:20 +00:00
commit
af724a1e0e
@ -94,7 +94,7 @@
|
|||||||
from paginated routes.
|
from paginated routes.
|
||||||
In order to download all the user pictures, it may be needed
|
In order to download all the user pictures, it may be needed
|
||||||
to performs multiple requests #}
|
to performs multiple requests #}
|
||||||
const max_per_page = 1;
|
const max_per_page = 199;
|
||||||
const url = "{{ url("api:pictures") }}"
|
const url = "{{ url("api:pictures") }}"
|
||||||
+ "?users_identified={{ object.id }}"
|
+ "?users_identified={{ object.id }}"
|
||||||
+ `&page_size=${max_per_page}`;
|
+ `&page_size=${max_per_page}`;
|
||||||
|
@ -175,6 +175,16 @@ class AlbumQuerySet(models.QuerySet):
|
|||||||
"""
|
"""
|
||||||
if user.is_root or user.is_in_group(pk=settings.SITH_GROUP_SAS_ADMIN_ID):
|
if user.is_root or user.is_in_group(pk=settings.SITH_GROUP_SAS_ADMIN_ID):
|
||||||
return self.all()
|
return self.all()
|
||||||
|
if user.was_subscribed:
|
||||||
|
return self.filter(moderated=True)
|
||||||
|
# known bug : if all children of an album are also albums
|
||||||
|
# then this album is excluded, even if one of the sub-albums should be visible.
|
||||||
|
# The fs-like navigation is likely to be half-broken for non-subscribers,
|
||||||
|
# but that's ok, since non-subscribers are expected to see only the albums
|
||||||
|
# containing pictures on which they have been identified (hence, very few).
|
||||||
|
# Most, if not all, of their albums will be displayed on the
|
||||||
|
# `latest albums` section of the SAS.
|
||||||
|
# Moreover, they will still see all of their picture in their profile.
|
||||||
return self.filter(
|
return self.filter(
|
||||||
Exists(Picture.objects.filter(parent_id=OuterRef("pk")).viewable_by(user))
|
Exists(Picture.objects.filter(parent_id=OuterRef("pk")).viewable_by(user))
|
||||||
)
|
)
|
||||||
|
@ -181,7 +181,9 @@ class PictureView(CanViewMixin, DetailView, FormMixin):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs = super().get_context_data(**kwargs)
|
kwargs = super().get_context_data(**kwargs)
|
||||||
pictures_qs = Picture.objects.viewable_by(self.request.user)
|
pictures_qs = Picture.objects.filter(
|
||||||
|
parent_id=self.object.parent_id
|
||||||
|
).viewable_by(self.request.user)
|
||||||
kwargs["form"] = self.form
|
kwargs["form"] = self.form
|
||||||
kwargs["next_pict"] = (
|
kwargs["next_pict"] = (
|
||||||
pictures_qs.filter(id__gt=self.object.id).order_by("id").first()
|
pictures_qs.filter(id__gt=self.object.id).order_by("id").first()
|
||||||
|
Loading…
Reference in New Issue
Block a user