1
0
Fork 0
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:
catborise 2026-11-03 18:18:51 +03:00
parent b7b699e5fe
commit ed4ebd26df
11 changed files with 698 additions and 567 deletions

View file

@ -11,7 +11,7 @@ from django.contrib.messages import get_messages
from django.test import TestCase
from django.urls import reverse
from instances.models import Instance
from instances.utils import QUOTA_UNVERIFIED
from instances.utils import QUOTA_UNVERIFIED, QuotaExceeded
class TemplateFlagQuotaTests(TestCase):
@ -49,7 +49,7 @@ class TemplateFlagQuotaTests(TestCase):
def test_over_quota_the_template_stays_a_template(self):
Instance.objects.filter(pk=self.vm.pk).update(is_template=True)
_, messages = self.post(self.staff, is_template=False, quota="cpu")
_, messages = self.post(self.staff, is_template=False, quota=QuotaExceeded("cpu", 9, 8))
self.assertTrue(self.vm.is_template)
self.assertTrue(any("quota" in m for m in messages), messages)
@ -70,6 +70,6 @@ class TemplateFlagQuotaTests(TestCase):
def test_superusers_have_no_quota(self):
Instance.objects.filter(pk=self.vm.pk).update(is_template=True)
admin = get_user_model().objects.create_superuser("tq-admin", "tq@example.com", "pw")
check, _ = self.post(admin, is_template=False, quota="cpu")
check, _ = self.post(admin, is_template=False, quota=QuotaExceeded("cpu", 9, 8))
self.assertFalse(self.vm.is_template)
check.assert_not_called()