1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-10 04:06:47 +00:00

feat(operations): a job's error and warning show in the reader's language

A job stored its error and its result's warning as English text, much
of it built with the values in it (volume paths, a disk, libvirt's
error), so no catalog could translate it, and the job pages and panel
showed English whatever the language.

A job now stores them as messages: our English text, marked for
translation, and its values; libvirt's own text is a message without
values and is shown as it is. The jobs API and pages put them in the
reader's language. OperationError keeps its text and values apart for
the same reason, so a refusal raised while a job is submitted is shown
translated too. Messages one after another still read as sentences.

Errors stored before are kept as one message each, shown as they were.
This commit is contained in:
catborise 2026-11-02 23:49:45 +03:00
parent 0eab09e19d
commit 1e66367bb4
29 changed files with 927 additions and 333 deletions

View file

@ -14,6 +14,7 @@ from vrtManager.util import OperationError
from . import jobs as jobs_module
from .api.serializers import OperationSerializer
from .models import Operation, last_seen
from .utils import said, words
def _visible(user):
@ -71,7 +72,7 @@ def cancel(request, pk):
try:
jobs_module.cancel(op.pk, request.user)
except OperationError as err:
messages.error(request, str(err))
messages.error(request, words(said(err)))
return redirect("operations:job", pk=op.pk)
@ -83,5 +84,5 @@ def resolve(request, pk):
try:
jobs_module.resolve(op.pk, request.user, request.POST.get("outcome", ""), request.POST.get("note", ""))
except OperationError as err:
messages.error(request, str(err))
messages.error(request, words(said(err)))
return redirect("operations:job", pk=op.pk)