From e638bc04ed5fe8a9d609ff78f4a414525631b617 Mon Sep 17 00:00:00 2001
From: Julien Constant <49886317+Juknum@users.noreply.github.com>
Date: Tue, 4 Apr 2023 22:50:19 +0200
Subject: [PATCH] =?UTF-8?q?Fixes=20pour=20la=20mise=20=C3=A0=20jour=20de?=
=?UTF-8?q?=20mars=20(#598)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
core/models.py | 4 ++++
core/static/core/header.scss | 7 ++++++-
core/static/sas/picture.scss | 11 +++++++++++
core/static/user/user_detail.scss | 15 +++++++++++++++
core/static/user/user_edit.scss | 2 ++
core/templates/core/base.jinja | 13 +++++++------
core/templates/core/user_detail.jinja | 10 ++++++++--
core/templates/core/user_edit.jinja | 8 ++++++--
core/utils.py | 5 +++++
locale/fr/LC_MESSAGES/django.po | 4 ++++
sas/templates/sas/picture.jinja | 2 +-
11 files changed, 69 insertions(+), 12 deletions(-)
diff --git a/core/models.py b/core/models.py
index dff97cf0..276ec559 100644
--- a/core/models.py
+++ b/core/models.py
@@ -46,6 +46,7 @@ from django.utils.html import escape
from django.utils.functional import cached_property
import os
+from core import utils
from phonenumber_field.modelfields import PhoneNumberField
@@ -296,6 +297,9 @@ class User(AbstractBaseUser):
USERNAME_FIELD = "username"
# REQUIRED_FIELDS = ['email']
+ def promo_has_logo(self):
+ return utils.file_exist("./core/static/core/img/promo_%02d.png" % self.promo)
+
def has_module_perms(self, package_name):
return self.is_active
diff --git a/core/static/core/header.scss b/core/static/core/header.scss
index 82d4bbfe..dea1aab4 100644
--- a/core/static/core/header.scss
+++ b/core/static/core/header.scss
@@ -196,10 +196,15 @@
justify-content: flex-end;
}
- >a>img {
+ > a {
+ display: block;
width: 40px;
height: 40px;
border-radius: 50%;
+ background-position: center center;
+ background-size: cover;
+ background-repeat: no-repeat;
+ background-color: #354a5f;
}
>.options {
diff --git a/core/static/sas/picture.scss b/core/static/sas/picture.scss
index f5c895fe..520c8d9d 100644
--- a/core/static/sas/picture.scss
+++ b/core/static/sas/picture.scss
@@ -145,6 +145,7 @@
}
> a {
+ box-sizing: border-box;
display: flex;
flex-direction: row;
align-items: center;
@@ -181,6 +182,16 @@
object-fit: contain;
border-radius: 50%;
}
+
+ > .profile-pic {
+ background-position: center center;
+ background-size: cover;
+ background-repeat: no-repeat;
+ min-width: 25px;
+ height: 25px;
+ border-radius: 50%;
+ display: block;
+ }
}
}
}
diff --git a/core/static/user/user_detail.scss b/core/static/user/user_detail.scss
index 6ac5065a..4f67c6f6 100644
--- a/core/static/user/user_detail.scss
+++ b/core/static/user/user_detail.scss
@@ -61,6 +61,21 @@ main {
width: 5em;
margin: 0.5em;
}
+
+ > div {
+ display: flex;
+ width: 5em;
+ height: 5em;
+ border-radius: 50%;
+ justify-content: center;
+ align-items: center;
+ background-color: #f2f2f2;
+
+ > span {
+ font-size: small;
+ color: #ccc;
+ }
+ }
}
> .user_profile_infos_items {
diff --git a/core/static/user/user_edit.scss b/core/static/user/user_edit.scss
index fdba806e..a0dcf559 100644
--- a/core/static/user/user_edit.scss
+++ b/core/static/user/user_edit.scss
@@ -56,6 +56,7 @@
width: 100%;
height: 100%;
max-width: 300px;
+ margin-top: 10px;
@media (max-width: 750px) {
max-width: 100%;
@@ -77,6 +78,7 @@
width: 100% !important;
object-fit: contain;
height: auto;
+ max-height: 100%;
}
>p {
diff --git a/core/templates/core/base.jinja b/core/templates/core/base.jinja
index 1cf84aaf..79e15d8b 100644
--- a/core/templates/core/base.jinja
+++ b/core/templates/core/base.jinja
@@ -97,13 +97,14 @@
{% trans %}Logout{% endtrans %}
-
- {% if user.profile_pict %}
-
+
- {% endif %}
-
+ style="background-image: url('{{ static('core/img/unknown.jpg') }}')"
+ {% endif %}
+ >
{{ form["profile_pict"].label }}
- {{ form["profile_pict"] }} + {%- if form["profile_pict"] -%} +{{ form["profile_pict"].label }}
+ {{ form["profile_pict"] }} + {%- else -%} + {% trans %}To edit your profile picture, ask a member of the AE{% endtrans %} + {%- endif -%} {%- if user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) and form.instance.profile_pict.id -%} {%- trans -%}Delete{%- endtrans -%} diff --git a/core/utils.py b/core/utils.py index 4d072c30..0e98da6b 100644 --- a/core/utils.py +++ b/core/utils.py @@ -14,6 +14,7 @@ # # +import os import subprocess import re @@ -71,6 +72,10 @@ def get_semester(d=date.today()): return "A" + str(start.year)[-2:] +def file_exist(path): + return os.path.exists(path) + + def scale_dimension(width, height, long_edge): if width > height: ratio = long_edge * 1.0 / width diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index d0b2bd16..b545b4a9 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -3246,6 +3246,10 @@ msgstr "Changer mon mot de passe" msgid "Change user password" msgstr "Changer le mot de passe" +#: core/templates/core/user_edit.jinja:50 +msgid "To edit your profile picture, ask a member of the AE" +msgstr "Pour changer votre photo de profil, demandez à un membre de l'AE" + #: core/templates/core/user_godfathers.jinja:5 #, python-format msgid "%(user_name)s's family" diff --git a/sas/templates/sas/picture.jinja b/sas/templates/sas/picture.jinja index f04f1112..f22fbdb0 100644 --- a/sas/templates/sas/picture.jinja +++ b/sas/templates/sas/picture.jinja @@ -144,7 +144,7 @@