Fixes pour la mise à jour de mars (#598)

This commit is contained in:
Julien Constant 2023-04-04 22:50:19 +02:00 committed by Julien Constant
parent 8e7c025e47
commit f605f7dcc6
No known key found for this signature in database
GPG Key ID: 816E7C070117E5B7
11 changed files with 69 additions and 12 deletions

View File

@ -46,6 +46,7 @@ from django.utils.html import escape
from django.utils.functional import cached_property from django.utils.functional import cached_property
import os import os
from core import utils
from phonenumber_field.modelfields import PhoneNumberField from phonenumber_field.modelfields import PhoneNumberField
@ -296,6 +297,9 @@ class User(AbstractBaseUser):
USERNAME_FIELD = "username" USERNAME_FIELD = "username"
# REQUIRED_FIELDS = ['email'] # 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): def has_module_perms(self, package_name):
return self.is_active return self.is_active

View File

@ -196,10 +196,15 @@
justify-content: flex-end; justify-content: flex-end;
} }
>a>img { > a {
display: block;
width: 40px; width: 40px;
height: 40px; height: 40px;
border-radius: 50%; border-radius: 50%;
background-position: center center;
background-size: cover;
background-repeat: no-repeat;
background-color: #354a5f;
} }
>.options { >.options {

View File

@ -145,6 +145,7 @@
} }
> a { > a {
box-sizing: border-box;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
@ -181,6 +182,16 @@
object-fit: contain; object-fit: contain;
border-radius: 50%; 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;
}
} }
} }
} }

View File

@ -61,6 +61,21 @@ main {
width: 5em; width: 5em;
margin: 0.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 { > .user_profile_infos_items {

View File

@ -56,6 +56,7 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
max-width: 300px; max-width: 300px;
margin-top: 10px;
@media (max-width: 750px) { @media (max-width: 750px) {
max-width: 100%; max-width: 100%;
@ -77,6 +78,7 @@
width: 100% !important; width: 100% !important;
object-fit: contain; object-fit: contain;
height: auto; height: auto;
max-height: 100%;
} }
>p { >p {

View File

@ -97,13 +97,14 @@
<a href="{{ url('core:logout') }}">{% trans %}Logout{% endtrans %}</a> <a href="{{ url('core:logout') }}">{% trans %}Logout{% endtrans %}</a>
</div> </div>
</div> </div>
<a href="{{ url('core:user_profile', user_id=user.id) }}"> <a
href="{{ url('core:user_profile', user_id=user.id) }}"
{% if user.profile_pict %} {% if user.profile_pict %}
<img src="{{ user.profile_pict.get_download_url() }}" alt="{% trans %}Profile{% endtrans %}" title="{% trans %}Profile{% endtrans %}" /> style="background-image: url('{{ user.profile_pict.get_download_url() }}')"
{% else %} {% else %}
<img src="{{ static('core/img/unknown.jpg') }}" alt="{% trans %}Profile{% endtrans %}" title="{% trans %}Profile{% endtrans %}" /> style="background-image: url('{{ static('core/img/unknown.jpg') }}')"
{% endif %} {% endif %}
</a> ></a>
</div> </div>
<div class="notification"> <div class="notification">
<a href="#" onclick="display_notif()"> <a href="#" onclick="display_notif()">

View File

@ -84,10 +84,16 @@
</div> </div>
{% if profile.promo %} {% if profile.promo %}
<br>
<div class="user_profile_infos_promo"> <div class="user_profile_infos_promo">
{% trans %}Promo: {% endtrans %}{{ profile.promo }} {% trans %}Promo: {% endtrans %}{{ profile.promo }}
<img src="{{ static('core/img/promo_%02d.png' % profile.promo) }}" {% if profile.promo_has_logo() %}
alt="Promo {{ profile.promo }}" /> <img src="{{ static('core/img/promo_%02d.png' % profile.promo) }}" alt="Promo {{ profile.promo }}" />
{% else %}
<div>
<span>¯\_(ツ)_/¯</span>
</div>
{% endif %}
</div> </div>
{% endif %} {% endif %}
</div> </div>

View File

@ -29,8 +29,12 @@
{%- endif -%} {%- endif -%}
</div> </div>
<div class="profile-picture-edit"> <div class="profile-picture-edit">
{%- if form["profile_pict"] -%}
<p>{{ form["profile_pict"].label }}</p> <p>{{ form["profile_pict"].label }}</p>
{{ form["profile_pict"] }} {{ form["profile_pict"] }}
{%- else -%}
<em>{% trans %}To edit your profile picture, ask a member of the AE{% endtrans %}</em>
{%- endif -%}
{%- if user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) and form.instance.profile_pict.id -%} {%- if user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) and form.instance.profile_pict.id -%}
<a href="{{ url('core:file_delete', file_id=form.instance.profile_pict.id, popup='') }}"> <a href="{{ url('core:file_delete', file_id=form.instance.profile_pict.id, popup='') }}">
{%- trans -%}Delete{%- endtrans -%} {%- trans -%}Delete{%- endtrans -%}

View File

@ -14,6 +14,7 @@
# #
# #
import os
import subprocess import subprocess
import re import re
@ -71,6 +72,10 @@ def get_semester(d=date.today()):
return "A" + str(start.year)[-2:] return "A" + str(start.year)[-2:]
def file_exist(path):
return os.path.exists(path)
def scale_dimension(width, height, long_edge): def scale_dimension(width, height, long_edge):
if width > height: if width > height:
ratio = long_edge * 1.0 / width ratio = long_edge * 1.0 / width

View File

@ -3246,6 +3246,10 @@ msgstr "Changer mon mot de passe"
msgid "Change user password" msgid "Change user password"
msgstr "Changer le mot de passe" 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 #: core/templates/core/user_godfathers.jinja:5
#, python-format #, python-format
msgid "%(user_name)s's family" msgid "%(user_name)s's family"

View File

@ -144,7 +144,7 @@
<li> <li>
<a class="user" href="{{ r.user.get_absolute_url() }}"> <a class="user" href="{{ r.user.get_absolute_url() }}">
{% if r.user.profile_pict %} {% if r.user.profile_pict %}
<img src="{{ r.user.profile_pict.get_download_url() }}"> <div class="profile-pic" style="background-image: url('{{ r.user.profile_pict.get_download_url() }}');"></div>
{% endif %} {% endif %}
<span>{{ r.user.get_short_name() }}</span> <span>{{ r.user.get_short_name() }}</span>
</a> </a>