1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(networks): the XML editor does not overwrite a change made meanwhile

The network and filter XML editors defined what they sent as a whole, so
a page opened before another admin's change (a QoS limit, a filter rule)
saved over it and the change was gone without a word. The editor now
sends a digest of the definition it showed, and a definition changed
since is refused with a reload hint.
This commit is contained in:
catborise 2026-11-12 13:02:20 +03:00
parent 534782fdda
commit d00f7d8841
16 changed files with 151 additions and 98 deletions

View file

@ -485,9 +485,12 @@ class wvmNetwork(wvmConnect):
limit.getparent().remove(limit)
self._define(tree)
def edit_network(self, new_xml):
def edit_network(self, new_xml, seen):
"""Defines this network anew from new_xml: of the same name and, if it
names one, the same UUID, not another network."""
names one, the same UUID, not another network; seen is the digest of
the saved definition the editor showed."""
if seen != util.digest(self.saved_xml):
raise util.OperationError(gettext_noop("Network %(net)s was changed meanwhile; reload the page"), net=self.net.name())
tree = util.parse_xml(new_xml)
if tree.tag != "network" or tree.findtext("name") != self.net.name():
raise util.OperationError(gettext_noop("The XML must define network %(net)s"), net=self.net.name())