mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
feat(locale): quota refusals and connection errors show in the reader's language
A quota refusal put the English name of the quota (cpu, memory, disk, instance) into a translated sentence, so a Turkish page read "memory kotası doldu". check_user_quota now returns which quota and its numbers (QuotaExceeded), each quota has a whole sentence, and the refusals put that sentence before what is refused; QUOTA_DEBUG adds the numbers as before. The clone job stores the refusal as a message, so the Jobs page shows it in its reader's language. The connection errors of vrtManager (did not answer within, still waited for, closed, failed with libvirt's text) were English f-strings; they are messages now, each close reason a whole one. A connection that died without a close callback raised an error reading "None"; it now names the host. Logs keep the English text.
This commit is contained in:
parent
b7b699e5fe
commit
ed4ebd26df
11 changed files with 698 additions and 567 deletions
|
|
@ -124,7 +124,7 @@ def clone_data(user, instance, fields):
|
|||
"""The clone's settings from the form fields and the source as it is now,
|
||||
and what it adds to the user's quota; OperationError with the reason when
|
||||
it cannot be made."""
|
||||
from instances.views import VOLUME_NAME_RE, quota_refused
|
||||
from instances.views import VOLUME_NAME_RE
|
||||
|
||||
data = dict()
|
||||
data["name"] = fields.get("name", "").strip()
|
||||
|
|
@ -187,10 +187,11 @@ def clone_data(user, instance, fields):
|
|||
if key.startswith("disk-") and value is not None and not VOLUME_NAME_RE.fullmatch(value)
|
||||
]
|
||||
|
||||
if not user.is_superuser and quota_msg == utils.QUOTA_UNVERIFIED:
|
||||
raise util.OperationError(utils.QUOTA_UNVERIFIED_TEXT)
|
||||
if not user.is_superuser and quota_msg:
|
||||
raise util.OperationError(quota_refused(quota_msg, _(
|
||||
"User '%(quota_msg)s' quota reached, cannot create '%(clone_name)s'!"
|
||||
)), quota_msg=quota_msg, clone_name=data["name"])
|
||||
raise util.OperationError(_("%(quota)s: cannot create '%(clone_name)s'."),
|
||||
quota=utils.quota_message(quota_msg), clone_name=data["name"])
|
||||
if check_instance:
|
||||
raise util.OperationError(_("Instance '%(clone_name)s' already exists!"), clone_name=data["name"])
|
||||
if not re.match(r"^[a-zA-Z0-9-]+$", data["name"]):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue