From 4d3e1a14f34611b077763384fd5fbc52ca47941b Mon Sep 17 00:00:00 2001 From: Darks Date: Sun, 19 Jul 2020 21:14:34 +0200 Subject: [PATCH] =?UTF-8?q?profil:=20compl=C3=A9tion=20de=20la=20page=20de?= =?UTF-8?q?=20profil=20(#9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routes/users.py | 4 +- app/static/css/global.css | 39 --------------- app/static/css/theme.css | 7 +++ app/static/css/widgets.css | 71 ++++++++++++++++++++++++++ app/templates/account/user.html | 88 +++++++++++++++++++++++++++------ app/utils/date.py | 4 +- app/utils/render.py | 1 + 7 files changed, 156 insertions(+), 58 deletions(-) create mode 100644 app/static/css/widgets.css diff --git a/app/routes/users.py b/app/routes/users.py index fa755ad..72a57b0 100644 --- a/app/routes/users.py +++ b/app/routes/users.py @@ -3,6 +3,7 @@ from werkzeug.utils import secure_filename import os.path from app import app from app.models.users import Member +from app.models.trophies import Trophy from app.utils import unicode_names from app.utils.render import render from config import V5Config @@ -12,7 +13,8 @@ from config import V5Config def user(username): norm = unicode_names.normalize(username) member = Member.query.filter_by(norm=norm).first_or_404() - return render('account/user.html', member=member) + trophies = Trophy.query.all() + return render('account/user.html', member=member, trophies=trophies) @app.route('/membre/id/') diff --git a/app/static/css/global.css b/app/static/css/global.css index c969d63..2ab8d01 100644 --- a/app/static/css/global.css +++ b/app/static/css/global.css @@ -58,45 +58,6 @@ input[type="submit"]:hover, text-decoration: none; } -/* Profile summaries */ - -.profile { - display: flex; - align-items: center; -} -.profile-avatar { - width: 128px; - height: 128px; - margin-right: 16px; -} -.profile-name { - font-weight: bold; -} -.profile-title { - margin-bottom: 8px; -} -.profile-points { - font-size: 11px; -} -.profile-points span { - color: gray; -} -.profile-points-small { - display: none; -} -.profile-xp { - height: 10px; - min-width: 96px; - background: #e0e0e0; - border: 1px solid #c0c0c0; -} -.profile-xp div { - height: 10px; - background: #f85555; - border: 1px solid #d03333; - margin: -1px; -} - @media screen and (max-width: 1499px) { .profile-avatar { diff --git a/app/static/css/theme.css b/app/static/css/theme.css index 5542800..4565dfd 100644 --- a/app/static/css/theme.css +++ b/app/static/css/theme.css @@ -88,3 +88,10 @@ footer { --btn-text: #000000; --btn-bg-active: rgba(0, 0, 0, .15); } + +.profile-xp { + --background: #e0e0e0; + --border: 1px solid #c0c0c0; + --background-xp: #f85555; + --border-xp: 1px solid #d03333; +} diff --git a/app/static/css/widgets.css b/app/static/css/widgets.css new file mode 100644 index 0000000..8602857 --- /dev/null +++ b/app/static/css/widgets.css @@ -0,0 +1,71 @@ +/* Profile summaries */ + +.profile { + display: flex; + align-items: center; +} +.profile-avatar { + width: 128px; + height: 128px; + margin-right: 16px; +} +.profile-name { + font-weight: bold; +} +.profile-title { + margin-bottom: 8px; +} +.profile-points { + font-size: 11px; +} +.profile-points span { + color: gray; +} +.profile-points-small { + display: none; +} +.profile-xp { + height: 10px; + min-width: 96px; + background: var(--background); + border: var(--border); +} +.profile-xp div { + height: 10px; + background: var(--background-xp); + border: var(--border-xp); + margin: -1px; +} + + +/* Trophies */ +.trophies { + display: flex; flex-wrap: wrap; justify-content: space-between; +} +.trophy { + display: flex; align-items: center; + width: 260px; + margin: 5px; padding: 5px; + border: 1px solid #c5c5c5; + border-left: 5px solid var(--links); + border-radius: 2px; +} +.trophy img { + height: 50px; margin-right: 5px; +} +.trophy div > * { + display: block; +} +.trophy em { + font-style: normal; font-weight: bold; + margin-bottom: 3px; +} +.trophy span { + font-size: 80%; +} + +.trophy.disabled { + filter: grayscale(100%); + opacity: .5; + border-left: 1px solid #c5c5c5; +} diff --git a/app/templates/account/user.html b/app/templates/account/user.html index 6caa89a..d9a0d1c 100644 --- a/app/templates/account/user.html +++ b/app/templates/account/user.html @@ -7,27 +7,83 @@ {% block content %}
- {{ widget_member.profile(member) }} +
+
+ {{ widget_member.profile(member) }} + {% if current_user.is_authenticated %} + {% if current_user == member %} + + {% elif current_user.priv('access-admin-panel') %} + + {% endif %} + {% endif %} - {% if current_user.is_authenticated %} - {% if current_user == member %} - - {% elif current_user.priv('access-admin-panel') %} - - {% endif %} - {% endif %} + +
+
+
+ {{ member.signature }} +
+
+ Membre depuis le {{ member.register_date|date('%Y-%m-%d') }} +
+
+
+ +

Présentation

+
+ {{ member.bio }} +
+ +

Groupes

- {% if member.trophies %}
    - {% for t in member.trophies %} -
  • {{ t.name }}
  • + {% for g in member.groups %} +
  • {{ g.name }}
  • {% endfor %}
- {% else %} - Aucun trophée. - {% endif %} -
+ + +

Trophées

+
+ {% for t in trophies %} +
+ +
+ {{ t.name }} + Avoir posté 50 messages sur le forum +
+
+ {% endfor %} +
+ +

Programmes

+
+ Ici y'aura les programmes +
+ +

Topics

+
+ + + + + + + + {% for t in member.posts if t.type == "topic" %} + + + + + + + {% endfor %} +
TitreForumCréationCommentaires
{{ t.title }}{{ t.forum.name }}Le {{ t.date_created|date }}{{ t.thread.comments.count() }}
+
{% endblock %} diff --git a/app/utils/date.py b/app/utils/date.py index 8dd1186..3bf0a85 100644 --- a/app/utils/date.py +++ b/app/utils/date.py @@ -1,9 +1,9 @@ from app import app @app.template_filter('date') -def filter_date(date): +def filter_date(date, format="%Y-%m-%d à %H:%M"): """ Print a date in a human-readable format. """ - return date.strftime("%d %b %Y à %H:%M") + return date.strftime(format) diff --git a/app/utils/render.py b/app/utils/render.py index 0beb0d2..db0f2b1 100644 --- a/app/utils/render.py +++ b/app/utils/render.py @@ -19,6 +19,7 @@ def render(*args, styles=[], scripts=[], **kwargs): 'css/navbar.css', 'css/header.css', 'css/container.css', + 'css/widgets.css', 'css/editor.css', 'css/form.css', 'css/footer.css',