better avatar pic: use name initial as avatar
This commit is contained in:
parent
83abbe5406
commit
28d475ea22
|
@ -24,8 +24,9 @@
|
||||||
<div class="form-label">Profile picture</div>
|
<div class="form-label">Profile picture</div>
|
||||||
{{ form.profile_picture(class="form-control-file") }}
|
{{ form.profile_picture(class="form-control-file") }}
|
||||||
{{ render_field_errors(form.profile_picture) }}
|
{{ render_field_errors(form.profile_picture) }}
|
||||||
|
{% if current_user.profile_picture_id %}
|
||||||
<img src="{{ current_user.profile_picture_url() }}" class="profile-picture">
|
<img src="{{ current_user.profile_picture_url() }}" class="profile-picture">
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-primary">Update</button>
|
<button class="btn btn-primary">Update</button>
|
||||||
|
|
|
@ -230,6 +230,10 @@ class User(db.Model, ModelMixin, UserMixin):
|
||||||
|
|
||||||
return self.name, [other_name, "Anonymous", "whoami"]
|
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):
|
class ActivationCode(db.Model, ModelMixin):
|
||||||
"""For activate user account"""
|
"""For activate user account"""
|
||||||
|
|
|
@ -23,7 +23,12 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<a href="#" class="nav-link pr-0 leading-none" data-toggle="dropdown">
|
<a href="#" class="nav-link pr-0 leading-none" data-toggle="dropdown">
|
||||||
<span class="avatar" style="background-image: url('{{ current_user.profile_picture_url() }}')"></span>
|
{% if current_user.profile_picture_id %}
|
||||||
|
<span class="avatar" style="background-image: url('{{ current_user.profile_picture_url() }}')"></span>
|
||||||
|
{% else %}
|
||||||
|
<span class="avatar avatar-blue">{{ current_user.get_name_initial() }}</span>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<span class="ml-2 d-none d-lg-block">
|
<span class="ml-2 d-none d-lg-block">
|
||||||
<span class="text-default">{{ current_user.name }}</span>
|
<span class="text-default">{{ current_user.name }}</span>
|
||||||
<small class="text-muted d-block mt-1">{{ current_user.email }}</small>
|
<small class="text-muted d-block mt-1">{{ current_user.email }}</small>
|
||||||
|
|
Loading…
Reference in a new issue