Skip to content

Commit

Permalink
SCKAN-275 feat: Add basic admin panel controls
Browse files Browse the repository at this point in the history
  • Loading branch information
afonsobspinto committed Mar 19, 2024
1 parent 96ffa1e commit 776237e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
33 changes: 30 additions & 3 deletions backend/composer/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Tag,
Via,
FunctionalCircuitRole,
ProjectionPhenotype, Destination, Synonym
ProjectionPhenotype, Destination, Synonym, AnatomicalEntityMeta, Layer, Region, AnatomicalEntityIntersection
)


Expand Down Expand Up @@ -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]


Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion backend/composer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 776237e

Please sign in to comment.