From f7bdccd4dd370131aa102a688260eec33c15c039 Mon Sep 17 00:00:00 2001 From: Tor-Einar Skog <tor-einar.skog@nibio.no> Date: Mon, 9 Jan 2023 14:58:28 +0100 Subject: [PATCH] Upgrade to Django 4.0 --- VIPSWeb/local_settings_sample.py | 2 +- VIPSWeb/templatetags/template_helper.py | 2 +- VIPSWeb/urls.py | 47 +++++++++++++------------ applefruitmoth/urls.py | 5 ++- calculators/urls.py | 7 ++-- cerealblotchmodels/urls.py | 9 ++--- cydiapomonella/urls.py | 5 +-- forecasts/models.py | 2 +- forecasts/urls.py | 19 +++++----- fusarium/urls.py | 5 ++- information/models.py | 2 +- information/urls.py | 7 ++-- mock/urls.py | 4 +-- observations/urls.py | 9 ++--- organisms/urls.py | 4 +-- requirements.txt | 4 +-- roughage/urls.py | 6 ++-- security/urls.py | 8 ++--- vips_messages/models.py | 2 +- vips_messages/urls.py | 8 ++--- 20 files changed, 80 insertions(+), 77 deletions(-) diff --git a/VIPSWeb/local_settings_sample.py b/VIPSWeb/local_settings_sample.py index 33cfd8ad..7ed9ab8a 100755 --- a/VIPSWeb/local_settings_sample.py +++ b/VIPSWeb/local_settings_sample.py @@ -25,7 +25,7 @@ ## Change these for every new instance of the app import os # MUST be lazy, otherwise the app crashes -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ DEBUG = True MAINTENANCE_MODE = False diff --git a/VIPSWeb/templatetags/template_helper.py b/VIPSWeb/templatetags/template_helper.py index 792005e1..0c3006ea 100755 --- a/VIPSWeb/templatetags/template_helper.py +++ b/VIPSWeb/templatetags/template_helper.py @@ -1,6 +1,6 @@ # -*- coding: UTF-8 -*- from django import template -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.utils import translation from django.conf import settings from datetime import datetime diff --git a/VIPSWeb/urls.py b/VIPSWeb/urls.py index 681c5c57..499d6a6f 100755 --- a/VIPSWeb/urls.py +++ b/VIPSWeb/urls.py @@ -16,7 +16,8 @@ # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # -from django.conf.urls import include, url +from django.conf.urls import include +from django.urls import re_path #from django.views.generic import TemplateView from django.views.static import serve from django.views.i18n import JavaScriptCatalog @@ -38,7 +39,7 @@ js_info_dict = { if settings.MAINTENANCE_MODE is True: urlpatterns = [ - url(r'^$', views.maintenance, name='maintenance') + re_path(r'^$', views.maintenance, name='maintenance') ] else: urlpatterns = [ @@ -49,31 +50,31 @@ else: # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), - url(r'^cydiapomonella/', include('cydiapomonella.urls')), - url(r'^forecasts/', include('forecasts.urls', namespace = "forecasts")), - url(r'^messages/', include('vips_messages.urls', namespace = "vips_messages")), - url(r'^organisms/', include('organisms.urls', namespace = "organisms")), - url(r'^observations/', include('observations.urls', namespace = "observations")), - url(r'^information/', include('information.urls', namespace = "information")), - url(r'^blotch/', include('cerealblotchmodels.urls', namespace = "cerealblotchmodels")), - url(r'^calculators/', include('calculators.urls', namespace = "calculators")), - url(r'^roughage/', include('roughage.urls', namespace = "roughage")), - url(r'^security/', include('security.urls', namespace = "security")), - url(r'^fusarium/', include('fusarium.urls', namespace = "fusarium")), - url(r'^applefruitmoth/', include('applefruitmoth.urls', namespace = "applefruitmoth")), - url(r'^mock/', include('mock.urls', namespace = "mock")), + re_path(r'^cydiapomonella/', include('cydiapomonella.urls')), + re_path(r'^forecasts/', include('forecasts.urls', namespace = "forecasts")), + re_path(r'^messages/', include('vips_messages.urls', namespace = "vips_messages")), + re_path(r'^organisms/', include('organisms.urls', namespace = "organisms")), + re_path(r'^observations/', include('observations.urls', namespace = "observations")), + re_path(r'^information/', include('information.urls', namespace = "information")), + re_path(r'^blotch/', include('cerealblotchmodels.urls', namespace = "cerealblotchmodels")), + re_path(r'^calculators/', include('calculators.urls', namespace = "calculators")), + re_path(r'^roughage/', include('roughage.urls', namespace = "roughage")), + re_path(r'^security/', include('security.urls', namespace = "security")), + re_path(r'^fusarium/', include('fusarium.urls', namespace = "fusarium")), + re_path(r'^applefruitmoth/', include('applefruitmoth.urls', namespace = "applefruitmoth")), + re_path(r'^mock/', include('mock.urls', namespace = "mock")), # Uncomment the next line to enable the admin: - url(r'^admin/', admin.site.urls), - url(r'^tinymce/', include('tinymce.urls')), + re_path(r'^admin/', admin.site.urls), + re_path(r'^tinymce/', include('tinymce.urls')), # Static serving of media files - url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}), + re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}), # Enabling translation in JavaScript files # See https://docs.djangoproject.com/en/1.6/topics/i18n/translation/#internationalization-in-javascript-code - url(r'^jsi18n/$', JavaScriptCatalog.as_view(packages=js_info_dict['packages']), name='javascript-catalog'), - url(r'^i18n/', include('django.conf.urls.i18n')), - url(r'^settings.js', views.settings_js, name="views.settings_js"), - url(r'^vipslogicproxy/(?P<path>.*)$', views.vipslogicproxy), + re_path(r'^jsi18n/$', JavaScriptCatalog.as_view(packages=js_info_dict['packages']), name='javascript-catalog'), + re_path(r'^i18n/', include('django.conf.urls.i18n')), + re_path(r'^settings.js', views.settings_js, name="views.settings_js"), + re_path(r'^vipslogicproxy/(?P<path>.*)$', views.vipslogicproxy), # Default view is index - url(r'^$', views.index, name='index'), + re_path(r'^$', views.index, name='index'), #url(r'^$', TemplateView.as_view(template_name="index.html")) ] diff --git a/applefruitmoth/urls.py b/applefruitmoth/urls.py index 92ccac72..f694372d 100755 --- a/applefruitmoth/urls.py +++ b/applefruitmoth/urls.py @@ -16,12 +16,11 @@ # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # -from django.conf.urls import url - +from django.urls import re_path from applefruitmoth import views app_name = "applefruitmoth" urlpatterns = [ - url(r'^$', views.index, name='index'), + re_path(r'^$', views.index, name='index'), ] \ No newline at end of file diff --git a/calculators/urls.py b/calculators/urls.py index 1661f2f1..6c1644cb 100755 --- a/calculators/urls.py +++ b/calculators/urls.py @@ -15,13 +15,14 @@ # You should have received a copy of the NIBIO Open Source License # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # -from django.conf.urls import url + +from django.urls import re_path from calculators import views app_name = "calculators" urlpatterns = [ # ex: /forecasts/ - url(r'^$', views.index, name='index'), - url(r'eil/', views.eil, name='eil') + re_path(r'^$', views.index, name='index'), + re_path(r'eil/', views.eil, name='eil') ] \ No newline at end of file diff --git a/cerealblotchmodels/urls.py b/cerealblotchmodels/urls.py index 375b0ccd..e4368fe9 100755 --- a/cerealblotchmodels/urls.py +++ b/cerealblotchmodels/urls.py @@ -15,14 +15,15 @@ # You should have received a copy of the NIBIO Open Source License # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # -from django.conf.urls import url + +from django.urls import re_path from cerealblotchmodels import views app_name = "cerealblotchmodels" urlpatterns = [ # ex: /forecasts/ - url(r'^$', views.index, name='index'), - url(r'barleynetblotch/', views.barleynetblotchform, name='barleynetblotchform'), - url(r'septoriahumidity/', views.septoriahumidityform, name='septoriahumidityform') + re_path(r'^$', views.index, name='index'), + re_path(r'barleynetblotch/', views.barleynetblotchform, name='barleynetblotchform'), + re_path(r'septoriahumidity/', views.septoriahumidityform, name='septoriahumidityform') ] \ No newline at end of file diff --git a/cydiapomonella/urls.py b/cydiapomonella/urls.py index f5a4c4f6..5005bba0 100644 --- a/cydiapomonella/urls.py +++ b/cydiapomonella/urls.py @@ -1,9 +1,10 @@ -from django.conf.urls import url + +from django.urls import re_path from . import views urlpatterns = [ - url(r'^$', views.index,name='index'), + re_path(r'^$', views.index,name='index'), ] diff --git a/forecasts/models.py b/forecasts/models.py index 731375b5..cf56d754 100755 --- a/forecasts/models.py +++ b/forecasts/models.py @@ -22,7 +22,7 @@ import requests import json from decimal import Decimal, InvalidOperation -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.conf import settings from django.db import models from django.utils import translation diff --git a/forecasts/urls.py b/forecasts/urls.py index ef8c0bb0..9c3499ec 100755 --- a/forecasts/urls.py +++ b/forecasts/urls.py @@ -15,7 +15,8 @@ # You should have received a copy of the NIBIO Open Source License # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # -from django.conf.urls import url + +from django.urls import re_path from django.views.decorators.cache import cache_page from forecasts import views @@ -24,16 +25,16 @@ app_name="forecasts" urlpatterns = [ # ex: /forecasts/ - url(r'^$', views.index, name='index'), + re_path(r'^$', views.index, name='index'), # ex: /forecasts/5/ #url(r'^(?P<forecast_id>\d+)/detail_highcharts_json/$', cache_page(60 * 15)(views.detail_highcharts_json), name='detail_highcharts_json'), - url(r'^(?P<forecast_id>-?\d+)/detail_highcharts_json/$', views.detail_highcharts_json, name='detail_highcharts_json'), + re_path(r'^(?P<forecast_id>-?\d+)/detail_highcharts_json/$', views.detail_highcharts_json, name='detail_highcharts_json'), #url(r'^(?P<forecast_id>\d+)/$', cache_page(60 * 15)(views.detail), name='detail'), - url(r'^(?P<forecast_id>-?\d+)/$', (views.detail), name='detail'), - url(r'^(?P<forecast_id>-?\d+)/(?P<latest_days>\d+)/$', (views.detail_latest_days), name='detail_latest_days'), - url(r'^models/test/$', views.models_detail_test, name='models_detail_test'), - url(r'^models/(?P<model_id>\w+)/$', views.models_detail, name='models_detail'), - url(r'^models/js/modelLocalNames.js', cache_page(60 * 30)(views.model_local_names_js), name='model_local_names_js'), - url(r'^models/$', views.models_index, name='models_index'), + re_path(r'^(?P<forecast_id>-?\d+)/$', (views.detail), name='detail'), + re_path(r'^(?P<forecast_id>-?\d+)/(?P<latest_days>\d+)/$', (views.detail_latest_days), name='detail_latest_days'), + re_path(r'^models/test/$', views.models_detail_test, name='models_detail_test'), + re_path(r'^models/(?P<model_id>\w+)/$', views.models_detail, name='models_detail'), + re_path(r'^models/js/modelLocalNames.js', cache_page(60 * 30)(views.model_local_names_js), name='model_local_names_js'), + re_path(r'^models/$', views.models_index, name='models_index'), ] \ No newline at end of file diff --git a/fusarium/urls.py b/fusarium/urls.py index e7b9cc8e..9fb1f77f 100755 --- a/fusarium/urls.py +++ b/fusarium/urls.py @@ -16,12 +16,11 @@ # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # -from django.conf.urls import url - +from django.urls import re_path from fusarium import views app_name = "fusarium" urlpatterns = [ - url(r'^$', views.index, name='index'), + re_path(r'^$', views.index, name='index'), ] \ No newline at end of file diff --git a/information/models.py b/information/models.py index 6594c756..1911f446 100755 --- a/information/models.py +++ b/information/models.py @@ -1,4 +1,4 @@ -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.db import models from tinymce import models as tinymce_models from django.conf import settings diff --git a/information/urls.py b/information/urls.py index cbbea488..c13d2d73 100755 --- a/information/urls.py +++ b/information/urls.py @@ -16,15 +16,14 @@ # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # -from django.conf.urls import url - +from django.urls import re_path from information import views app_name = "information" urlpatterns = [ # ex: /messages/ - url(r'^$', views.index, name='index'), + re_path(r'^$', views.index, name='index'), # ex: /messages/5/ - url(r'^(?P<information_id>\d+)/$', views.detail, name='detail'), + re_path(r'^(?P<information_id>\d+)/$', views.detail, name='detail'), ] \ No newline at end of file diff --git a/mock/urls.py b/mock/urls.py index 76901112..c30c0dd0 100644 --- a/mock/urls.py +++ b/mock/urls.py @@ -16,11 +16,11 @@ # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # -from django.conf.urls import url +from django.urls import re_path from mock import views app_name = "mock" urlpatterns = [ - url(r'^zymogridmapclient/$', views.zymogridmapclient, name='zymogridmapclient'), + re_path(r'^zymogridmapclient/$', views.zymogridmapclient, name='zymogridmapclient'), ] diff --git a/observations/urls.py b/observations/urls.py index 25664187..09e94d6f 100755 --- a/observations/urls.py +++ b/observations/urls.py @@ -15,7 +15,8 @@ # You should have received a copy of the NIBIO Open Source License # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # -from django.conf.urls import url +#from django.conf.urls import url +from django.urls import re_path #from django.views.decorators.cache import cache_page from observations import views @@ -24,8 +25,8 @@ app_name = "observations" urlpatterns = [ # ex: /forecasts/ - url(r'^$', views.index, name='index'), - url(r'old', views.index_old, name='index_old'), + re_path(r'^$', views.index, name='index'), + re_path(r'old', views.index_old, name='index_old'), # ex: /observations/5/ - url(r'^(?P<observation_id>\d+)/$', (views.detail), name='detail'), + re_path(r'^(?P<observation_id>\d+)/$', (views.detail), name='detail'), ] \ No newline at end of file diff --git a/organisms/urls.py b/organisms/urls.py index 5055042a..b597deb8 100755 --- a/organisms/urls.py +++ b/organisms/urls.py @@ -16,7 +16,7 @@ # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # -from django.conf.urls import url +from django.urls import re_path from organisms import views @@ -24,7 +24,7 @@ app_name = "organisms" urlpatterns = [ # ex: /organisms/ - url(r'^$', views.index, name='index'), + re_path(r'^$', views.index, name='index'), # ex: /organisms/5/ #url(r'^(?P<organism_id>\d+)/$', views.detail, name='detail'), ] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 99a24132..de6ebdf4 100755 --- a/requirements.txt +++ b/requirements.txt @@ -18,10 +18,10 @@ # Please add requirements here # Read docs for how this works: http://www.pip-installer.org/en/latest/cookbook.html -Django==3.2.16 +Django==4.0.8 Pillow requests==2.25.0 -django-tinymce==2.8.0 +django-tinymce==3.5.0 python-dateutil==2.8.1 django-extensions selenium diff --git a/roughage/urls.py b/roughage/urls.py index 36a71637..d5b77151 100755 --- a/roughage/urls.py +++ b/roughage/urls.py @@ -16,13 +16,13 @@ # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # -from django.conf.urls import url +from django.urls import re_path from roughage import views app_name = "roughage" urlpatterns = [ - url(r'^nutrition/calibration/$', views.nutrition_calibration), - url(r'^nutrition/$', views.nutrition) + re_path(r'^nutrition/calibration/$', views.nutrition_calibration), + re_path(r'^nutrition/$', views.nutrition) ] \ No newline at end of file diff --git a/security/urls.py b/security/urls.py index 4e2f7757..88849498 100755 --- a/security/urls.py +++ b/security/urls.py @@ -16,14 +16,14 @@ # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # -from django.conf.urls import url +from django.urls import re_path from security import views app_name = "security" urlpatterns = [ - url(r'^login/(?P<user_uuid>[^/]+)/$', views.login_user_uuid), - url(r'^login/$', views.login_form), - url(r'^logout/$', views.logout) + re_path(r'^login/(?P<user_uuid>[^/]+)/$', views.login_user_uuid), + re_path(r'^login/$', views.login_form), + re_path(r'^logout/$', views.logout) ] \ No newline at end of file diff --git a/vips_messages/models.py b/vips_messages/models.py index 16803ab6..f4724ace 100755 --- a/vips_messages/models.py +++ b/vips_messages/models.py @@ -19,7 +19,7 @@ import requests from django.conf import settings from django.db import models -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from datetime import datetime class MessageTag: diff --git a/vips_messages/urls.py b/vips_messages/urls.py index 38f1f499..4a42a90e 100755 --- a/vips_messages/urls.py +++ b/vips_messages/urls.py @@ -16,7 +16,7 @@ # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # -from django.conf.urls import url +from django.urls import re_path from vips_messages import views @@ -24,8 +24,8 @@ app_name="vips_messages" urlpatterns = [ # ex: /messages/ - url(r'^$', views.index, name='index'), + re_path(r'^$', views.index, name='index'), # ex: /messages/5/ - url(r'^(?P<message_id>\d+)/$', views.detail, name='detail'), - url(r'^by_tag/json', views.messages_by_tag_json, name='messages_by_tag_json'), + re_path(r'^(?P<message_id>\d+)/$', views.detail, name='detail'), + re_path(r'^by_tag/json', views.messages_by_tag_json, name='messages_by_tag_json'), ] \ No newline at end of file -- GitLab