diff --git a/arkindex/documents/admin.py b/arkindex/documents/admin.py index 2602e9ab28ef7a047eb9e0e37200e75324ddd29f..64f37857aa678c0e4a08935c2ac2cc152e7a786a 100644 --- a/arkindex/documents/admin.py +++ b/arkindex/documents/admin.py @@ -157,9 +157,19 @@ class EntityRoleAdmin(admin.ModelAdmin): class EntityTypeAdmin(admin.ModelAdmin): - list_display = ('id', 'name', 'color') + list_display = ('id', 'corpus', 'name', 'color') list_filter = ('corpus', ) - readonly_fields = ('id', 'corpus', ) + + def get_readonly_fields(self, request, obj=None): + # Make the corpus field read-only only for existing entity types. + # Otherwise, new EntityTypes would be created with corpus=None + if obj: + return ('id', 'corpus') + return ('id', ) + + def has_delete_permission(self, request, obj=None): + # Require everyone to use the frontend or DestroyEntityType + return False admin.site.register(Corpus, CorpusAdmin)