diff --git a/db.py b/db.py index 5bb93dfa..7aed3e72 100644 --- a/db.py +++ b/db.py @@ -21,9 +21,10 @@ import loldata from dirty import Dirty import query_discord_music from flask import escape +import libgravatar +import configparser # Init the config reader -import configparser config = configparser.ConfigParser() config.read("config.ini") @@ -47,6 +48,7 @@ class Royal(Base): role = Column(String) fiorygi = Column(Integer, default=0) member_since = Column(Date) + email = Column(String) @staticmethod def create(session: Session, username: str): @@ -58,6 +60,12 @@ class Royal(Base): def __repr__(self): return f"" + def get_gravatar_url(self): + if self.email is None: + return f"https://www.gravatar.com/avatar/{libgravatar.md5_hash(self.username)}?d=identicon&f=y" + gravatar = libgravatar.Gravatar(self.email) + return gravatar.get_image(default="identicon") + class Telegram(Base): __tablename__ = "telegram" diff --git a/requirements.txt b/requirements.txt index dea73f34..302919b3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,4 +15,5 @@ praw dice raven[flask] coloredlogs -sentry_sdk \ No newline at end of file +sentry_sdk +libgravatar \ No newline at end of file diff --git a/static/nryg.less b/static/nryg.less index cbb3ce59..357aca5c 100644 --- a/static/nryg.less +++ b/static/nryg.less @@ -241,6 +241,13 @@ img { } } +.gravatar { + border-radius: 16px; + width: 32px; + height: 32px; + vertical-align: middle; +} + .whatsthis { font-size: large; } @@ -713,6 +720,10 @@ img { grid-column-start: 1; grid-column-end: 3; font-weight: bold; + + .player-image { + border-radius: 16px; + } } .member-status { diff --git a/templates/base.html b/templates/base.html index 72ae1a97..3609c711 100644 --- a/templates/base.html +++ b/templates/base.html @@ -24,6 +24,7 @@ {% endif %} {% if g.user is not none %} + {{ g.user.username }} Logout {% else %} diff --git a/templates/minis/ryg.html b/templates/minis/ryg.html index 0fde5b94..da3ed4ae 100644 --- a/templates/minis/ryg.html +++ b/templates/minis/ryg.html @@ -1,7 +1,7 @@
{{ record.role }} dal {% if record.member_since %}{{ record.member_since }}{% else %}????-??-??{% endif %}