admin: make the domain field read-only after creation

fixes #3937
This commit is contained in:
Benjamin Dauvergne 2013-11-05 10:53:01 +01:00
parent 48cf5b373b
commit 38f397e54b
1 changed files with 12 additions and 0 deletions

View File

@ -24,8 +24,20 @@ class WcsInstanceAdmin(admin.ModelAdmin):
{'fields': ('drupal', 'ezldap', 'strongbox', 'clicrdv', 'domino' )}
),
)
readonly_fields = ('domain',)
inlines = [VariablesInline, ApiSecretsInline]
save_as = True
def get_prepopulated_fields(self, request, obj=None):
if obj:
return {}
return self.prepopulated_fields
def get_readonly_fields(self, request, obj=None):
readonly_fields = self.readonly_fields
if not obj:
return filter(lambda x: x != 'domain', readonly_fields)
return readonly_fields
admin.site.register(WcsInstance, WcsInstanceAdmin)