From 776237e5c26984abf8f4803e5eea4d7bc4ac485b Mon Sep 17 00:00:00 2001 From: afonso Date: Tue, 19 Mar 2024 16:18:11 +0000 Subject: [PATCH] SCKAN-275 feat: Add basic admin panel controls --- backend/composer/admin.py | 33 ++++++++++++++++++++++++++++++--- backend/composer/models.py | 2 +- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/backend/composer/admin.py b/backend/composer/admin.py index c3b76394..3d9ed946 100644 --- a/backend/composer/admin.py +++ b/backend/composer/admin.py @@ -19,7 +19,7 @@ Tag, Via, FunctionalCircuitRole, - ProjectionPhenotype, Destination, Synonym + ProjectionPhenotype, Destination, Synonym, AnatomicalEntityMeta, Layer, Region, AnatomicalEntityIntersection ) @@ -94,10 +94,33 @@ class SynonymInline(admin.TabularInline): extra = 1 -class AnatomicalEntityAdmin(admin.ModelAdmin): +class AnatomicalEntityMetaAdmin(admin.ModelAdmin): list_display = ("name", "ontology_uri") list_display_links = ("name", "ontology_uri") - search_fields = ("name",) # or ("^name",) for search to start with + search_fields = ("name",) + + +class LayerAdmin(admin.ModelAdmin): + list_display = ('name', 'ontology_uri',) + search_fields = ('name',) + + +class RegionAdmin(admin.ModelAdmin): + list_display = ('name', 'ontology_uri',) + search_fields = ('name',) + filter_horizontal = ('layers',) + + +class AnatomicalEntityIntersectionAdmin(admin.ModelAdmin): + list_display = ('layer', 'region',) + list_filter = ('layer', 'region',) + raw_id_fields = ('layer', 'region',) + + +class AnatomicalEntityAdmin(admin.ModelAdmin): + list_display = ('name', 'ontology_uri', 'region_layer',) + search_fields = ('name',) + raw_id_fields = ('region_layer',) inlines = [SynonymInline] @@ -205,6 +228,10 @@ def get_form(self, request, obj=None, change=False, **kwargs): admin.site.register(User, UserAdmin) # +admin.site.register(AnatomicalEntityMeta, AnatomicalEntityMetaAdmin) +admin.site.register(Layer, LayerAdmin) +admin.site.register(Region, RegionAdmin) +admin.site.register(AnatomicalEntityIntersection, AnatomicalEntityIntersectionAdmin) admin.site.register(AnatomicalEntity, AnatomicalEntityAdmin) admin.site.register(Phenotype) admin.site.register(Sex) diff --git a/backend/composer/models.py b/backend/composer/models.py index 83aed628..e7c29fe4 100644 --- a/backend/composer/models.py +++ b/backend/composer/models.py @@ -258,7 +258,7 @@ def __str__(self): class Meta: ordering = ["name"] - verbose_name_plural = "Anatomical Entities Meta" + verbose_name_plural = "Anatomical Entities" class Synonym(models.Model):