From 0eec75f36b03a0e4e02a0408828212fd665a31b4 Mon Sep 17 00:00:00 2001 From: Adrian Fedoreanu Date: Sat, 23 Mar 2024 20:27:04 +0100 Subject: [PATCH] update to django 4 --- oscar_invoices/abstract_models.py | 16 +++++++++++----- oscar_invoices/apps.py | 16 +++++++++++++++- oscar_invoices/urls.py | 10 ---------- requirements.txt | 8 ++++---- sandbox/urls.py | 4 +--- setup.py | 13 ++++++------- tox.ini | 14 ++++++-------- 7 files changed, 43 insertions(+), 38 deletions(-) delete mode 100644 oscar_invoices/urls.py diff --git a/oscar_invoices/abstract_models.py b/oscar_invoices/abstract_models.py index 1aacdf6..1920c45 100644 --- a/oscar_invoices/abstract_models.py +++ b/oscar_invoices/abstract_models.py @@ -1,7 +1,7 @@ from django.conf import settings from django.db import models from django.urls import reverse -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from oscar.apps.address.abstract_models import AbstractAddress from oscar.core.loading import get_class from phonenumber_field.modelfields import PhoneNumberField @@ -16,11 +16,17 @@ class AbstractLegalEntity(models.Model): Represents LegalEntity - merchant (company or individual) which we issue invoice on behalf of. """ - shop_name = models.CharField(_('Shop name'), max_length=255, null=True, blank=True) - business_name = models.CharField(_('Business name'), max_length=255, db_index=True) - vat_number = models.CharField(_('VAT identification number'), max_length=20) + shop_name = models.CharField(_('Shop name'), max_length=255, null=True, + blank=True) + business_name = models.CharField(_('Business name'), max_length=255, + db_index=True) + vat_number = models.CharField(_('VAT identification number'), max_length=20, + null=True, blank=True) + company_number = models.CharField(_('Company identification number'), + max_length=20, null=True, blank=True) logo = models.ImageField( - _('Logo'), upload_to=settings.OSCAR_IMAGE_FOLDER, max_length=255, null=True, blank=True) + _('Logo'), upload_to=settings.OSCAR_IMAGE_FOLDER, max_length=255, + null=True, blank=True) email = models.EmailField(_('Email'), null=True, blank=True) web_site = models.URLField(_('Website'), null=True, blank=True) iban = models.CharField(_("IBAN"), max_length=255, null=True, blank=True) diff --git a/oscar_invoices/apps.py b/oscar_invoices/apps.py index c97c2b4..4429637 100644 --- a/oscar_invoices/apps.py +++ b/oscar_invoices/apps.py @@ -1,4 +1,5 @@ -from django.utils.translation import ugettext_lazy as _ +from django.urls import re_path +from django.utils.translation import gettext_lazy as _ from oscar.core.application import OscarConfig @@ -6,3 +7,16 @@ class InvoicesConfig(OscarConfig): label = 'oscar_invoices' name = 'oscar_invoices' verbose_name = _('Invoices') + + default_permissions = ["is_staff"] + + def ready(self): + from . import views + self.invoice_view = views.InvoicePreviewView + + def get_urls(self): + urlpatterns = [ + re_path(r"invoice/(?P\d+)/", self.invoice_view.as_view(), + name="invoice"), + ] + return self.post_process_urls(urlpatterns) diff --git a/oscar_invoices/urls.py b/oscar_invoices/urls.py deleted file mode 100644 index 92d207a..0000000 --- a/oscar_invoices/urls.py +++ /dev/null @@ -1,10 +0,0 @@ -from django.urls import re_path -from oscar.core.loading import get_class - -InvoicePreviewView = get_class("oscar_invoices.views", "InvoicePreviewView") - - -app_name = "oscar_invoices" -urlpatterns = [ - re_path(r"invoice/(?P\d+)/", InvoicePreviewView.as_view(), name="invoice"), -] diff --git a/requirements.txt b/requirements.txt index 4a2955e..9b29a41 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,12 @@ # Testing -pytest>=3.6.0 +pytest>=7.4.4 pytest-django -django-webtest==1.9.9 +django-webtest>=1.9.11 sorl-thumbnail -psycopg2-binary>=2.7 +psycopg2-binary>=2.9.9 sorl-thumbnail coverage -mock==4.0.3 +mock>=5.1.0 factory-boy==3.2.1 # Development diff --git a/sandbox/urls.py b/sandbox/urls.py index 9d493d0..a45b4df 100644 --- a/sandbox/urls.py +++ b/sandbox/urls.py @@ -5,13 +5,11 @@ from django.contrib import admin from django.urls import include, path -from oscar_invoices import urls as oscar_invoices_urls - urlpatterns = [ path('admin/', admin.site.urls), path('i18n/', include(i18n)), path('', include(apps.get_app_config("oscar").urls[0])), - path('', include(oscar_invoices_urls)), + path('', apps.get_app_config("oscar_invoices").urls), ] if settings.DEBUG: diff --git a/setup.py b/setup.py index 9a9aa40..d1101b0 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='django-oscar-invoices', - version='0.2.1', + version='0.2.2', url='https://github.com/django-oscar/django-oscar-invoices', author='Metaclass Team', author_email='sasha@metaclass.co', @@ -17,19 +17,18 @@ 'Development Status :: 4 - Beta', 'Environment :: Web Environment', 'Framework :: Django', - 'Framework :: Django :: 2.0', - 'Framework :: Django :: 3.0', + 'Framework :: Django :: 4.0', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: Unix', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.9.18', ], install_requires=[ 'phonenumbers', 'pillow', - 'django>=1.11', - 'django-oscar>=2.0', - 'django-phonenumber-field>=3.0.0', + 'django>=4.2.6', + 'django-oscar>=3.2.2', + 'django-phonenumber-field>=6.4.0', ] ) diff --git a/tox.ini b/tox.ini index ce874c7..f5314fe 100644 --- a/tox.ini +++ b/tox.ini @@ -1,18 +1,16 @@ [tox] envlist = - py{36,37}-django{22,31} - py{37,38}-django{31} + py{39}-django{42} [testenv] commands = pytest {posargs} setenv = PYTHONPATH=. deps = - django22: django>=2.2,<2.3 - django31: django>=3.1,<3.2 - pytest >= 3.6.0 - pytest-django - django-webtest>=1.9.3 + django42: django>=4.2.6 + pytest >= 7.4.4 + pytest-django >= 4.7.0 + django-webtest>=1.9.11 sorl-thumbnail - psycopg2-binary>=2.7 + psycopg2-binary>=2.9.9 mock