From c5f493178c1248ce5beb19d966096b3ab753f85b Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Thu, 15 Apr 2021 13:13:23 +0200 Subject: [PATCH 01/12] Fix overwriting verification key upon sending confirmation mail --- ivatar/ivataraccount/models.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ivatar/ivataraccount/models.py b/ivatar/ivataraccount/models.py index 3f73fb1..1d7b97a 100644 --- a/ivatar/ivataraccount/models.py +++ b/ivatar/ivataraccount/models.py @@ -359,11 +359,12 @@ class UnconfirmedEmail(BaseAccountModel): def save(self, force_insert=False, force_update=False, using=None, update_fields=None): - hash_object = hashlib.new('sha256') - hash_object.update( - urandom(1024) + self.user.username.encode('utf-8') # pylint: disable=no-member - ) # pylint: disable=no-member - self.verification_key = hash_object.hexdigest() + if not self.verification_key: + hash_object = hashlib.new('sha256') + hash_object.update( + urandom(1024) + self.user.username.encode('utf-8') # pylint: disable=no-member + ) # pylint: disable=no-member + self.verification_key = hash_object.hexdigest() super(UnconfirmedEmail, self).save( force_insert, force_update, From a346bc628589bfa3d0305d30df150def1611ae86 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Wed, 21 Apr 2021 15:15:02 +0200 Subject: [PATCH 02/12] JSON of course return json, but also normal web requests --- ivatar/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ivatar/views.py b/ivatar/views.py index d3de012..57f21f0 100644 --- a/ivatar/views.py +++ b/ivatar/views.py @@ -411,7 +411,8 @@ class StatsView(TemplateView, JsonResponse): 'openids': ConfirmedOpenId.objects.all().count(), # pylint: disable=no-member } - if request.content_type == 'application/json': + # JSON of course return json, but also normal web requests default to JSON + if request.content_type == 'application/json' or request.content_type == 'text/plain': return JsonResponse(retval) return HttpResponseRedirect(reverse_lazy('home')) From b52244b16791a388061edbd2c449e7a99ad246b2 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Wed, 21 Apr 2021 15:29:16 +0200 Subject: [PATCH 03/12] We also need to handle 'text/html' this way --- ivatar/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ivatar/views.py b/ivatar/views.py index 57f21f0..09e474b 100644 --- a/ivatar/views.py +++ b/ivatar/views.py @@ -412,7 +412,7 @@ class StatsView(TemplateView, JsonResponse): } # JSON of course return json, but also normal web requests default to JSON - if request.content_type == 'application/json' or request.content_type == 'text/plain': + if request.content_type in ('application/json', 'text/plain', 'text/html'): return JsonResponse(retval) return HttpResponseRedirect(reverse_lazy('home')) From 5733448830ae71fa4b4f18f5b5a6f518e6fc4b65 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Wed, 21 Apr 2021 15:41:05 +0200 Subject: [PATCH 04/12] Just default to sending JSON - everything else seems not to work correctly --- ivatar/views.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ivatar/views.py b/ivatar/views.py index 09e474b..49a8b33 100644 --- a/ivatar/views.py +++ b/ivatar/views.py @@ -411,8 +411,4 @@ class StatsView(TemplateView, JsonResponse): 'openids': ConfirmedOpenId.objects.all().count(), # pylint: disable=no-member } - # JSON of course return json, but also normal web requests default to JSON - if request.content_type in ('application/json', 'text/plain', 'text/html'): - return JsonResponse(retval) - - return HttpResponseRedirect(reverse_lazy('home')) + return JsonResponse(retval) From ca9f83984a21b3ac1755605655c6195d09772c4a Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Thu, 22 Apr 2021 07:43:32 +0200 Subject: [PATCH 05/12] Add patch from #81 (install instruction for Pillow) --- INSTALL.md | 1 + 1 file changed, 1 insertion(+) diff --git a/INSTALL.md b/INSTALL.md index da3e500..ee596c4 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -23,6 +23,7 @@ cd ivatar virtualenv -p python3 .virtualenv source .virtualenv/bin/activate pip install -r requirements.txt +pip install pillow ~~~~ ## (SQL) Migrations From 73fca0b953628bc6d95f1dde0f528fa7e3c8bf1e Mon Sep 17 00:00:00 2001 From: Sheogorath Date: Thu, 27 May 2021 02:05:27 +0200 Subject: [PATCH 06/12] Add newer version of matrix contact page This patch provides a first draft for the new matrix contact details. It'S not perfect yet, since the matrix room name is still cumbersome. However, this should be fixed in the future and currently the matrix.to link should manage most of the directions. --- templates/contact.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/templates/contact.html b/templates/contact.html index 6d02405..499bebe 100644 --- a/templates/contact.html +++ b/templates/contact.html @@ -14,9 +14,7 @@ There are a few ways to get in touch with the ivatar/libravatar developers:

IRC

-If you have an IRC client already, you can join #libravatar on chat.freenode.net. -
-Otherwise, you can use this simple web interface. +You can join the Libravatar community chat at #libravatar:shivering-isles.com. It is also bridged to #libravatar on irc.libera.chat for those prefering IRC.
Please keep in mind that you may live in a different timezone than most of the developers. So if you do not get a response, it's not because we're ignoring you, it's probably because we're sleeping :) From 552da91044535470ff30c2b80a813e128139162e Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 28 May 2021 15:19:51 +0200 Subject: [PATCH 07/12] Adapt for Django 3.2. See also: https://docs.djangoproject.com/en/3.2/releases/3.2/ --- .../migrations/0017_auto_20210528_1314.py | 48 +++++++++++++++++++ ivatar/settings.py | 2 + 2 files changed, 50 insertions(+) create mode 100644 ivatar/ivataraccount/migrations/0017_auto_20210528_1314.py diff --git a/ivatar/ivataraccount/migrations/0017_auto_20210528_1314.py b/ivatar/ivataraccount/migrations/0017_auto_20210528_1314.py new file mode 100644 index 0000000..411c08f --- /dev/null +++ b/ivatar/ivataraccount/migrations/0017_auto_20210528_1314.py @@ -0,0 +1,48 @@ +# Generated by Django 3.2.3 on 2021-05-28 13:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ivataraccount', '0016_auto_20210413_0904'), + ] + + operations = [ + migrations.AlterField( + model_name='confirmedemail', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='confirmedopenid', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='openidassociation', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='openidnonce', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='photo', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='unconfirmedemail', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='unconfirmedopenid', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + ] diff --git a/ivatar/settings.py b/ivatar/settings.py index 7546ee1..82cf3f0 100644 --- a/ivatar/settings.py +++ b/ivatar/settings.py @@ -118,4 +118,6 @@ PROJECT_ROOT = os.path.abspath( STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + from config import * # pylint: disable=wildcard-import,wrong-import-position,unused-wildcard-import From 7a53a182220973eb60b5a4acf3e5b92dcbaa3955 Mon Sep 17 00:00:00 2001 From: Sheogorath Date: Fri, 28 May 2021 13:46:03 +0000 Subject: [PATCH 08/12] Replace matrix room alias The new alias is `#libravatar:matrix.org` as it sounds way more official. --- templates/contact.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/contact.html b/templates/contact.html index 499bebe..30040ab 100644 --- a/templates/contact.html +++ b/templates/contact.html @@ -14,7 +14,7 @@ There are a few ways to get in touch with the ivatar/libravatar developers:

IRC

-You can join the Libravatar community chat at #libravatar:shivering-isles.com. It is also bridged to #libravatar on irc.libera.chat for those prefering IRC. +You can join the Libravatar community chat at #libravatar:matrix.org. It is also bridged to #libravatar on irc.libera.chat for those prefering IRC.
Please keep in mind that you may live in a different timezone than most of the developers. So if you do not get a response, it's not because we're ignoring you, it's probably because we're sleeping :) From d9f4a4f63418e2da644097ba416a03a55fec4375 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 28 May 2021 18:10:01 +0200 Subject: [PATCH 09/12] Add link to libera.chat --- templates/contact.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/contact.html b/templates/contact.html index 30040ab..65997d0 100644 --- a/templates/contact.html +++ b/templates/contact.html @@ -14,7 +14,7 @@ There are a few ways to get in touch with the ivatar/libravatar developers:

IRC

-You can join the Libravatar community chat at #libravatar:matrix.org. It is also bridged to #libravatar on irc.libera.chat for those prefering IRC. +You can join the Libravatar community chat at #libravatar:matrix.org. It is also bridged to #libravatar on irc.libera.chat for those prefering IRC.
Please keep in mind that you may live in a different timezone than most of the developers. So if you do not get a response, it's not because we're ignoring you, it's probably because we're sleeping :) From dcb36271795d309362d0f24c03cb1f5312b51866 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Mon, 31 May 2021 07:51:03 +0000 Subject: [PATCH 10/12] Fix reqs that ended up in master only --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d8ae36a..760b3df 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ autopep8 bcrypt defusedxml -Django<3.2 +Django django-auth-ldap django-bootstrap4 django-coverage-plugin From 9defe7617a7c6babd25722add508a3a98b6057c1 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 11 Jun 2021 11:29:12 +0200 Subject: [PATCH 11/12] Ignore a few more files --- .coveragerc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.coveragerc b/.coveragerc index b023fc9..315f343 100644 --- a/.coveragerc +++ b/.coveragerc @@ -5,6 +5,11 @@ omit = node_modules/* .virtualenv/* import_libravatar.py + requirements.txt + static/admin/* + static/humans.txt + static/img/robots.txt + [html] extra_css = coverage_extra_style.css From 0c2f039ff4a4014a7f0081be95fd86bf6b98f3d7 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Mon, 6 Sep 2021 13:27:29 +0000 Subject: [PATCH 12/12] Fix CI/CD --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 854773c..9217ca8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,6 @@ -image: docker.io/ofalk/fedora31-python3 +image: + name: quay.io/rhn_support_ofalk/fedora34-python3 + entrypoint: [ '/bin/sh', '-c' ] before_script: - virtualenv -p python3 /tmp/.virtualenv