mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(jobs): a busy message names what the job in the way works on
A verification of a chain's base refused a verification of its incremental with "Verify backup is running on this resource": which backup held it was not said. The job's resource label now follows its name for who may see the job, as on the Jobs page; not in an audit row or a bulk migration's error, which others read.
This commit is contained in:
parent
7b23c75bf5
commit
57e90e0d27
6 changed files with 24 additions and 5 deletions
|
|
@ -28,6 +28,20 @@ class BusyMessageTestCase(SimpleTestCase):
|
|||
self.assertIn(" çalışıyor ", text)
|
||||
self.assertNotIn("running", text)
|
||||
|
||||
def test_the_job_in_the_way_is_named_with_what_it_works_on_to_who_may_see_it(self):
|
||||
from types import SimpleNamespace
|
||||
|
||||
from operations.utils import busy_message
|
||||
op = Operation(kind="backup.verify", state=Operation.RUNNING, created_at=django_timezone.now(), user_id=2,
|
||||
username="admin", resource_label="vm1 2026-11-19 16:00")
|
||||
text = busy_message(SimpleNamespace(blocker=op), SimpleNamespace(is_superuser=True, pk=1))
|
||||
self.assertTrue(text.startswith("Verify backup (vm1 2026-11-19 16:00) is running on this resource"), text)
|
||||
text = busy_message(SimpleNamespace(blocker=op), SimpleNamespace(is_superuser=False, pk=1))
|
||||
self.assertTrue(text.startswith("Verify backup is running on this resource"), text)
|
||||
# kept in an audit row, which a VM's owner may read
|
||||
text = busy_message(SimpleNamespace(blocker=op), SimpleNamespace(is_superuser=True, pk=1), named=False)
|
||||
self.assertTrue(text.startswith("Verify backup is running on this resource"), text)
|
||||
|
||||
|
||||
class StateColorsTestCase(SimpleTestCase):
|
||||
def test_every_state_has_its_colour(self):
|
||||
|
|
|
|||
|
|
@ -191,12 +191,16 @@ def summary(op, user):
|
|||
return base
|
||||
|
||||
|
||||
def busy_message(busy, user):
|
||||
def busy_message(busy, user, named=True):
|
||||
"""Why busy refused user. named: with what the job in the way works on; not in a text kept where others
|
||||
read it (an audit row, a job's error)."""
|
||||
op = busy.blocker
|
||||
if op is None:
|
||||
return _("A short operation is in progress on this resource; try again in a moment.")
|
||||
values = {"label": _(jobs.label_of(op.kind)), "state": pgettext("job state", op.state), "since": timesince(op.created_at, timezone.now())}
|
||||
if may_see(op, user):
|
||||
if named and op.resource_label: # which backup, VM or volume it works on: one in the way may be another
|
||||
values["label"] = f"{values['label']} ({shown_label(op, user)})"
|
||||
return _("%(label)s is %(state)s on this resource (started by %(user)s, %(since)s ago); "
|
||||
"see the Jobs page.") % {**values, "user": op.username}
|
||||
return _("%(label)s is %(state)s on this resource (since %(since)s).") % values
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue