diff --git a/django_project/cloud_native_gis/admin/layer.py b/django_project/cloud_native_gis/admin/layer.py
index 614f461..1a6d9a9 100644
--- a/django_project/cloud_native_gis/admin/layer.py
+++ b/django_project/cloud_native_gis/admin/layer.py
@@ -8,7 +8,6 @@
from cloud_native_gis.models.layer import Layer, LayerAttributes
from cloud_native_gis.models.layer_upload import LayerUpload
from cloud_native_gis.tasks import import_data
-from cloud_native_gis.utils.layer import layer_api_url, maputnik_url
class LayerAttributeInline(admin.TabularInline):
@@ -29,11 +28,13 @@ def start_upload_data(modeladmin, request, queryset):
import_data.delay(layer.pk)
+@admin.register(Layer)
class LayerAdmin(admin.ModelAdmin):
"""Layer admin."""
list_display = (
- 'unique_id', 'name', 'created_by', 'created_at', 'tile_url', 'editor'
+ 'unique_id', 'name', 'created_by', 'created_at',
+ 'is_ready', 'tile_url', 'editor'
)
form = LayerForm
inlines = [LayerAttributeInline]
@@ -60,15 +61,17 @@ def field_names(self, obj: Layer):
def editor(self, obj: Layer):
"""Return fields."""
+ maputnik_url = obj.maputnik_url(self.request)
+ if not maputnik_url:
+ return None
return mark_safe(
- f"Editor"
+ f"Editor"
)
editor.allow_tags = True
+@admin.register(LayerUpload)
class LayerUploadAdmin(admin.ModelAdmin):
"""Layer admin."""
@@ -84,7 +87,3 @@ def get_form(self, request, *args, **kwargs):
form = super(LayerUploadAdmin, self).get_form(request, *args, **kwargs)
form.user = request.user
return form
-
-
-admin.site.register(Layer, LayerAdmin)
-admin.site.register(LayerUpload, LayerUploadAdmin)
diff --git a/django_project/cloud_native_gis/models/layer.py b/django_project/cloud_native_gis/models/layer.py
index 6328c2c..ff78fdb 100644
--- a/django_project/cloud_native_gis/models/layer.py
+++ b/django_project/cloud_native_gis/models/layer.py
@@ -147,6 +147,14 @@ def absolute_tile_url(self, request):
else:
return None
+ def maputnik_url(self, request):
+ """Return absolute url for maputnik."""
+ from cloud_native_gis.utils.layer import layer_api_url, maputnik_url
+ if self.tile_url and request:
+ return f"{maputnik_url()}?api-url={layer_api_url(self, request)}"
+ else:
+ return None
+
def update_default_style(self, style: Style):
"""Update default style."""
self.default_style = style