diff --git a/ivatar/ivataraccount/models.py b/ivatar/ivataraccount/models.py index 6a06fb2..a271a79 100644 --- a/ivatar/ivataraccount/models.py +++ b/ivatar/ivataraccount/models.py @@ -24,6 +24,8 @@ from openid.association import Association as OIDAssociation from openid.store import nonce as oidnonce from openid.store.interface import OpenIDStore +from libravatar import libravatar_url + from ivatar.settings import MAX_LENGTH_EMAIL, logger from ivatar.settings import MAX_PIXELS, AVATAR_MAX_SIZE, JPEG_QUALITY from ivatar.settings import MIN_LENGTH_URL, MAX_LENGTH_URL @@ -127,6 +129,9 @@ class Photo(BaseAccountModel): if gravatar: image_url = gravatar['image_url'] + if service_name == 'Libravatar': + image_url = libravatar_url(email_address) + if not image_url: return False # pragma: no cover try: diff --git a/ivatar/ivataraccount/templates/_import_photo_form.html b/ivatar/ivataraccount/templates/_import_photo_form.html index ba3964c..3098117 100644 --- a/ivatar/ivataraccount/templates/_import_photo_form.html +++ b/ivatar/ivataraccount/templates/_import_photo_form.html @@ -4,12 +4,20 @@ {% if not user.is_anonymous %} {% if photos %}

{% trans 'Would you like to import some of these externally hosted photos?' %}

-
{% csrf_token %} + {% if email_id %} + {% csrf_token %} + {% else %} + {% csrf_token %} + + {% endif %}