-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92d9d4d
commit bb66fd1
Showing
1 changed file
with
1 addition
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,6 @@ | ||
import hashlib | ||
|
||
from django.contrib.auth.models import AbstractUser | ||
from django.utils.http import urlencode | ||
|
||
from judge.models import Profile | ||
from judge.utils.unicode import utf8bytes | ||
from . import registry | ||
|
||
|
||
@registry.function | ||
def gravatar(email, size=80, default=None): | ||
if isinstance(email, Profile): | ||
if default is None: | ||
default = email.mute | ||
email = email.user.email | ||
elif isinstance(email, AbstractUser): | ||
email = email.email | ||
|
||
gravatar_url = 'https://www.gravatar.com/avatar/' + hashlib.md5(utf8bytes(email.strip().lower())).hexdigest() + '?' | ||
args = {'d': 'identicon', 's': str(size)} | ||
if default: | ||
args['f'] = 'y' | ||
gravatar_url += urlencode(args) | ||
return gravatar_url | ||
return '/static/icons/logo.svg' |