Do not allow the instance’s name to change
This commit is contained in:
parent
032596c0e4
commit
8a67e16a0b
1 changed files with 9 additions and 1 deletions
|
@ -173,6 +173,11 @@ class CrdModelFormMixin:
|
||||||
for field in ("organization", "context"):
|
for field in ("organization", "context"):
|
||||||
self.fields[field].widget = forms.HiddenInput()
|
self.fields[field].widget = forms.HiddenInput()
|
||||||
|
|
||||||
|
if self.instance and self.instance.pk:
|
||||||
|
self.fields["name"].disabled = True
|
||||||
|
self.fields["name"].help_text = _("Name cannot be changed after creation.")
|
||||||
|
self.fields["name"].widget = forms.HiddenInput()
|
||||||
|
|
||||||
def strip_title(self, field_name, label):
|
def strip_title(self, field_name, label):
|
||||||
field = self.fields[field_name]
|
field = self.fields[field_name]
|
||||||
if field and field.label.startswith(label):
|
if field and field.label.startswith(label):
|
||||||
|
@ -183,7 +188,10 @@ class CrdModelFormMixin:
|
||||||
|
|
||||||
# General fieldset for non-spec fields
|
# General fieldset for non-spec fields
|
||||||
general_fields = [
|
general_fields = [
|
||||||
field for field in self.fields if not field.startswith("spec.")
|
field_name
|
||||||
|
for field_name, field in self.fields.items()
|
||||||
|
if not field_name.startswith("spec.")
|
||||||
|
and not isinstance(field.widget, forms.HiddenInput)
|
||||||
]
|
]
|
||||||
if general_fields:
|
if general_fields:
|
||||||
fieldsets.append(
|
fieldsets.append(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue