mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Fix problème de cache dans le SAS & améliore le CSS du SAS
Co-authored-by: Bartuccio Antoine <klmp200@users.noreply.github.com>
This commit is contained in:
parent
f605f7dcc6
commit
d83842af27
@ -160,6 +160,7 @@ main {
|
|||||||
> .photo,
|
> .photo,
|
||||||
> .album {
|
> .album {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
background-color: #333333;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: center center;
|
background-position: center center;
|
||||||
@ -167,6 +168,10 @@ main {
|
|||||||
width: calc(16 / 9 * 128px);
|
width: calc(16 / 9 * 128px);
|
||||||
height: 128px;
|
height: 128px;
|
||||||
|
|
||||||
|
&.vertical {
|
||||||
|
background-size: contain;
|
||||||
|
}
|
||||||
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
> #next {
|
> #next {
|
||||||
width: calc(50% - 5px);
|
width: calc(50% - 5px);
|
||||||
aspect-ratio: 16/9;
|
aspect-ratio: 16/9;
|
||||||
background: #aaa;
|
background: #333333;
|
||||||
|
|
||||||
> a {
|
> a {
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -241,6 +241,7 @@
|
|||||||
> .infos {
|
> .infos {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
width: 50%;
|
||||||
|
|
||||||
> div > div {
|
> div > div {
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -260,7 +261,7 @@
|
|||||||
> .tools {
|
> .tools {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: 100%;
|
width: 50%;
|
||||||
|
|
||||||
> div {
|
> div {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -63,7 +63,12 @@ class Picture(SithFile):
|
|||||||
return (w / h) < 1
|
return (w / h) < 1
|
||||||
|
|
||||||
def can_be_edited_by(self, user):
|
def can_be_edited_by(self, user):
|
||||||
return user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID)
|
perm = cache.get("%d_can_edit_pictures" % (user.id), None)
|
||||||
|
if perm is None:
|
||||||
|
perm = user.is_root or user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID)
|
||||||
|
|
||||||
|
cache.set("%d_can_edit_pictures" % (user.id), perm, timeout=4)
|
||||||
|
return perm
|
||||||
|
|
||||||
def can_be_viewed_by(self, user):
|
def can_be_viewed_by(self, user):
|
||||||
# SAS pictures are visible to old subscribers
|
# SAS pictures are visible to old subscribers
|
||||||
@ -72,19 +77,13 @@ class Picture(SithFile):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
perm = cache.get("%d_can_view_pictures" % (user.id), False)
|
perm = cache.get("%d_can_view_pictures" % (user.id), False)
|
||||||
|
if not perm:
|
||||||
|
perm = user.was_subscribed
|
||||||
|
|
||||||
# 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 or self.can_be_edited_by(user))
|
|
||||||
and user.was_subscribed
|
|
||||||
)
|
|
||||||
cache.set("%d_can_view_pictures" % (user.id), perm, timeout=4)
|
cache.set("%d_can_view_pictures" % (user.id), perm, timeout=4)
|
||||||
|
return (perm and self.is_moderated and self.is_in_sas) or self.can_be_edited_by(
|
||||||
return perm
|
user
|
||||||
|
)
|
||||||
|
|
||||||
def get_download_url(self):
|
def get_download_url(self):
|
||||||
return reverse("sas:download", kwargs={"picture_id": self.id})
|
return reverse("sas:download", kwargs={"picture_id": self.id})
|
||||||
|
@ -88,7 +88,7 @@
|
|||||||
{% if p.can_be_viewed_by(user) %}
|
{% if p.can_be_viewed_by(user) %}
|
||||||
<a href="{{ url('sas:picture', picture_id=p.id) }}#pict">
|
<a href="{{ url('sas:picture', picture_id=p.id) }}#pict">
|
||||||
<div
|
<div
|
||||||
class="photo"
|
class="photo {% if p.is_vertical %}vertical{% endif %}"
|
||||||
style="background-image: url('{{ p.get_download_thumb_url() }}')"
|
style="background-image: url('{{ p.get_download_thumb_url() }}')"
|
||||||
>
|
>
|
||||||
{% if not p.is_moderated %}
|
{% if not p.is_moderated %}
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
<h3>{{ picture.get_display_name() }}</h3>
|
<h3>{{ picture.get_display_name() }}</h3>
|
||||||
<h4>{{ picture.parent.children.filter(id__lte=picture.id).count() }} / {{ picture.parent.children.count() }}</h4>
|
<h4>{{ picture.parent.children.filter(id__lte=picture.id).count() }} / {{ picture.parent.children.count() }}</h4>
|
||||||
</div>
|
</div>
|
||||||
|
<br>
|
||||||
|
|
||||||
{% if not picture.is_moderated %}
|
{% if not picture.is_moderated %}
|
||||||
{% set next = picture.get_next() %}
|
{% set next = picture.get_next() %}
|
||||||
|
Loading…
Reference in New Issue
Block a user