Skip to content

Commit

Permalink
Merge pull request #36 from phedoreanu/master
Browse files Browse the repository at this point in the history
update to django 4
  • Loading branch information
viggo-devries authored Apr 22, 2024
2 parents d091b0f + c09e51e commit 4914760
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 40 deletions.
16 changes: 11 additions & 5 deletions oscar_invoices/abstract_models.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
16 changes: 15 additions & 1 deletion oscar_invoices/apps.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
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


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<pk>\d+)/", self.invoice_view.as_view(),
name="invoice"),
]
return self.post_process_urls(urlpatterns)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.11 on 2024-03-23 19:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('oscar_invoices', '0004_date_banking_details'),
]

operations = [
migrations.AddField(
model_name='legalentity',
name='company_number',
field=models.CharField(blank=True, max_length=20, null=True, verbose_name='Company identification number'),
),
migrations.AlterField(
model_name='legalentity',
name='vat_number',
field=models.CharField(blank=True, max_length=20, null=True, verbose_name='VAT identification number'),
),
]
7 changes: 6 additions & 1 deletion oscar_invoices/templates/oscar_invoices/invoice.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ <h1>{% trans "Original invoice" %} #{{ invoice.number }}</h1><br>
</td>
<td>
{{ legal_entity.business_name }}<br>
{% trans "VAT ID" %}: {{ legal_entity.vat_number }}<br>
{% if legal_entity.vat_number %}
{% trans "VAT ID" %}: {{ legal_entity.vat_number }}<br>
{% endif %}
{% if legal_entity.company_number %}
{% trans "Company ID" %}: {{ legal_entity.company_number }}<br>
{% endif %}
<address>
{{ legal_entity_address.summary }}<br/>
{% if legal_entity_address.phone_number %}
Expand Down
10 changes: 0 additions & 10 deletions oscar_invoices/urls.py

This file was deleted.

8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions sandbox/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 6 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]',
Expand All @@ -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',
]
)
2 changes: 1 addition & 1 deletion tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class LegalEntityFactory(factory.django.DjangoModelFactory):
business_name = 'Test Company'
vat_number = 'test-vat-number'
company_number = 'test-company-number'

class Meta:
model = get_model('oscar_invoices', 'LegalEntity')
Expand Down
14 changes: 6 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4914760

Please sign in to comment.