Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
4cd96999
Commit
4cd96999
authored
May 07, 2014
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid caching default avatar images
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
32523774
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
5 deletions
+15
-5
weblate/accounts/avatar.py
weblate/accounts/avatar.py
+11
-4
weblate/accounts/views.py
weblate/accounts/views.py
+4
-1
No files found.
weblate/accounts/avatar.py
View file @
4cd96999
...
...
@@ -85,6 +85,16 @@ def avatar_for_email(email, size=80):
return
url
def
get_fallback_avatar_url
(
size
):
"""
Returns URL of fallback avatar.
"""
return
os
.
path
.
join
(
settings
.
MEDIA_URL
,
'weblate-{0}.png'
.
format
(
size
)
)
def
get_fallback_avatar
(
size
):
"""
Returns fallback avatar.
...
...
@@ -167,10 +177,7 @@ def get_user_display(user, icon=True, link=False):
# Icon requested?
if
icon
and
appsettings
.
ENABLE_AVATARS
:
if
user
is
None
or
user
.
email
==
'noreply@weblate.org'
:
avatar
=
os
.
path
.
join
(
settings
.
MEDIA_URL
,
'weblate-32.png'
)
avatar
=
get_fallback_avatar_url
(
32
)
else
:
avatar
=
reverse
(
'user_avatar'
,
kwargs
=
{
'user'
:
user
.
username
,
'size'
:
32
}
...
...
weblate/accounts/views.py
View file @
4cd96999
...
...
@@ -42,7 +42,7 @@ from social.apps.django_app.utils import BACKENDS
from
social.apps.django_app.views
import
complete
import
weblate
from
weblate.accounts.avatar
import
get_avatar_image
from
weblate.accounts.avatar
import
get_avatar_image
,
get_fallback_avatar_url
from
weblate.accounts.models
import
set_lang
,
remove_user
,
Profile
from
weblate.trans.models
import
Change
,
Project
from
weblate.accounts.forms
import
(
...
...
@@ -346,6 +346,9 @@ def user_avatar(request, user, size):
'''
user
=
get_object_or_404
(
User
,
username
=
user
)
if
user
.
email
==
'noreply@weblate.org'
:
return
redirect
(
get_fallback_avatar_url
(
size
))
return
HttpResponse
(
content_type
=
'image/png'
,
content
=
get_avatar_image
(
user
,
size
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment