From 90ce34b811f5fe261786338ded8dfa0b6f83f9cb Mon Sep 17 00:00:00 2001 From: Irwan Fathurrahman Date: Fri, 12 Jul 2024 12:58:15 +0700 Subject: [PATCH] Hide editor url if layer is not ready --- django_project/cloud_native_gis/admin/layer.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/django_project/cloud_native_gis/admin/layer.py b/django_project/cloud_native_gis/admin/layer.py index 614f461..646caff 100644 --- a/django_project/cloud_native_gis/admin/layer.py +++ b/django_project/cloud_native_gis/admin/layer.py @@ -29,11 +29,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,6 +62,8 @@ def field_names(self, obj: Layer): def editor(self, obj: Layer): """Return fields.""" + if not obj.tile_url: + return None return mark_safe( f"