From 96237bb47e7571de4dc6d346e6997bffc92165b4 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Tue, 10 Jul 2018 14:46:30 +0200 Subject: [PATCH] Ability to import from libravatar + import by email; Forms are WIP! --- ivatar/ivataraccount/models.py | 5 + .../templates/_import_photo_form.html | 14 ++- .../ivataraccount/templates/import_photo.html | 13 +++ ivatar/ivataraccount/urls.py | 6 ++ ivatar/ivataraccount/views.py | 91 ++++++++++++++++--- ivatar/views.py | 10 +- 6 files changed, 119 insertions(+), 20 deletions(-) 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 %}