Display user avatar in team members list and event attendee list

This commit is contained in:
Michael Hall 2018-02-01 22:52:02 -05:00
parent e15cdd7fc1
commit 76ef0160b2
3 changed files with 19 additions and 9 deletions

View file

@ -7,6 +7,7 @@ from .locale import *
import pytz
import datetime
import hashlib
class UserProfile(models.Model):
" Store profile information about a user "
@ -105,6 +106,12 @@ def _getUserProfile(self):
profile.realname = '%s %s' % (self.first_name, self.last_name)
else:
profile.realname = self.first_name
if self.email:
h = hashlib.md5()
h.update(bytearray(profile.user.email, 'utf8'))
profile.avatar = 'http://www.gravatar.com/avatar/%s.jpg?d=mm' % h.hexdigest()
profile.save()
return profile

View file

@ -37,13 +37,14 @@
<div class="col"><h4>Attendees ({{attendee_list.count}})</h4><hr/></div>
</div>
{% for attendee in attendee_list %}
<div class="row">
<div class="col"><p>
{{ attendee.user }}
<div class="row mb-3">
<div class="col media">
<img class="mr-1" src="{{attendee.user.avatar}}" width="32px" height="32px">
<div class="media-body">
<h5 class="mt-2 mb-0">{{attendee.user}} <span class="badge badge-success align-top">{{ attendee.status_name }}</span></h5>
{% if attendee.role > 0 %}<small class="text-muted">{{ attendee.role_name }}</small>{% endif %}
</p>
</div>
</div>
<div class="col-1">{{ attendee.status_name }}</div>
</div>
{% endfor %}
</div>

View file

@ -42,11 +42,13 @@
<div class="container">
<h4>Members</h4><hr/>
{% for member in member_list %}
<div class="row">
<div class="col"><p>
{{member.user}}
<div class="row mb-3">
<div class="col media">
<img class="mr-1" src="{{member.user.avatar}}" width="32px" height="32px">
<div class="media-body">
<h5 class="mt-0 mb-0">{{member.user}}</h5>
{% if member.role > 0 %}<small class="text-muted">{{ member.role_name }}</small>{% endif %}
</p>
</div>
</div>
</div>
{% endfor %}