diff --git a/changelog.md b/changelog.md index 2982963c1..44882fc90 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 + #### Disable search button while searching While waiting for search results the search button and form are now disabled unless @@ -8,6 +14,7 @@ the user has changed the search string. #### Fixes a sporadic failure in create_random_data Fixes a bug where in an edge case create_random.data.date_generator would raise "ValueError: empty range for randrange()". + ### 0.23.0 (Major Release) #### Enhanced customisation of search results diff --git a/doc/docs/reference/upgrading.md b/doc/docs/reference/upgrading.md index c1ce702e4..ae72158e8 100644 --- a/doc/docs/reference/upgrading.md +++ b/doc/docs/reference/upgrading.md @@ -3,14 +3,25 @@ This document provides instructions for specific steps required to upgrading your Opal 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 Opal version. This may requrie some code changes to +your application. +* `{% load staticfiles %}` in templates needs to be replaced with `{% load static %}` +* 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. + #### 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 +30,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 +83,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 d67b3286e..b53117cd6 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 f55d10f16..d966bcc81 100644 --- a/setup.py +++ b/setup.py @@ -49,11 +49,11 @@ 'kombu==5.1.0', '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',