From c67dc6f56ea398b0c9a9633ac6e76aa9b178fff3 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 12 Apr 2019 20:44:22 +1000 Subject: [PATCH] Initial updates required to run under django 2.2 - Change to middleware.py - Change some URLs formatting - Fix django version at 2.2 --- InvenTree/InvenTree/middleware.py | 2 +- InvenTree/InvenTree/urls.py | 4 +-- .../migrations/0002_auto_20190412_2030.py | 25 +++++++++++++++++++ .../migrations/0003_auto_20190412_2030.py | 19 ++++++++++++++ .../migrations/0004_auto_20190412_2030.py | 19 ++++++++++++++ requirements/base.txt | 2 +- 6 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 InvenTree/build/migrations/0002_auto_20190412_2030.py create mode 100644 InvenTree/part/migrations/0003_auto_20190412_2030.py create mode 100644 InvenTree/stock/migrations/0004_auto_20190412_2030.py diff --git a/InvenTree/InvenTree/middleware.py b/InvenTree/InvenTree/middleware.py index fc75be2fb4..13b1a135fe 100644 --- a/InvenTree/InvenTree/middleware.py +++ b/InvenTree/InvenTree/middleware.py @@ -14,7 +14,7 @@ class AuthRequiredMiddleware(object): response = self.get_response(request) - if not request.user.is_authenticated(): + if not request.user.is_authenticated: print(request.path_info) if not request.path_info == reverse_lazy('login'): diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index edfc1a6750..4830ecd518 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -48,8 +48,8 @@ urlpatterns = [ url(r'^auth/', include('rest_framework.urls', namespace='rest_framework')), - url(r'^login/', auth_views.login, name='login'), - url(r'^logout/', auth_views.logout, {'template_name': 'registration/logout.html'}, name='logout'), + url(r'^login/', auth_views.LoginView.as_view(), name='login'), + url(r'^logout/', auth_views.LogoutView.as_view(template_name='registration/logout.html'), name='logout'), url(r'^admin/', admin.site.urls, name='inventree-admin'), url(r'^index/', IndexView.as_view(), name='index'), diff --git a/InvenTree/build/migrations/0002_auto_20190412_2030.py b/InvenTree/build/migrations/0002_auto_20190412_2030.py new file mode 100644 index 0000000000..eca2bf5adb --- /dev/null +++ b/InvenTree/build/migrations/0002_auto_20190412_2030.py @@ -0,0 +1,25 @@ +# Generated by Django 2.2 on 2019-04-12 10:30 + +import django.core.validators +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('build', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='build', + name='part', + field=models.ForeignKey(limit_choices_to={'buildable': True}, on_delete=django.db.models.deletion.CASCADE, related_name='builds', to='part.Part'), + ), + migrations.AlterField( + model_name='build', + name='status', + field=models.PositiveIntegerField(choices=[(10, 'Pending'), (20, 'Holding'), (30, 'Cancelled'), (40, 'Complete')], default=10, validators=[django.core.validators.MinValueValidator(0)]), + ), + ] diff --git a/InvenTree/part/migrations/0003_auto_20190412_2030.py b/InvenTree/part/migrations/0003_auto_20190412_2030.py new file mode 100644 index 0000000000..3439c09483 --- /dev/null +++ b/InvenTree/part/migrations/0003_auto_20190412_2030.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2 on 2019-04-12 10:30 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('part', '0002_part_default_location'), + ] + + operations = [ + migrations.AlterField( + model_name='bomitem', + name='part', + field=models.ForeignKey(limit_choices_to={'buildable': True}, on_delete=django.db.models.deletion.CASCADE, related_name='bom_items', to='part.Part'), + ), + ] diff --git a/InvenTree/stock/migrations/0004_auto_20190412_2030.py b/InvenTree/stock/migrations/0004_auto_20190412_2030.py new file mode 100644 index 0000000000..d55dbc6fff --- /dev/null +++ b/InvenTree/stock/migrations/0004_auto_20190412_2030.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2 on 2019-04-12 10:30 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('stock', '0003_auto_20180510_1042'), + ] + + operations = [ + migrations.AlterField( + model_name='stockitem', + name='status', + field=models.PositiveIntegerField(choices=[(10, 'OK'), (50, 'Attention needed'), (55, 'Damaged'), (60, 'Destroyed')], default=10, validators=[django.core.validators.MinValueValidator(0)]), + ), + ] diff --git a/requirements/base.txt b/requirements/base.txt index e1cdb825c4..5c0ec6f74f 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,4 +1,4 @@ -Django>=1.11 +Django==2.2 pillow>=5.0.0 djangorestframework>=3.6.2 django_filter>=1.0.2