Skip to content

Commit

Permalink
Hide editor url if layer is not ready
Browse files Browse the repository at this point in the history
  • Loading branch information
meomancer committed Jul 12, 2024
1 parent cf773ff commit 90ce34b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions django_project/cloud_native_gis/admin/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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"<a target='__blank__' href='{maputnik_url()}?"
f"api-url={layer_api_url(obj, self.request)}"
Expand All @@ -69,6 +73,7 @@ def editor(self, obj: Layer):
editor.allow_tags = True


@admin.register(LayerUpload)
class LayerUploadAdmin(admin.ModelAdmin):
"""Layer admin."""

Expand All @@ -84,7 +89,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)

0 comments on commit 90ce34b

Please sign in to comment.