Support both old-style avatar URLs and new-style upload avatar files
This commit is contained in:
parent
03e54bbc3f
commit
3618ba6def
8 changed files with 15 additions and 9 deletions
|
@ -45,10 +45,10 @@ class UserProfile(models.Model):
|
|||
return "Unknown Profile"
|
||||
|
||||
def avatar_url(self):
|
||||
if self.avatar.url.startswith('http'):
|
||||
return self.avatar.url
|
||||
if self.avatar.name.startswith('http'):
|
||||
return self.avatar.name
|
||||
else:
|
||||
return settings.MEDIA_URL + '/' + self.avatar.url
|
||||
return self.avatar.url
|
||||
|
||||
def get_timezone(self):
|
||||
try:
|
||||
|
|
|
@ -72,7 +72,7 @@ form {
|
|||
{% if request.user.is_authenticated %}
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarUserMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<img class="rounded-circle mr-1" src="{{request.user.profile.avatar.url}}" height="24px"/>{% if request.user.profile.realname %}{{ request.user.profile.realname }}{% else %}{{ request.user.username }}{% endif %}
|
||||
<img class="rounded-circle mr-1" src="{{request.user.profile.avatar_url}}" height="24px"/>{% if request.user.profile.realname %}{{ request.user.profile.realname }}{% else %}{{ request.user.username }}{% endif %}
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="navbarUserMenuLink">
|
||||
<a class="dropdown-item" href="{% url 'show-profile' request.user.profile.id %}">Profile</a>
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
{% for attendee in attendee_list %}
|
||||
<div class="row mb-3">
|
||||
<div class="col media gt-profile">
|
||||
<img class="mr-1 gt-profile-avatar" src="{{attendee.user.avatar.url}}" width="32px" height="32px">
|
||||
<img class="mr-1 gt-profile-avatar" src="{{attendee.user.avatar_url}}" width="32px" height="32px">
|
||||
<span class="gt-profile-badges">{% for badge in attendee.user.user.account.badges.all %}<img class="mr-0 gt-profile-badge" src="{{badge.img_url}}" title="{{badge.name}}" width="16px" height="16px">{% endfor %}</span>
|
||||
<div class="media-body">
|
||||
<h6 class="mt-2 mb-0">
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<div class="row">
|
||||
<div class="col-12">
|
||||
<center>
|
||||
<p><img class="align-bottom" border="1" src="{{profile.avatar.url}}" height="64px"/></p>
|
||||
<p><img class="align-bottom" border="1" src="{{profile.avatar_url}}" height="64px"/></p>
|
||||
<h3>Please confirm your profile information</h3>
|
||||
|
||||
<form action="{% url 'setup-1-confirm-profile' %}" method="POST" class="form">
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
{% for member in member_list %}
|
||||
<div class="row mb-3">
|
||||
<div class="col media gt-profile">
|
||||
<img class="mr-1 gt-profile-avatar" src="{{member.user.avatar.url}}" width="32px" height="32px">
|
||||
<img class="mr-1 gt-profile-avatar" src="{{member.user.avatar_url}}" width="32px" height="32px">
|
||||
<span class="gt-profile-badges">{% for badge in member.user.user.account.badges.all %}<img class="mr-0 gt-profile-badge" src="{{badge.img_url}}" title="{{badge.name}}" width="16px" height="16px">{% endfor %}</span>
|
||||
<div class="media-body">
|
||||
<h6 class="mt-0 mb-0"><a href="{% url 'show-profile' member.user.id %}" title="{{member.user}}'s profile">{{member.user}}</a></h6>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<img class="align-bottom" border="1" src="{{profile.avatar.url}}" height="128px"/>
|
||||
<img class="align-bottom" border="1" src="{{profile.avatar_url}}" height="128px"/>
|
||||
<h2>Profile: {{user}}</h2>
|
||||
<form enctype="multipart/form-data" action="{% url "edit-profile" %}" method="post">
|
||||
{% csrf_token %}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<div class="col-md-2"></div>
|
||||
<div class="col-md-6">
|
||||
<div class="h2">
|
||||
<img class="align-bottom" border="1" src="{{user.avatar.url}}" height="128px"/> {{user.user}}
|
||||
<img class="align-bottom" border="1" src="{{user.avatar_url}}" height="128px"/> {{user.user}}
|
||||
{% if user.user.id == request.user.id %}
|
||||
<a href="{% url 'edit-profile' %}" class="btn btn-secondary btn-sm">Edit Profile</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -5,13 +5,19 @@ decorator==4.2.1
|
|||
defusedxml==0.5.0
|
||||
dj-database-url==0.4.2
|
||||
Django==2.0
|
||||
django-appconf==1.0.2
|
||||
django-imagekit==4.0.2
|
||||
django-imagekit-cropper==1.16
|
||||
django-settings-export==1.2.1
|
||||
djangorestframework==3.7.7
|
||||
future==0.16.0
|
||||
geocoder==1.36.0
|
||||
idna==2.6
|
||||
Markdown==2.6.11
|
||||
model-mommy==1.5.1
|
||||
oauthlib==2.0.6
|
||||
pilkit==2.0
|
||||
Pillow==5.0.0
|
||||
PyJWT==1.5.3
|
||||
python3-openid==3.1.0
|
||||
pytz==2017.3
|
||||
|
|
Loading…
Reference in a new issue