From f36bc93e321211ff80f8726879fb7451b8ca8d64 Mon Sep 17 00:00:00 2001 From: augustin64 Date: Thu, 18 Aug 2022 14:54:55 +0200 Subject: [PATCH] Ajout de la liste des utilisateurs --- partitioncloud/albums.py | 1 + partitioncloud/static/style.css | 15 +++++++++++++++ partitioncloud/templates/albums/album.html | 7 +++++++ partitioncloud/utils.py | 8 ++++++++ 4 files changed, 31 insertions(+) diff --git a/partitioncloud/albums.py b/partitioncloud/albums.py index 8265d15..a4686c1 100644 --- a/partitioncloud/albums.py +++ b/partitioncloud/albums.py @@ -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: diff --git a/partitioncloud/static/style.css b/partitioncloud/static/style.css index 0baf9fc..0b09002 100644 --- a/partitioncloud/static/style.css +++ b/partitioncloud/static/style.css @@ -207,4 +207,19 @@ input[type=submit] { #online-search-label { 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; } \ No newline at end of file diff --git a/partitioncloud/templates/albums/album.html b/partitioncloud/templates/albums/album.html index ce7bcd4..a0987ac 100644 --- a/partitioncloud/templates/albums/album.html +++ b/partitioncloud/templates/albums/album.html @@ -5,6 +5,13 @@ {% endblock %} {% block header_actions %} +
+ {% for user in album.users %} + + {% endfor %} +
{% if not_participant %} diff --git a/partitioncloud/utils.py b/partitioncloud/utils.py index 15db7cf..7962054 100644 --- a/partitioncloud/utils.py +++ b/partitioncloud/utils.py @@ -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): @@ -105,6 +111,8 @@ class Album(): else: raise LookupError + + self.users = None def get_users(self):