mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 12:16:49 +00:00
feat(operations): the job panel and job pages speak the page's language
The job panel on VM and storage pages wrote its buttons and notes in English (Cancel, Open, Refresh, Dismiss, Finishing..., Files not removed, Worker unavailable, Cancel failed) and its state badge as the state's code, and the jobs API gave the phase untranslated. The panel now takes its texts and the state labels from the page's settings, and the API gives the phase in the viewer's language, as it gives the label; the job pages show that phase. A job that cannot be cancelled and ran past its time limit had "(over its time limit)" written into its phase, which then matched no translation. The phase stays as the job sets it, and the pages say the job is past its limit.
This commit is contained in:
parent
9d57adc097
commit
0eab09e19d
13 changed files with 178 additions and 42 deletions
|
|
@ -1,7 +1,10 @@
|
|||
from datetime import timedelta
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.test import TransactionTestCase
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
|
||||
from accounts.models import UserInstance
|
||||
from computes.models import Compute
|
||||
|
|
@ -24,6 +27,14 @@ class OperationsApiTestCase(TransactionTestCase):
|
|||
UserInstance.objects.create(user=self.owner, instance=self.vm2)
|
||||
self.op = jobs.submit("test.noop", self.owner, {"uuid": "u1"}, "key-00000001")
|
||||
|
||||
def test_the_phase_comes_in_the_users_language_and_says_when_it_is_past_its_limit(self):
|
||||
Operation.objects.filter(pk=self.op.pk).update(state=Operation.RUNNING, phase="Merging the snapshot")
|
||||
self.client.force_login(self.owner)
|
||||
url = f"/api/v1/operations/{self.op.pk}/"
|
||||
self.assertEqual(self.client.get(url, HTTP_ACCEPT_LANGUAGE="tr").json()["phase"], "Anlık görüntü birleştiriliyor")
|
||||
Operation.objects.filter(pk=self.op.pk).update(time_limit=60, started_at=timezone.now() - timedelta(seconds=61))
|
||||
self.assertEqual(self.client.get(url).json()["phase"], "Merging the snapshot (over its time limit)")
|
||||
|
||||
def test_users_list_only_their_own_jobs(self):
|
||||
self.client.force_login(self.other)
|
||||
self.assertEqual(self.client.get("/api/v1/operations/").json()["count"], 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue