Prepare for Django 4.x

This commit is contained in:
Yohan Boniface 2023-02-22 15:19:38 +01:00
parent 96a194e1f4
commit 2fc30b117b
7 changed files with 19 additions and 11 deletions

View file

@ -26,9 +26,9 @@ classifiers =
packages = find: packages = find:
include_package_data = True include_package_data = True
install_requires = install_requires =
Django>=3.2.5,<4 Django==4.1.7
django-agnocomplete==1.0.0 django-agnocomplete==2.2.0
django-compressor==2.4.1 django-compressor==4.3.1
Pillow==8.4.0 Pillow==8.4.0
psycopg2==2.9.3 psycopg2==2.9.3
requests==2.26.0 requests==2.26.0

View file

@ -7,7 +7,7 @@ class TileLayerAdmin(admin.ModelAdmin):
list_editable = ('rank', ) list_editable = ('rank', )
class MapAdmin(admin.OSMGeoAdmin): class MapAdmin(admin.GISModelAdmin):
search_fields = ("name",) search_fields = ("name",)
autocomplete_fields = ("owner", "editors") autocomplete_fields = ("owner", "editors")
list_filter = ("share_status",) list_filter = ("share_status",)

6
umap/apps.py Normal file
View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class UmapConfig(AppConfig):
name = "umap"
verbose_name = "uMap"

View file

@ -2,7 +2,7 @@ import json
import six import six
from django.db import models from django.db import models
from django.utils.encoding import smart_text from django.utils.encoding import smart_str
class DictField(models.TextField): class DictField(models.TextField):
@ -30,4 +30,4 @@ class DictField(models.TextField):
def value_to_string(self, obj): def value_to_string(self, obj):
"""Return value from object converted to string properly""" """Return value from object converted to string properly"""
return smart_text(self.get_prep_value(self.value_from_object(obj))) return smart_str(self.get_prep_value(self.value_from_object(obj)))

View file

@ -42,7 +42,6 @@ LANG_INFO.update({
TIME_ZONE = 'UTC' TIME_ZONE = 'UTC'
USE_TZ = True USE_TZ = True
USE_I18N = True USE_I18N = True
USE_L10N = True
LANGUAGE_CODE = 'en' LANGUAGE_CODE = 'en'
LANGUAGES = ( LANGUAGES = (
('am-et', 'Amharic'), ('am-et', 'Amharic'),
@ -108,7 +107,10 @@ INSTALLED_APPS = (
'umap', 'umap',
'compressor', 'compressor',
'social_django', 'social_django',
'agnocomplete', # See https://github.com/peopledoc/django-agnocomplete/commit/26eda2dfa4a2f8a805ca2ea19a0c504b9d773a1c
# Django does not find the app config in the default place, so the app is not loaded
# so the "autodiscover" is not run.
'agnocomplete.app.AgnocompleteConfig',
) )
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

View file

@ -1,5 +1,5 @@
from django.conf import settings from django.conf import settings
from django.conf.urls import include, re_path from django.urls import include, re_path
from django.conf.urls.i18n import i18n_patterns from django.conf.urls.i18n import i18n_patterns
from django.conf.urls.static import static from django.conf.urls.static import static
from django.contrib import admin from django.contrib import admin

View file

@ -605,7 +605,7 @@ class MapDelete(DeleteView):
model = Map model = Map
pk_url_kwarg = "map_id" pk_url_kwarg = "map_id"
def delete(self, *args, **kwargs): def form_valid(self, form):
self.object = self.get_object() self.object = self.get_object()
if self.object.owner and self.request.user != self.object.owner: if self.object.owner and self.request.user != self.object.owner:
return HttpResponseForbidden( return HttpResponseForbidden(
@ -801,7 +801,7 @@ class DataLayerUpdate(FormLessEditMixin, GZipMixin, UpdateView):
class DataLayerDelete(DeleteView): class DataLayerDelete(DeleteView):
model = DataLayer model = DataLayer
def delete(self, *args, **kwargs): def form_valid(self, form):
self.object = self.get_object() self.object = self.get_object()
if self.object.map != self.kwargs['map_inst']: if self.object.map != self.kwargs['map_inst']:
return HttpResponseForbidden() return HttpResponseForbidden()