set other lxc templates to not default on change
This commit is contained in:
@@ -343,6 +343,11 @@ class LxcTemplate(ProxmoxAbstractModel, TaskAwareModelMixin):
|
|||||||
is_default_template = models.BooleanField(default=False,
|
is_default_template = models.BooleanField(default=False,
|
||||||
help_text='If true, this template will be used when creating new containers as default, or preselected')
|
help_text='If true, this template will be used when creating new containers as default, or preselected')
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
if self.is_default_template:
|
||||||
|
self.objects.filter(models.Q(is_default_template=True), ~models.Q(internal_id=self.pk)).update(is_default_template=False)
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.volid.split('/')[-1]
|
return self.volid.split('/')[-1]
|
||||||
|
|
||||||
@@ -352,3 +357,4 @@ class LxcTemplate(ProxmoxAbstractModel, TaskAwareModelMixin):
|
|||||||
@property
|
@property
|
||||||
def human_size(self):
|
def human_size(self):
|
||||||
return human_size(self.size)
|
return human_size(self.size)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user