mirror of
https://github.com/partitioncloud/partitioncloud-server.git
synced 2025-01-23 17:26:26 +01:00
Added user colors (depends on the css)
Planning to put them in the config later (or maybe adding themes, but not today)
This commit is contained in:
parent
781134f4a4
commit
ea04e8271e
@ -4,6 +4,24 @@ from .db import get_db
|
|||||||
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
|
# Variables defined in the CSS
|
||||||
|
colors = [
|
||||||
|
"--color-rosewater",
|
||||||
|
"--color-flamingo",
|
||||||
|
"--color-pink",
|
||||||
|
"--color-mauve",
|
||||||
|
"--color-red",
|
||||||
|
"--color-maroon",
|
||||||
|
"--color-peach",
|
||||||
|
"--color-yellow",
|
||||||
|
"--color-green",
|
||||||
|
"--color-teal",
|
||||||
|
"--color-sky",
|
||||||
|
"--color-sapphire",
|
||||||
|
"--color-blue",
|
||||||
|
"--color-lavender"
|
||||||
|
]
|
||||||
|
|
||||||
class User():
|
class User():
|
||||||
def __init__(self, user_id=None, name=None):
|
def __init__(self, user_id=None, name=None):
|
||||||
self.id = user_id
|
self.id = user_id
|
||||||
@ -130,8 +148,11 @@ class User():
|
|||||||
|
|
||||||
|
|
||||||
def get_color(self):
|
def get_color(self):
|
||||||
integer = hash(self.username) % 16777215
|
if len(colors) == 0:
|
||||||
return "#" + str(hex(integer))[2:]
|
integer = hash(self.username) % 16777215
|
||||||
|
return "#" + str(hex(integer))[2:]
|
||||||
|
else:
|
||||||
|
return f"var({colors[hash(self.username) %len(colors)]})"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<h1>Albums</h1>
|
<h1>Albums</h1>
|
||||||
<section id="albums">
|
<section id="albums">
|
||||||
{% if user.get_albums() |length != 0 %}
|
{% if g.user and user.get_albums() | length != 0 %}
|
||||||
{% for album in user.albums %}
|
{% for album in user.albums %}
|
||||||
<a href="/albums/{{ album['uuid'] }}">
|
<a href="/albums/{{ album['uuid'] }}">
|
||||||
<div class="album-cover" id="album-1">
|
<div class="album-cover" id="album-1">
|
||||||
@ -74,20 +74,20 @@
|
|||||||
</svg>
|
</svg>
|
||||||
Déconnexion
|
Déconnexion
|
||||||
</button><br/>
|
</button><br/>
|
||||||
|
{% if g.user.access_level == 1 %}
|
||||||
|
<button href="/admin">Panneau admin</button><br/>
|
||||||
|
{% endif %}
|
||||||
|
<div class="user">
|
||||||
|
<div class="user-profile-picture" style="background-color:{{ user.color }};"
|
||||||
|
title="{{ user.username }}">
|
||||||
|
{{ user.username[0] | upper }}
|
||||||
|
</div>
|
||||||
|
<div class="username">{{ user.username }}</div>
|
||||||
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<button href="{{ url_for('auth.register') }}">Créer un compte</button>
|
<button href="{{ url_for('auth.register') }}">Créer un compte</button>
|
||||||
<button href="{{ url_for('auth.login') }}">Se connecter</button>
|
<button href="{{ url_for('auth.login') }}">Se connecter</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if g.user.access_level == 1 %}
|
|
||||||
<button href="/admin">Panneau admin</button><br/>
|
|
||||||
{% endif %}
|
|
||||||
<div class="user">
|
|
||||||
<div class="user-profile-picture" style="background-color:var(--color-pink);"
|
|
||||||
title="augustin64">
|
|
||||||
A
|
|
||||||
</div>
|
|
||||||
<div class="username">augustin64</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="content-container">
|
<div id="content-container">
|
||||||
|
Loading…
Reference in New Issue
Block a user