mirror of
https://github.com/ae-utbm/sith.git
synced 2025-09-17 21:53:50 +00:00
Compare commits
1 Commits
cache-phot
...
navbar
Author | SHA1 | Date | |
---|---|---|---|
|
7ee645c5ee |
@@ -20,14 +20,6 @@
|
|||||||
<a class="link" href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a>
|
<a class="link" href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a>
|
||||||
<a class="link" href="{{ url('sas:main') }}">{% trans %}Gallery{% endtrans %}</a>
|
<a class="link" href="{{ url('sas:main') }}">{% trans %}Gallery{% endtrans %}</a>
|
||||||
<a class="link" href="{{ url('eboutic:main') }}">{% trans %}Eboutic{% endtrans %}</a>
|
<a class="link" href="{{ url('eboutic:main') }}">{% trans %}Eboutic{% endtrans %}</a>
|
||||||
<details name="navbar" class="menu">
|
|
||||||
<summary class="head">{% trans %}Services{% endtrans %}</summary>
|
|
||||||
<ul class="content">
|
|
||||||
<li><a href="{{ url('matmat:search_clear') }}">{% trans %}Matmatronch{% endtrans %}</a></li>
|
|
||||||
<li><a href="{{ url('core:file_list') }}">{% trans %}Files{% endtrans %}</a></li>
|
|
||||||
<li><a href="{{ url('pedagogy:guide') }}">{% trans %}Pedagogy{% endtrans %}</a></li>
|
|
||||||
</ul>
|
|
||||||
</details>
|
|
||||||
<details name="navbar" class="menu">
|
<details name="navbar" class="menu">
|
||||||
<summary class="head">{% trans %}My Benefits{% endtrans %}</summary>
|
<summary class="head">{% trans %}My Benefits{% endtrans %}</summary>
|
||||||
<ul class="content">
|
<ul class="content">
|
||||||
|
@@ -7,7 +7,6 @@ import {
|
|||||||
|
|
||||||
interface PagePictureConfig {
|
interface PagePictureConfig {
|
||||||
userId: number;
|
userId: number;
|
||||||
lastPhotoDate?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Album {
|
interface Album {
|
||||||
@@ -21,28 +20,11 @@ document.addEventListener("alpine:init", () => {
|
|||||||
loading: true,
|
loading: true,
|
||||||
albums: [] as Album[],
|
albums: [] as Album[],
|
||||||
|
|
||||||
async fetchPictures(): Promise<PictureSchema[]> {
|
async init() {
|
||||||
const localStorageKey = `user${config.userId}Pictures`;
|
|
||||||
const localStorageDateKey = `user${config.userId}PicturesDate`;
|
|
||||||
const lastCachedDate = localStorage.getItem(localStorageDateKey);
|
|
||||||
if (
|
|
||||||
config.lastPhotoDate !== undefined &&
|
|
||||||
lastCachedDate !== undefined &&
|
|
||||||
lastCachedDate >= config.lastPhotoDate
|
|
||||||
) {
|
|
||||||
return JSON.parse(localStorage.getItem(localStorageKey));
|
|
||||||
}
|
|
||||||
const pictures = await paginated(picturesFetchPictures, {
|
const pictures = await paginated(picturesFetchPictures, {
|
||||||
// biome-ignore lint/style/useNamingConvention: from python api
|
// biome-ignore lint/style/useNamingConvention: from python api
|
||||||
query: { users_identified: [config.userId] },
|
query: { users_identified: [config.userId] },
|
||||||
} as PicturesFetchPicturesData);
|
} as PicturesFetchPicturesData);
|
||||||
localStorage.setItem(localStorageDateKey, config.lastPhotoDate);
|
|
||||||
localStorage.setItem(localStorageKey, JSON.stringify(pictures));
|
|
||||||
return pictures;
|
|
||||||
},
|
|
||||||
|
|
||||||
async init() {
|
|
||||||
const pictures = await this.fetchPictures();
|
|
||||||
const groupedAlbums = Object.groupBy(pictures, (i: PictureSchema) => i.album.id);
|
const groupedAlbums = Object.groupBy(pictures, (i: PictureSchema) => i.album.id);
|
||||||
this.albums = Object.values(groupedAlbums).map((pictures: PictureSchema[]) => {
|
this.albums = Object.values(groupedAlbums).map((pictures: PictureSchema[]) => {
|
||||||
return {
|
return {
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<main x-data="user_pictures({ userId: {{ object.id }}, lastPhotoDate: '{{ object.last_photo_date }}' })">
|
<main x-data="user_pictures({ userId: {{ object.id }} })">
|
||||||
{% if user.id == object.id %}
|
{% if user.id == object.id %}
|
||||||
{{ download_button(_("Download all my pictures")) }}
|
{{ download_button(_("Download all my pictures")) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@@ -16,7 +16,6 @@ from typing import Any
|
|||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.db.models import OuterRef, Subquery
|
|
||||||
from django.http import Http404, HttpResponseRedirect
|
from django.http import Http404, HttpResponseRedirect
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
@@ -179,13 +178,6 @@ class UserPicturesView(UserTabsMixin, CanViewMixin, DetailView):
|
|||||||
context_object_name = "profile"
|
context_object_name = "profile"
|
||||||
template_name = "sas/user_pictures.jinja"
|
template_name = "sas/user_pictures.jinja"
|
||||||
current_tab = "pictures"
|
current_tab = "pictures"
|
||||||
queryset = User.objects.annotate(
|
|
||||||
last_photo_date=Subquery(
|
|
||||||
Picture.objects.filter(people__user=OuterRef("id"))
|
|
||||||
.order_by("-date")
|
|
||||||
.values("date")[:1]
|
|
||||||
)
|
|
||||||
).all()
|
|
||||||
|
|
||||||
|
|
||||||
# Admin views
|
# Admin views
|
||||||
|
Reference in New Issue
Block a user