Skip to content

Commit

Permalink
Bumps versions of django, django-compressor and django-version
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fredkingham committed Sep 2, 2022
1 parent e1a57b8 commit a29eed3
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 21 deletions.
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 15 additions & 5 deletions doc/docs/reference/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion opal/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion opal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion opal/scaffolding/plugin_scaffold/requirements.txt.jinja2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
python-dateutil==2.8.1
django-compressor==2.4
django-compressor==3.0
opal=={{ version }}
coverage==3.6
2 changes: 2 additions & 0 deletions opal/scaffolding/scaffold/app/settings.py.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
6 changes: 3 additions & 3 deletions opal/scaffolding/scaffold/requirements.txt.jinja2
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions opal/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load staticfiles %}
{% load static %}
{% load compress %}
{% load application %}
{% load plugins %}
Expand Down Expand Up @@ -88,7 +88,7 @@ <h4 class="growl-title" ng-show="message.title" ng-bind="message.title"></h4>

</head>
<body>
{% block application %}{% endblock %}
{% block application %}{% endblock %}
<!-- google analytics -->
{% block analytics %}
<script>
Expand Down
2 changes: 1 addition & 1 deletion opal/templates/plugins/javascripts.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load staticfiles %}
{% load static %}
{% for js in javascripts %}
<script type="text/javascript" src="{% static js %}"></script>
{% endfor %}
2 changes: 1 addition & 1 deletion opal/templates/plugins/stylesheets.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load staticfiles %}
{% load static %}
{% for sheet, mime_type in styles %}
<link href="{% static sheet %}" type="{{ mime_type }}" rel="stylesheet" charset="utf-8" media="all">
{% endfor %}
3 changes: 2 additions & 1 deletion opal/tests/test_context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions opal/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
FamousLastWords, PatientColour, ExternalSubRecord, SymptomComplex,
PatientConsultation, Birthday, DogOwner, HatWearer, InvisibleHatWearer,
HouseOwner, HoundOwner, Colour, FavouriteColour, Dinner,
EntitledHatWearer
EntitledHatWearer, Demographics
)


Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit a29eed3

Please sign in to comment.