From 28d475ea226acde7e43aa8eff0aadeba7cea315e Mon Sep 17 00:00:00 2001 From: Son NK Date: Fri, 16 Aug 2019 11:57:19 +0200 Subject: [PATCH] better avatar pic: use name initial as avatar --- app/dashboard/templates/dashboard/setting.html | 5 +++-- app/models.py | 4 ++++ templates/header.html | 7 ++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/dashboard/templates/dashboard/setting.html b/app/dashboard/templates/dashboard/setting.html index 89407e08..751a5748 100644 --- a/app/dashboard/templates/dashboard/setting.html +++ b/app/dashboard/templates/dashboard/setting.html @@ -24,8 +24,9 @@
Profile picture
{{ form.profile_picture(class="form-control-file") }} {{ render_field_errors(form.profile_picture) }} - - + {% if current_user.profile_picture_id %} + + {% endif %} diff --git a/app/models.py b/app/models.py index ab2db8ba..95e041e8 100644 --- a/app/models.py +++ b/app/models.py @@ -230,6 +230,10 @@ class User(db.Model, ModelMixin, UserMixin): return self.name, [other_name, "Anonymous", "whoami"] + def get_name_initial(self) -> str: + names = self.name.split(" ") + return "".join([n[0].upper() for n in names if n]) + class ActivationCode(db.Model, ModelMixin): """For activate user account""" diff --git a/templates/header.html b/templates/header.html index 7997407b..046ef5de 100644 --- a/templates/header.html +++ b/templates/header.html @@ -23,7 +23,12 @@