diff --git a/core/models.py b/core/models.py index 018bc738..18352e21 100644 --- a/core/models.py +++ b/core/models.py @@ -783,7 +783,7 @@ class Preferences(models.Model): user = models.OneToOneField( User, related_name="_preferences", on_delete=models.CASCADE ) - receive_weekmail = models.BooleanField(_("Receive the Weekmail"), default=False) + receive_weekmail = models.BooleanField(_("receive the Weekmail"), default=False) show_my_stats = models.BooleanField(_("show your stats to others"), default=False) notify_on_click = models.BooleanField( _("get a notification for every click"), default=False diff --git a/core/static/sas/album.scss b/core/static/sas/album.scss index a81ae186..18808bda 100644 --- a/core/static/sas/album.scss +++ b/core/static/sas/album.scss @@ -43,7 +43,7 @@ > p { box-sizing: border-box; - max-width: calc(100% / 3); + max-width: 300px; width: 100%; @media (max-width: 500px) { @@ -55,6 +55,7 @@ max-width: 100%; width: 100%; height: 40px; + line-height: normal; font-size: 16px; } } @@ -62,7 +63,7 @@ > input { height: 40px; width: 100%; - max-width: calc(100% / 3); + max-width: 300px; @media (max-width: 500px) { max-width: 100%; @@ -83,6 +84,7 @@ display: flex; justify-content: center; gap: 10px; + width: -moz-fit-content; width: fit-content; background-color: rgba(0,0,0,.1); border-radius: 10px; @@ -90,48 +92,7 @@ margin: 10px 0 10px auto; } -.photos { - display: flex; - flex-direction: row; - flex-wrap: wrap; - align-items: center; - gap: 5px; - - > .photo { - background-color: rgba(0, 0, 0, .5); - border-radius: 5px; - - > a { - display: block; - border-radius: 5px; - - background-position: center center; - background-size: cover; - background-repeat: no-repeat; - - box-sizing: border-box; - position: relative; - width: 100%; - height: 100%; - - > input[type=checkbox] { - position: absolute; - top: 0; - right: 0; - height: 20px; - width: 20px; - margin: 5px; - - cursor: pointer; - } - - > img { - object-fit: contain; - } - } - } -} - +.photos, .albums { box-sizing: border-box; display: flex; @@ -142,6 +103,15 @@ > a { box-sizing: border-box; position: relative; + height: 128px; + + @media (max-width: 500px) { + width: calc(50% - 5px); + } + + @media (max-width: 300px) { + width: 100%; + } &:hover { background: rgba(0, 0, 0, .5); @@ -151,19 +121,15 @@ position: absolute; top: 0; right: 0; - height: 20px; - width: 20px; + height: 15px; + width: 15px; margin: 5px; cursor: pointer; } - @media (max-width: 500px) { - width: 100%; - } - + > .photo, > .album { - border-radius: 5px; border: none; box-sizing: border-box; @@ -183,7 +149,6 @@ } > div { - border-radius: 5px; box-sizing: border-box; width: 100%; height: 100%; @@ -195,14 +160,42 @@ padding: 10px; color: white; - - background: rgba(0, 0, 0, .3); - background: linear-gradient(0deg, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, 0) 100%); - + &:hover { + background: rgba(0, 0, 0, .7); + } + } + + &.not_moderated { + &::before { + content: '⚠️'; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + color: white; + display: flex; + justify-content: center; + align-items: center; + background: rgba(0, 0, 0, .5); + -webkit-backdrop-filter: blur(5px); + backdrop-filter: blur(5px); + } + + &:hover::before { + -webkit-backdrop-filter: blur(2px); + backdrop-filter: blur(2px); } } } + + > .album > div { + background: rgba(0, 0, 0, .3); + background: linear-gradient(0deg, rgba(0, 0, 0, .7) 0%, rgba(0, 0, 0, 0) 100%); + text-align: left; + word-break: break-word; + } } } \ No newline at end of file diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 4e1ade61..b771c4b6 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -5282,6 +5282,10 @@ msgstr "photo" msgid "SAS" msgstr "SAS" +#: sas/templates/sas/album.jinja:102 +msgid "This album does not contain any photos." +msgstr "Cet album ne contient aucune photo." + #: sas/templates/sas/album.jinja:53 sas/templates/sas/album.jinja:55 #: sas/templates/sas/main.jinja:13 sas/templates/sas/main.jinja:15 #: sas/templates/sas/main.jinja:17 diff --git a/sas/models.py b/sas/models.py index db82aef3..944b646f 100644 --- a/sas/models.py +++ b/sas/models.py @@ -69,7 +69,6 @@ class Picture(SithFile): im = Image.open(BytesIO(f.read())) (w, h) = im.size return (w / h) < 1 - return False def can_be_edited_by(self, user): return user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) @@ -79,11 +78,16 @@ class Picture(SithFile): # Result is cached 4s for this user if user.is_anonymous: return False + perm = cache.get("%d_can_view_pictures" % (user.id), False) - if perm: + + # use cache only when user is in SAS Admins or when picture is moderated + if perm and (self.is_moderated or self.can_be_edited_by(user)): return perm - perm = self.is_in_sas and self.is_moderated and user.was_subscribed + + perm = self.is_in_sas and (self.is_moderated or self.can_be_edited_by(user)) and user.was_subscribed cache.set("%d_can_view_pictures" % (user.id), perm, timeout=4) + return perm def get_download_url(self): diff --git a/sas/templates/sas/album.jinja b/sas/templates/sas/album.jinja index 3637591c..80b16942 100644 --- a/sas/templates/sas/album.jinja +++ b/sas/templates/sas/album.jinja @@ -58,10 +58,10 @@

{% trans %}Albums{% endtrans %}

{% for a in album.children_albums.order_by('-date') %} - {% if user.can_view(a) %} - + {% if a.can_be_viewed_by(user) %} +
@@ -69,7 +69,7 @@
{% if edit_mode %} - + {% endif %}
{% endif %} @@ -79,67 +79,59 @@
{% endif %} -

{% trans %}Photos{% endtrans %}

+

{% trans %}Pictures{% endtrans %}

{% if pictures | length != 0 %} - {% set max = (pictures | length // 6) if pictures | length > 6 else 1 %}
{% for p in pictures %} - + {% endif %} {% endfor %}
{% else %} {% trans %}This album does not contain any photos.{% endtrans %} {% endif %} -
- {{ paginate(pictures, paginator) }} -
+ {% if pictures.has_previous() or pictures.has_next() %} +
+ {{ paginate(pictures, paginator) }} +
+ {% endif %} {% if edit_mode %} {% endif %} + {% if edit_mode %} +
+ {% csrf_token %} +
+ {{ form.as_p() }} + + +
+
+ {% endif %} +
-
- {% csrf_token %} -
- {{ form.as_p() }} - - -
-
-

{% trans %}Template generation time: {% endtrans %} {{ timezone.now() - start }}

{% endblock %} {% block script %} -{{ super() }} - - + {{ super() }}