diff options
author | luxagraf <sng@luxagraf.net> | 2024-05-09 16:46:51 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2024-05-09 16:46:51 -0500 |
commit | 06085dc492c1d558c0956cad7f3b4b6e39f11187 (patch) | |
tree | a8fc667dd39e5d2d7114105dda003e983fb602ae /app/utils/widgets.py | |
parent | 36cec3379c541c93740dc50b4f706912edb5b69c (diff) |
admin: fixed all the maps to work with django 5 changes
Diffstat (limited to 'app/utils/widgets.py')
-rw-r--r-- | app/utils/widgets.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/app/utils/widgets.py b/app/utils/widgets.py index 61f1722..897d428 100644 --- a/app/utils/widgets.py +++ b/app/utils/widgets.py @@ -1,6 +1,8 @@ import os from django import forms from django.contrib import admin + +from django.contrib.gis.admin import GISModelAdmin from django.contrib.admin.widgets import AdminFileWidget from django.utils.safestring import mark_safe from django.utils.translation import gettext_lazy as _ @@ -13,6 +15,7 @@ import markdown from bs4 import BeautifulSoup from django.utils.module_loading import import_string +from utils.util import get_latlon class CustomSelectMultiple(SelectMultiple): @@ -129,15 +132,18 @@ class LGEntryFormSmall(forms.ModelForm): } -class OLAdminBase(admin.ModelAdmin): - default_lon = -9285175 - default_lat = 4025046 - default_zoom = 15 - units = True - scrollable = False - map_width = 700 - map_height = 425 - map_template = 'gis/admin/osm.html' - openlayers_url = '/static/admin/js/OpenLayers.js' +class OLAdminBase(GISModelAdmin): + lat, lon = get_latlon() + gis_widget_kwargs = { + "attrs": { + "default_lon": lon, + "default_lat": lat, + "default_zoom": 13, + "map_width": 900, + "map_height": 625, + #"map_template": 'gis/admin/osm.html', + #"openlayers_url": '/static/admin/js/OpenLayers.js' + } + } |