Ajout de la liste des utilisateurs

This commit is contained in:
augustin64 2022-08-18 14:54:55 +02:00
parent 89cec8ef35
commit f36bc93e32
4 changed files with 31 additions and 0 deletions

View File

@ -57,6 +57,7 @@ def album(uuid):
"""
try:
album = Album(uuid=uuid)
album.users = [User(i["id"]) for i in album.get_users()]
user = User(session.get("user_id"))
partitions = album.get_partitions()
if user.id is None:

View File

@ -208,3 +208,18 @@ input[type=submit] {
font-size: .7rem;
font-weight: lighter;
}
.user-profile-picture {
width: 25px;
height: 22px;
text-align: center;
padding-top: 3px;
border-radius: 20px;
border-width: 1px;
border-color: black;
margin: 1px;
}
#users-list {
display: flex;
}

View File

@ -5,6 +5,13 @@
{% endblock %}
{% block header_actions %}
<div id="users-list">
{% for user in album.users %}
<div class="user-profile-picture" style="background-color:{{ user.color }};" title="{{ user.username }}">
{{ user.username[0] | upper }}
</div>
{% endfor %}
</div>
{% if not_participant %}
<a class="button-href" href="/albums/{{ album.uuid }}/join">
<button id="join-album">Rejoindre</button>

View File

@ -21,6 +21,7 @@ class User():
).fetchone()
self.username = data["username"]
self.access_level = data["access_level"]
self.color = self.get_color()
def is_participant(self, album_uuid):
@ -71,6 +72,11 @@ class User():
db.commit()
def get_color(self):
integer = int.from_bytes(self.username.encode(), "little") % 16777215
return "#" + str(hex(integer))[2:]
class Album():
def __init__(self, uuid=None, id=None):
@ -106,6 +112,8 @@ class Album():
else:
raise LookupError
self.users = None
def get_users(self):
"""