From f1c328a10c9246f208483493584fe1489f0c87b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=AD=C3=B0ir=20Valberg=20Gu=C3=B0mundsson?= Date: Mon, 18 Sep 2023 20:58:30 +0200 Subject: [PATCH] Upgrading stuff. --- .pre-commit-config.yaml | 17 ++++++++--------- requirements/base.in | 4 ++-- requirements/base.txt | 14 +++++++------- requirements/dev.in | 8 ++++---- requirements/dev.txt | 32 +++++++++++++++----------------- requirements/test.in | 4 ++-- requirements/test.txt | 18 +++++++++--------- src/accounting/admin.py | 2 -- src/accounting/models.py | 2 -- src/membership/models.py | 9 +++++++-- src/membership/permissions.py | 1 - src/project/settings.py | 1 + src/utils/mixins.py | 1 - 13 files changed, 55 insertions(+), 58 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0b7a1c8..290ad3b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,14 +16,13 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.0.209' + rev: 'v0.0.290' hooks: - id: ruff args: - - --force-exclude - --fix - repo: https://github.com/asottile/reorder_python_imports - rev: v3.9.0 + rev: v3.11.0 hooks: - id: reorder-python-imports args: @@ -31,33 +30,33 @@ repos: - --application-directories=.:src exclude: migrations/ - repo: https://github.com/asottile/pyupgrade - rev: v3.3.1 + rev: v3.11.0 hooks: - id: pyupgrade args: - --py311-plus exclude: migrations/ - repo: https://github.com/adamchainz/django-upgrade - rev: 1.12.0 + rev: 1.14.1 hooks: - id: django-upgrade args: - --target-version=4.1 - repo: https://github.com/asottile/yesqa - rev: v1.4.0 + rev: v1.5.0 hooks: - id: yesqa - repo: https://github.com/asottile/add-trailing-comma - rev: v2.4.0 + rev: v3.1.0 hooks: - id: add-trailing-comma args: - --py36-plus - repo: https://github.com/hadialqattan/pycln - rev: v2.1.2 + rev: v2.2.2 hooks: - id: pycln - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.9.1 hooks: - id: black diff --git a/requirements/base.in b/requirements/base.in index a1667aa..d0eefba 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -1,6 +1,6 @@ -Django==4.1.5 +Django==4.2.5 django-money==1.3 -django-allauth==0.46 +django-allauth==0.56.1 psycopg2-binary==2.9.5 environs[django]==9.3 uvicorn==0.13 diff --git a/requirements/base.txt b/requirements/base.txt index 052d79a..5bb7f4f 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,10 +1,10 @@ # -# This file is autogenerated by pip-compile with Python 3.10 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # pip-compile --output-file=requirements/base.txt requirements/base.in # -asgiref==3.5.2 +asgiref==3.7.2 # via django certifi==2022.9.24 # via requests @@ -22,14 +22,14 @@ dj-database-url==1.0.0 # via environs dj-email-url==1.0.6 # via environs -django==4.1.5 +django==4.2.5 # via # -r requirements/base.in # dj-database-url # django-allauth # django-money # django-zen-queries -django-allauth==0.46 +django-allauth==0.56.1 # via -r requirements/base.in django-cache-url==3.4.2 # via environs @@ -37,7 +37,7 @@ django-money==1.3 # via -r requirements/base.in django-zen-queries==2.1.0 # via -r requirements/base.in -environs[django]==9.3 +environs[django]==9.3.0 # via -r requirements/base.in h11==0.14.0 # via uvicorn @@ -73,9 +73,9 @@ sqlparse==0.4.3 # via django urllib3==1.26.12 # via requests -uvicorn==0.13 +uvicorn==0.13.0 # via -r requirements/base.in -whitenoise==5.2 +whitenoise==5.2.0 # via -r requirements/base.in # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/dev.in b/requirements/dev.in index 7a45bd0..2119327 100644 --- a/requirements/dev.in +++ b/requirements/dev.in @@ -1,8 +1,8 @@ -r test.txt -django-browser-reload==1.6.0 -django-debug-toolbar==3.7.0 -django-extensions==3.2.1 +django-browser-reload==1.11.0 +django-debug-toolbar==4.2.0 +django-extensions==3.2.3 django-stubs==1.12.0 ipython==8.6.0 -mypy==0.990 +mypy==1.5.1 diff --git a/requirements/dev.txt b/requirements/dev.txt index e3f707e..7d611a6 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,10 +1,10 @@ # -# This file is autogenerated by pip-compile with Python 3.10 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # pip-compile --output-file=requirements/dev.txt requirements/dev.in # -asgiref==3.5.2 +asgiref==3.7.2 # via # -r requirements/test.txt # django @@ -28,7 +28,7 @@ click==7.1.2 # via # -r requirements/test.txt # uvicorn -coverage==6.5.0 +coverage==7.3.1 # via -r requirements/test.txt cryptography==38.0.3 # via @@ -48,7 +48,7 @@ dj-email-url==1.0.6 # via # -r requirements/test.txt # environs -django==4.1.5 +django==4.2.5 # via # -r requirements/test.txt # dj-database-url @@ -60,17 +60,17 @@ django==4.1.5 # django-stubs # django-stubs-ext # django-zen-queries -django-allauth==0.46 +django-allauth==0.56.1 # via -r requirements/test.txt -django-browser-reload==1.6.0 +django-browser-reload==1.11.0 # via -r requirements/dev.in django-cache-url==3.4.2 # via # -r requirements/test.txt # environs -django-debug-toolbar==3.7.0 +django-debug-toolbar==4.2.0 # via -r requirements/dev.in -django-extensions==3.2.1 +django-extensions==3.2.3 # via -r requirements/dev.in django-money==1.3 # via -r requirements/test.txt @@ -80,7 +80,7 @@ django-stubs-ext==0.7.0 # via django-stubs django-zen-queries==2.1.0 # via -r requirements/test.txt -environs[django]==9.3 +environs[django]==9.3.0 # via -r requirements/test.txt executing==1.2.0 # via stack-data @@ -106,11 +106,11 @@ marshmallow==3.19.0 # environs matplotlib-inline==0.1.6 # via ipython -mypy==0.990 +mypy==1.5.1 # via # -r requirements/dev.in # django-stubs -mypy-extensions==0.4.3 +mypy-extensions==1.0.0 # via mypy oauthlib==3.2.2 # via @@ -178,12 +178,10 @@ sqlparse==0.4.3 # django-debug-toolbar stack-data==0.6.1 # via ipython -tblib==1.7.0 +tblib==2.0.0 # via -r requirements/test.txt tomli==2.0.1 - # via - # django-stubs - # mypy + # via django-stubs traitlets==5.5.0 # via # ipython @@ -203,11 +201,11 @@ urllib3==1.26.12 # via # -r requirements/test.txt # requests -uvicorn==0.13 +uvicorn==0.13.0 # via -r requirements/test.txt wcwidth==0.2.5 # via prompt-toolkit -whitenoise==5.2 +whitenoise==5.2.0 # via -r requirements/test.txt # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/test.in b/requirements/test.in index ec90b2f..5ac8533 100644 --- a/requirements/test.in +++ b/requirements/test.in @@ -1,5 +1,5 @@ -r base.txt -coverage==6.5.0 -tblib==1.7.0 +coverage==7.3.1 +tblib==2.0.0 unittest-xml-reporting==3.2.0 diff --git a/requirements/test.txt b/requirements/test.txt index 7a21b7b..e840d1b 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,10 +1,10 @@ # -# This file is autogenerated by pip-compile with Python 3.10 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # pip-compile --output-file=requirements/test.txt requirements/test.in # -asgiref==3.5.2 +asgiref==3.7.2 # via # -r requirements/base.txt # django @@ -24,7 +24,7 @@ click==7.1.2 # via # -r requirements/base.txt # uvicorn -coverage==6.5.0 +coverage==7.3.1 # via -r requirements/test.in cryptography==38.0.3 # via @@ -42,14 +42,14 @@ dj-email-url==1.0.6 # via # -r requirements/base.txt # environs -django==4.1.5 +django==4.2.5 # via # -r requirements/base.txt # dj-database-url # django-allauth # django-money # django-zen-queries -django-allauth==0.46 +django-allauth==0.56.1 # via -r requirements/base.txt django-cache-url==3.4.2 # via @@ -59,7 +59,7 @@ django-money==1.3 # via -r requirements/base.txt django-zen-queries==2.1.0 # via -r requirements/base.txt -environs[django]==9.3 +environs[django]==9.3.0 # via -r requirements/base.txt h11==0.14.0 # via @@ -122,7 +122,7 @@ sqlparse==0.4.3 # via # -r requirements/base.txt # django -tblib==1.7.0 +tblib==2.0.0 # via -r requirements/test.in unittest-xml-reporting==3.2.0 # via -r requirements/test.in @@ -130,9 +130,9 @@ urllib3==1.26.12 # via # -r requirements/base.txt # requests -uvicorn==0.13 +uvicorn==0.13.0 # via -r requirements/base.txt -whitenoise==5.2 +whitenoise==5.2.0 # via -r requirements/base.txt # The following packages are considered to be unsafe in a requirements file: diff --git a/src/accounting/admin.py b/src/accounting/admin.py index 6115dc8..53691b7 100644 --- a/src/accounting/admin.py +++ b/src/accounting/admin.py @@ -6,7 +6,6 @@ from . import models @admin.register(models.Order) class OrderAdmin(admin.ModelAdmin): - list_display = ("who", "description", "created", "is_paid") @admin.display(description=_("Customer")) @@ -16,7 +15,6 @@ class OrderAdmin(admin.ModelAdmin): @admin.register(models.Payment) class PaymentAdmin(admin.ModelAdmin): - list_display = ("who", "description", "order_id", "created") @admin.display(description=_("Customer")) diff --git a/src/accounting/models.py b/src/accounting/models.py index 75e380b..ded800e 100644 --- a/src/accounting/models.py +++ b/src/accounting/models.py @@ -9,7 +9,6 @@ from djmoney.models.fields import MoneyField class CreatedModifiedAbstract(models.Model): - modified = models.DateTimeField(auto_now=True, verbose_name=_("modified")) created = models.DateTimeField(auto_now_add=True, verbose_name=_("created")) @@ -97,7 +96,6 @@ class Order(CreatedModifiedAbstract): class Payment(CreatedModifiedAbstract): - amount = MoneyField(max_digits=16, decimal_places=2) order = models.ForeignKey(Order, on_delete=models.PROTECT) diff --git a/src/membership/models.py b/src/membership/models.py index b2f1b5b..29adc35 100644 --- a/src/membership/models.py +++ b/src/membership/models.py @@ -12,13 +12,18 @@ from utils.mixins import CreatedModifiedAbstract class Member(User): class QuerySet(models.QuerySet): def annotate_membership(self): - from membership.selectors import get_current_subscription_period + from .selectors import get_current_subscription_period + + current_subscription_period = get_current_subscription_period() + + if not current_subscription_period: + raise ValueError("No current subscription period found") return self.annotate( active_membership=models.Exists( Membership.objects.filter( user=models.OuterRef("pk"), - period=get_current_subscription_period().id, + period=current_subscription_period.id, ), ), ) diff --git a/src/membership/permissions.py b/src/membership/permissions.py index 8ea5ed2..804bcef 100644 --- a/src/membership/permissions.py +++ b/src/membership/permissions.py @@ -27,7 +27,6 @@ class Permission: return f"{self.app_label}.{self.codename}" def persist_permission(self): - content_type, _ = ContentType.objects.get_or_create( app_label=self.app_label, model=self.model, diff --git a/src/project/settings.py b/src/project/settings.py index f04d367..c14eca6 100644 --- a/src/project/settings.py +++ b/src/project/settings.py @@ -65,6 +65,7 @@ MIDDLEWARE = [ "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", + "allauth.account.middleware.AccountMiddleware", ] ROOT_URLCONF = "project.urls" diff --git a/src/utils/mixins.py b/src/utils/mixins.py index e11ef34..26e2fe7 100644 --- a/src/utils/mixins.py +++ b/src/utils/mixins.py @@ -3,7 +3,6 @@ from django.utils.translation import gettext_lazy as _ class CreatedModifiedAbstract(models.Model): - modified = models.DateTimeField(auto_now=True, verbose_name=_("modified")) created = models.DateTimeField(auto_now_add=True, verbose_name=_("created"))