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 GitHub
parent 4830c3ea2d
commit e638bc04ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
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

View File

@ -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 {

View File

@ -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;
}
}
}
}

View File

@ -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 {

View File

@ -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 {

View File

@ -97,13 +97,14 @@
<a href="{{ url('core:logout') }}">{% trans %}Logout{% endtrans %}</a>
</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 %}
<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 %}
<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 %}
</a>
></a>
</div>
<div class="notification">
<a href="#" onclick="display_notif()">

View File

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

View File

@ -29,8 +29,12 @@
{%- endif -%}
</div>
<div class="profile-picture-edit">
{%- if form["profile_pict"] -%}
<p>{{ form["profile_pict"].label }}</p>
{{ 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 -%}
<a href="{{ url('core:file_delete', file_id=form.instance.profile_pict.id, popup='') }}">
{%- trans -%}Delete{%- endtrans -%}

View File

@ -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

View File

@ -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"

View File

@ -144,7 +144,7 @@
<li>
<a class="user" href="{{ r.user.get_absolute_url() }}">
{% 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 %}
<span>{{ r.user.get_short_name() }}</span>
</a>