Skip to content

Commit

Permalink
return oj logo for gravatar
Browse files Browse the repository at this point in the history
  • Loading branch information
leduythuccs committed Nov 26, 2023
1 parent 92d9d4d commit bb66fd1
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions judge/jinja2/gravatar.py
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'

0 comments on commit bb66fd1

Please sign in to comment.