Skip to content

Commit

Permalink
Fixes pour la mise à jour de mars (#598)
Browse files Browse the repository at this point in the history
  • Loading branch information
Juknum committed Apr 4, 2023
1 parent 4830c3e commit e638bc0
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 12 deletions.
4 changes: 4 additions & 0 deletions core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from django.utils.functional import cached_property

import os
from core import utils

from phonenumber_field.modelfields import PhoneNumberField

Expand Down Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion core/static/core/header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions core/static/sas/picture.scss
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
}

> a {
box-sizing: border-box;
display: flex;
flex-direction: row;
align-items: center;
Expand Down Expand Up @@ -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;
}
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions core/static/user/user_detail.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions core/static/user/user_edit.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
width: 100%;
height: 100%;
max-width: 300px;
margin-top: 10px;

@media (max-width: 750px) {
max-width: 100%;
Expand All @@ -77,6 +78,7 @@
width: 100% !important;
object-fit: contain;
height: auto;
max-height: 100%;
}

>p {
Expand Down
13 changes: 7 additions & 6 deletions core/templates/core/base.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}">
{% if user.profile_pict %}
<img src="{{ user.profile_pict.get_download_url() }}" alt="{% trans %}Profile{% endtrans %}" title="{% trans %}Profile{% endtrans %}" />
<a
href="{{ url('core:user_profile', user_id=user.id) }}"
{% if user.profile_pict %}
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 %}" />
{% endif %}
</a>
style="background-image: url('{{ static('core/img/unknown.jpg') }}')"
{% endif %}
></a>
</div>
<div class="notification">
<a href="#" onclick="display_notif()">
Expand Down
10 changes: 8 additions & 2 deletions core/templates/core/user_detail.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
8 changes: 6 additions & 2 deletions core/templates/core/user_edit.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@
{%- endif -%}
</div>
<div class="profile-picture-edit">
<p>{{ form["profile_pict"].label }}</p>
{{ form["profile_pict"] }}
{%- 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 -%}
Expand Down
5 changes: 5 additions & 0 deletions core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
#

import os
import subprocess
import re

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion sas/templates/sas/picture.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit e638bc0

Please sign in to comment.