Skip to content
Snippets Groups Projects
Commit 2dcb4c7d authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

Fix EntityType creation and deletion in the Django admin

parent 454da644
No related branches found
No related tags found
1 merge request!1941Fix EntityType creation and deletion in the Django admin
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment