Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django upgrade #2017

Open
wants to merge 7 commits into
base: v0.24.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
21 changes: 16 additions & 5 deletions doc/docs/reference/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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
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)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here as part of this PR?



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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here as part of this PR?

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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here as part of this PR?

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 @@ -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',
Expand Down