mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 01:16:10 +00:00
fix(tags): third audit: host form and tag delete, hosts list badges
- A host's form saves the host and its tags in one transaction under the ownership lock: a tag the Tags page deletes meanwhile is made again, instead of a 500 after the host's other changes were saved. - The hosts list shows three tags and "…" for the others, as the VM list. - "…" shows the other tags on any page, the tag filter or not.
This commit is contained in:
parent
7810fb39fe
commit
6cdaa2affd
4 changed files with 46 additions and 22 deletions
|
|
@ -1,8 +1,10 @@
|
|||
from django import forms
|
||||
from django.db import transaction
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from vrtManager.connection import CONN_SOCKET, CONN_SSH, CONN_TCP, CONN_TLS
|
||||
|
||||
from computes.models import TAG_NAME, Compute, Tag
|
||||
from computes.utils import lock_ownership
|
||||
|
||||
from .validators import validate_hostname
|
||||
|
||||
|
|
@ -72,9 +74,12 @@ class ComputeTagsMixin:
|
|||
self.initial["tags"] = list(self.instance.tags.values_list("name", flat=True))
|
||||
|
||||
def save(self, commit=True):
|
||||
compute = super().save(commit)
|
||||
if commit:
|
||||
compute.tags.set(Tag.named(self.cleaned_data["tags"]))
|
||||
# the host and its tags in one step, not while the Tags page deletes or renames one
|
||||
with transaction.atomic():
|
||||
lock_ownership()
|
||||
compute = super().save(commit)
|
||||
if commit:
|
||||
compute.tags.set(Tag.named(self.cleaned_data["tags"]))
|
||||
return compute
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue