Skip to content
Snippets Groups Projects
Commit 0bfa5a82 authored by Eva Bardou's avatar Eva Bardou
Browse files

Prevent element_corpus update + Disable Element creation in admin panel

parent ccdc7abc
No related branches found
No related tags found
1 merge request!1316Prevent element_corpus update + Disable Element creation in admin panel
......@@ -71,10 +71,14 @@ class ElementAdmin(admin.ModelAdmin):
list_display = ('id', 'name', 'type', 'corpus', )
list_filter = ['type__slug', 'corpus']
fields = ('id', 'type', 'name', 'corpus')
readonly_fields = ('id', )
readonly_fields = ('id', 'corpus', )
search_fields = ('name', )
inlines = (MetaDataInline, ClassificationInline)
# Disable element creation through the admin to prevent element_type conflicts
def has_add_permission(self, request):
return False
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'type':
# Only display types available on the element's corpus
......
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