From a29eed382040cb9ba817cf0b32f02de4d318527c Mon Sep 17 00:00:00 2001 From: fredkingham Date: Fri, 2 Sep 2022 09:31:25 +0100 Subject: [PATCH 1/3] Bumps versions of django, django-compressor and django-version Things to note... Run tests now needs a secret key for more information see https://docs.djangoproject.com/en/4.1/releases/3.2/#security Autofield now needs to be declared in settings, for more information see https://docs.djangoproject.com/en/4.1/releases/3.2/#customizing-type-of-auto-created-primary-keys staticfiles template library has been removed. We should now use static. For more information see https://docs.djangoproject.com/en/4.1/releases/3.0/#features-removed-in-3-0 --- changelog.md | 7 +++++++ doc/docs/reference/upgrading.md | 20 ++++++++++++++----- opal/context_processors.py | 2 +- opal/models.py | 2 +- .../plugin_scaffold/requirements.txt.jinja2 | 2 +- .../scaffold/app/settings.py.jinja2 | 2 ++ .../scaffold/requirements.txt.jinja2 | 6 +++--- opal/templates/base.html | 4 ++-- opal/templates/plugins/javascripts.html | 2 +- opal/templates/plugins/stylesheets.html | 2 +- opal/tests/test_context_processors.py | 3 ++- opal/tests/test_models.py | 4 ++-- runtests.py | 2 ++ setup.py | 6 +++--- 14 files changed, 43 insertions(+), 21 deletions(-) diff --git a/changelog.md b/changelog.md index 3321fd953..911299509 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,13 @@ The filter `future` now accepts a string as outputted by the Opal date serializa e.g. 27/12/2022. +#### Updates to the Dependency Graph + +* Django: 2.2.16 -> 3.2 +* Django-compressor: 2.4 -> 3.0 +* django-reversion: 3.0.8 -> 4.0.2 + + ### 0.22.1 (Minor Release) #### Exclude many to one relationships from the advanced search diff --git a/doc/docs/reference/upgrading.md b/doc/docs/reference/upgrading.md index c1ce702e4..77b3477bf 100644 --- a/doc/docs/reference/upgrading.md +++ b/doc/docs/reference/upgrading.md @@ -3,14 +3,24 @@ This document provides instructions for specific steps required to upgrading your Opal application to a later version where there are extra steps required. +#### 0.22.1 -> v0.23.0 + +Django is upgraded to 3.2 as part of this, +* `{% load staticfiles %}` in templates needs to be replaced with `{% load static %}` +* Third part json field libraries should be replaced with the jsonfield that now ships with django +* `DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'` should be set in your settings + +Note NullBooleanField is deprecated and should be replaced with BooleanField(null=True). +NullBooleanField will be removed when opal upgrades to django 4. + #### v0.20.0 -> v0.21.0 -Opal no longer supports Python 3.5. +Opal no longer supports Python 3.5. You will need to use 3.6, 3.7 or 3.8 and therefore must make sure they are installed in your environment. #### Celery changes -Opal does not require you to run Celery but we do pre-configure Opal applications for use with +Opal does not require you to run Celery but we do pre-configure Opal applications for use with Celery. If you don't have `celery` or `django-celery` in your requirements.txt this section can be ignored. @@ -19,7 +29,7 @@ If you don't have `celery` or `django-celery` in your requirements.txt this sect __Note__ This means that old results from `django-celery` will no longer be visible from the admin. -`django-celery-results==2.0.0` replaces `django-celery`, please add it to your requirements. +`django-celery-results==2.0.0` replaces `django-celery`, please add it to your requirements. This will show Celery task results in the admin and requires `python manage.py migrate` to be run. Celery has been upgraded to 5.0.2. @@ -72,8 +82,8 @@ you have specified them in for instance, a requirements.txt. ##### API API Changes (REST Framework) -Note that the Django REST Framework update includes a breaking change to their public -API which may affect your application. The `base_name` attribute of a ViewSet has been +Note that the Django REST Framework update includes a breaking change to their public +API which may affect your application. The `base_name` attribute of a ViewSet has been renamed to `basename` ([release notes](https://www.django-rest-framework.org/community/release-notes/#390)). Any APIs implemented in your application will likely need to rename this attribute as diff --git a/opal/context_processors.py b/opal/context_processors.py index 321750a8f..fe7465659 100644 --- a/opal/context_processors.py +++ b/opal/context_processors.py @@ -17,7 +17,7 @@ def settings(request): """ Put all settings in locals() for our templte context. """ - return {x: getattr(s, x) for x in dir(s)} + return {x: getattr(s, x) for x in dir(s) if hasattr(s, x)} def models(request): diff --git a/opal/models.py b/opal/models.py index cf3637d45..f77cc00fa 100644 --- a/opal/models.py +++ b/opal/models.py @@ -87,7 +87,7 @@ def m2m(x): def _get_field_type(cls, name): try: return type(cls._meta.get_field(name)) - except models.FieldDoesNotExist: + except FieldDoesNotExist: pass # TODO: Make this dynamic diff --git a/opal/scaffolding/plugin_scaffold/requirements.txt.jinja2 b/opal/scaffolding/plugin_scaffold/requirements.txt.jinja2 index db610d83c..8469b1337 100644 --- a/opal/scaffolding/plugin_scaffold/requirements.txt.jinja2 +++ b/opal/scaffolding/plugin_scaffold/requirements.txt.jinja2 @@ -1,4 +1,4 @@ python-dateutil==2.8.1 -django-compressor==2.4 +django-compressor==3.0 opal=={{ version }} coverage==3.6 diff --git a/opal/scaffolding/scaffold/app/settings.py.jinja2 b/opal/scaffolding/scaffold/app/settings.py.jinja2 index 0d83574fd..91041a2c7 100644 --- a/opal/scaffolding/scaffold/app/settings.py.jinja2 +++ b/opal/scaffolding/scaffold/app/settings.py.jinja2 @@ -118,6 +118,8 @@ except ImportError: } } +DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' + # Password validation # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ diff --git a/opal/scaffolding/scaffold/requirements.txt.jinja2 b/opal/scaffolding/scaffold/requirements.txt.jinja2 index 566a2d0a5..ebbf025ed 100644 --- a/opal/scaffolding/scaffold/requirements.txt.jinja2 +++ b/opal/scaffolding/scaffold/requirements.txt.jinja2 @@ -1,16 +1,16 @@ # cryptography is required for heroku deployment coverage==3.6 -django==2.2.16 +Django==3.2.15 dj-database-url==0.2.1 gunicorn==0.17.4 psycopg2==2.8.6 dj-static==0.0.6 -django-reversion==3.0.1 +django-reversion==4.0.2 #django-axes==1.4.0 ffs==0.0.8.2 requests==2.25.0 djangorestframework==3.12.2 -django-compressor==2.4 +django-compressor==3.0 python-dateutil==2.8.1 django-celery-results==2.0.0 celery==5.0.2 diff --git a/opal/templates/base.html b/opal/templates/base.html index 3499bbb1e..88f4e0e41 100644 --- a/opal/templates/base.html +++ b/opal/templates/base.html @@ -1,4 +1,4 @@ -{% load staticfiles %} +{% load static %} {% load compress %} {% load application %} {% load plugins %} @@ -88,7 +88,7 @@

- {% block application %}{% endblock %} + {% block application %}{% endblock %} {% block analytics %} {% endfor %} diff --git a/opal/templates/plugins/stylesheets.html b/opal/templates/plugins/stylesheets.html index 358c67e10..e4a6939f5 100644 --- a/opal/templates/plugins/stylesheets.html +++ b/opal/templates/plugins/stylesheets.html @@ -1,4 +1,4 @@ -{% load staticfiles %} +{% load static %} {% for sheet, mime_type in styles %} {% endfor %} diff --git a/opal/tests/test_context_processors.py b/opal/tests/test_context_processors.py index c43abf6c2..c4258513b 100644 --- a/opal/tests/test_context_processors.py +++ b/opal/tests/test_context_processors.py @@ -14,7 +14,8 @@ def test_settings(self): context = context_processors.settings(None) for s in dir(settings): - self.assertEqual(getattr(settings, s), context[s]) + if hasattr(settings, s): + self.assertEqual(getattr(settings, s), context[s]) class ModelsTestCase(TestCase): diff --git a/opal/tests/test_models.py b/opal/tests/test_models.py index 3eaf3e7af..81a0a508c 100644 --- a/opal/tests/test_models.py +++ b/opal/tests/test_models.py @@ -21,7 +21,7 @@ FamousLastWords, PatientColour, ExternalSubRecord, SymptomComplex, PatientConsultation, Birthday, DogOwner, HatWearer, InvisibleHatWearer, HouseOwner, HoundOwner, Colour, FavouriteColour, Dinner, - EntitledHatWearer + EntitledHatWearer, Demographics ) @@ -814,7 +814,7 @@ def test_field_schema(self, patient_list): class AbstractDemographicsTestCase(OpalTestCase): def test_name(self): - d = models.Demographics(first_name='Jane', + d = Demographics(first_name='Jane', surname='Doe', middle_name='Obsidian') self.assertEqual('Jane Doe', d.name) diff --git a/runtests.py b/runtests.py index 32d7ea6c8..2300cff6b 100644 --- a/runtests.py +++ b/runtests.py @@ -19,6 +19,8 @@ }, PROJECT_PATH=PROJECT_PATH, ROOT_URLCONF='opal.urls', + DEFAULT_AUTO_FIELD = 'django.db.models.AutoField', + SECRET_KEY='1111', USE_TZ=True, OPAL_EXTRA_APPLICATION='', DATE_FORMAT='d/m/Y', diff --git a/setup.py b/setup.py index e51441c82..5cdad4d19 100644 --- a/setup.py +++ b/setup.py @@ -47,11 +47,11 @@ install_requires=[ 'ffs>=0.0.8.2', 'Jinja2==2.10.1', - 'django==2.2.16', + 'Django==3.2.15', 'requests==2.25.0', 'djangorestframework==3.12.2', - 'django-reversion==3.0.8', - 'django-compressor==2.4', + 'django-reversion==4.0.2', + 'django-compressor==3.0', 'python-dateutil==2.8.1', 'django-celery-results==2.0.0', 'celery==5.0.2', From df67a49c35572af79d7d67e9d1eddbf31bb0b9d6 Mon Sep 17 00:00:00 2001 From: fredkingham Date: Mon, 6 Mar 2023 16:24:27 +0000 Subject: [PATCH 2/3] Moves the django upgrade into the 0.24.0 changelog/upgrading The django upgrade did not go out in 0.23 and has been moved into 0.24 this changes the change log/upgrading information from 23 into 0.24 as well. --- changelog.md | 13 ++++++------- doc/docs/reference/upgrading.md | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index 6db98134e..2d9f1a590 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ ### 0.24.0 (Major Release) +#### Updates to the Dependency Graph + +* Django: 2.2.16 -> 3.2 +* Django-compressor: 2.4 -> 3.0 +* django-reversion: 3.0.8 -> 4.0.2 + ### 0.23.0 (Major Release) #### Enhanced customisation of search results @@ -18,13 +24,6 @@ The filter `future` now accepts a string as outputted by the Opal date serializa e.g. 27/12/2022. -#### Updates to the Dependency Graph - -* Django: 2.2.16 -> 3.2 -* Django-compressor: 2.4 -> 3.0 -* django-reversion: 3.0.8 -> 4.0.2 - - ### 0.22.1 (Minor Release) #### Exclude many to one relationships from the advanced search diff --git a/doc/docs/reference/upgrading.md b/doc/docs/reference/upgrading.md index 77b3477bf..74d3d8988 100644 --- a/doc/docs/reference/upgrading.md +++ b/doc/docs/reference/upgrading.md @@ -3,7 +3,7 @@ This document provides instructions for specific steps required to upgrading your Opal application to a later version where there are extra steps required. -#### 0.22.1 -> v0.23.0 +#### 0.23.0 -> v0.24.0 Django is upgraded to 3.2 as part of this, * `{% load staticfiles %}` in templates needs to be replaced with `{% load static %}` From b8959be74a7420a091c81a9c1c1209b905922f63 Mon Sep 17 00:00:00 2001 From: David Miller Date: Wed, 24 May 2023 10:05:00 +0100 Subject: [PATCH 3/3] Fixup: Capitalization and Typos. --- doc/docs/reference/upgrading.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/docs/reference/upgrading.md b/doc/docs/reference/upgrading.md index 74d3d8988..ae72158e8 100644 --- a/doc/docs/reference/upgrading.md +++ b/doc/docs/reference/upgrading.md @@ -5,13 +5,14 @@ application to a later version where there are extra steps required. #### 0.23.0 -> v0.24.0 -Django is upgraded to 3.2 as part of this, +Django is upgraded to 3.2 as part of this Opal version. This may requrie some code changes to +your application. * `{% load staticfiles %}` in templates needs to be replaced with `{% load static %}` -* Third part json field libraries should be replaced with the jsonfield that now ships with django +* Third party JSONfield libraries should be replaced with the JSONfield that now ships with Django * `DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'` should be set in your settings -Note NullBooleanField is deprecated and should be replaced with BooleanField(null=True). -NullBooleanField will be removed when opal upgrades to django 4. +Note `NullBooleanField` is deprecated and should be replaced with `BooleanField(null=True)`. +`NullBooleanField` will be removed when Opal upgrades to Django 4. #### v0.20.0 -> v0.21.0