From 755143ea794a8bd4bd6da41061a9709ed486e10b Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 23 Nov 2018 11:33:47 +0100 Subject: [PATCH 1/3] Also check the username the user has in his export file, will be used for the mass-import of libravatar data --- ivatar/ivataraccount/read_libravatar_export.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ivatar/ivataraccount/read_libravatar_export.py b/ivatar/ivataraccount/read_libravatar_export.py index db09992..b248399 100644 --- a/ivatar/ivataraccount/read_libravatar_export.py +++ b/ivatar/ivataraccount/read_libravatar_export.py @@ -20,6 +20,7 @@ def read_gzdata(gzdata=None): emails = [] # pylint: disable=invalid-name openids = [] # pylint: disable=invalid-name photos = [] # pylint: disable=invalid-name + username = None # pylint: disable=invalid-name if not gzdata: return False @@ -32,6 +33,11 @@ def read_gzdata(gzdata=None): print('Unknown export format: %s' % root.tag) exit(-1) + # Username + for item in root.findall('{%s}account' % SCHEMAROOT)[0].items(): + if item[0] == 'username': + username = item[1] + # Emails for email in root.findall('{%s}emails' % SCHEMAROOT)[0]: if email.tag == '{%s}email' % SCHEMAROOT: @@ -69,4 +75,5 @@ def read_gzdata(gzdata=None): 'emails': emails, 'openids': openids, 'photos': photos, + 'username': username, } From cf4974f24d76c03ea2ce6cabe26bb8f17c2fd637 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 23 Nov 2018 12:46:10 +0100 Subject: [PATCH 2/3] Slash at the end of OpenId is not a must, remove it --- ivatar/ivataraccount/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ivatar/ivataraccount/models.py b/ivatar/ivataraccount/models.py index ca1c823..304a858 100644 --- a/ivatar/ivataraccount/models.py +++ b/ivatar/ivataraccount/models.py @@ -448,8 +448,8 @@ class ConfirmedOpenId(BaseAccountModel): lowercase_url = urlunsplit( (url.scheme.lower(), netloc, url.path, url.query, url.fragment) ) - if lowercase_url[-1] != '/': - lowercase_url += '/' + #if lowercase_url[-1] != '/': + # lowercase_url += '/' self.openid = lowercase_url self.digest = hashlib.sha256(lowercase_url.encode('utf-8')).hexdigest() return super().save(force_insert, force_update, using, update_fields) From 2643e11890e7575fc8487ec78711455528dab566 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 23 Nov 2018 12:54:12 +0100 Subject: [PATCH 3/3] Only use the value if >0, Fixes issue #21 --- ivatar/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ivatar/views.py b/ivatar/views.py index 5c2b1c7..770f15c 100644 --- a/ivatar/views.py +++ b/ivatar/views.py @@ -55,7 +55,8 @@ class AvatarImageView(TemplateView): if sizetemp: if sizetemp != '' and sizetemp is not None and sizetemp != '0': try: - size = int(sizetemp) + if int(sizetemp) > 0: + size = int(sizetemp) # Should we receive something we cannot convert to int, leave # the user with the default value of 80 except ValueError: