diff --git a/core/models.py b/core/models.py index 29c622fe..b0abf09e 100644 --- a/core/models.py +++ b/core/models.py @@ -880,11 +880,9 @@ class SithFile(models.Model): def save(self, *args, **kwargs): sas = SithFile.objects.filter(id=settings.SITH_SAS_ROOT_DIR_ID).first() self.is_in_sas = sas in self.get_parent_list() or self == sas - copy_rights = False - if self.id is None: - copy_rights = True + adding = self._state.adding super().save(*args, **kwargs) - if copy_rights: + if adding: self.copy_rights() if self.is_in_sas: for user in User.objects.filter( diff --git a/counter/static/bundled/counter/counter-click-index.ts b/counter/static/bundled/counter/counter-click-index.ts index b2b63c80..5b593532 100644 --- a/counter/static/bundled/counter/counter-click-index.ts +++ b/counter/static/bundled/counter/counter-click-index.ts @@ -1,6 +1,6 @@ import { BasketItem } from "#counter:counter/basket"; import type { CounterConfig, ErrorMessage } from "#counter:counter/types"; -import type { CounterProductSelect } from "./components/counter-product-select-index"; +import type { CounterProductSelect } from "./components/counter-product-select-index.ts"; document.addEventListener("alpine:init", () => { Alpine.data("counter", (config: CounterConfig) => ({ diff --git a/sas/models.py b/sas/models.py index bf87786d..e2b8867a 100644 --- a/sas/models.py +++ b/sas/models.py @@ -23,7 +23,7 @@ from typing import ClassVar, Self from django.conf import settings from django.core.cache import cache from django.db import models -from django.db.models import Exists, OuterRef +from django.db.models import Exists, OuterRef, Q from django.urls import reverse from django.utils import timezone from django.utils.translation import gettext_lazy as _ @@ -73,7 +73,7 @@ class PictureQuerySet(models.QuerySet): if user.is_root or user.is_in_group(pk=settings.SITH_GROUP_SAS_ADMIN_ID): return self.all() if user.was_subscribed: - return self.filter(is_moderated=True) + return self.filter(Q(is_moderated=True) | Q(owner=user)) return self.filter(people__user_id=user.id, is_moderated=True) @@ -187,7 +187,7 @@ class AlbumQuerySet(models.QuerySet): if user.is_root or user.is_in_group(pk=settings.SITH_GROUP_SAS_ADMIN_ID): return self.all() if user.was_subscribed: - return self.filter(is_moderated=True) + return self.filter(Q(is_moderated=True) | Q(owner=user)) # 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, diff --git a/sas/static/bundled/sas/viewer-index.ts b/sas/static/bundled/sas/viewer-index.ts index faa9505a..59718b26 100644 --- a/sas/static/bundled/sas/viewer-index.ts +++ b/sas/static/bundled/sas/viewer-index.ts @@ -4,9 +4,9 @@ import { History } from "#core:utils/history"; import type TomSelect from "tom-select"; import { type IdentifiedUserSchema, + type ModerationRequestSchema, type PictureSchema, type PicturesFetchIdentificationsResponse, - type PicturesFetchModerationRequestsResponse, type PicturesFetchPicturesData, type UserProfileSchema, picturesDeletePicture, @@ -30,7 +30,7 @@ class PictureWithIdentifications { id: number; // biome-ignore lint/style/useNamingConvention: api is in snake_case compressed_url: string; - moderationRequests: PicturesFetchModerationRequestsResponse = null; + moderationRequests: ModerationRequestSchema[] = null; constructor(picture: PictureSchema) { Object.assign(this, picture); @@ -156,9 +156,6 @@ exportToHtml("loadViewer", (config: ViewerConfig) => { * The select2 component used to identify users **/ selector: undefined, - /** - * true if the page is in a loading state, else false - **/ /** * Error message when a moderation operation fails **/ diff --git a/sas/templates/sas/picture.jinja b/sas/templates/sas/picture.jinja index f86c7959..b68312d5 100644 --- a/sas/templates/sas/picture.jinja +++ b/sas/templates/sas/picture.jinja @@ -17,6 +17,8 @@ {% from "sas/macros.jinja" import print_path %} +{% set user_is_sas_admin = user.is_root or user.is_in_group(pk = settings.SITH_GROUP_SAS_ADMIN_ID) %} + {% block content %}
@@ -31,8 +33,13 @@
+ {# Non-moderated pictures (hence, this moderation alert too) + should be shown only to admins and to the picture owner. + Admins should see all infos and have access to all actions. + Non-admin picture owners should only see the message warning them that + the picture isn't moderated yet. #}