1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-01 16:36:06 +00:00

fix(logs): the VM page's Logs tab shows times as the Logs page does

The Logs tab of a VM's Stats showed each row's time in UTC, formatted by
the process locale ("11/10/26 08:43:08" whatever the page's language),
while the Logs page shows the same row in the panel's time zone
("2026-11-10 11:43:08" with TIME_ZONE=Europe/Istanbul). The tab now
shows the panel's time in the Logs page's format, and its Date heading
names the zone as the Logs page's does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
catborise 2026-11-10 11:52:54 +03:00
parent ae3496ac50
commit a8f7c8aeaa
7 changed files with 86 additions and 75 deletions

View file

@ -1,10 +1,14 @@
from datetime import datetime, timezone as dt_timezone
from django.contrib.auth import get_user_model
from django.test import TestCase
from django.test import TestCase, override_settings
from django.urls import reverse
from django.utils import translation
from computes.models import Compute
from instances.models import Instance
from logs.audit import write
from logs.models import Logs
from logs.views import VM_LOG_ROWS
UUID = "12345678-1234-1234-1234-123456789012"
@ -41,6 +45,15 @@ class VMLogsTestCase(TestCase):
self.assertEqual(self.shown(), [("VM test-vm: power off: not running", "Failed"),
("VM test-vm: power on", "Done")])
@override_settings(TIME_ZONE="Europe/Istanbul")
def test_a_row_shows_its_time_as_the_logs_page_does(self):
write("admin", "c1", "test-vm", "VM test-vm: power on", True, uuid=UUID)
Logs.objects.update(date=datetime(2026, 11, 10, 9, 0, tzinfo=dt_timezone.utc))
for language in ("en", "tr"):
with translation.override(language):
row = self.client.get(reverse("vm_logs", args=[self.instance.pk])).json()[0]
self.assertEqual(row["date"], "2026-11-10 12:00:00")
def test_a_vm_is_found_by_uuid_not_by_name(self):
other = Compute.objects.create(name="c2", hostname="192.0.2.2", type=1)
namesake = Instance.objects.create(compute=other, name="test-vm", uuid="87654321-4321-4321-4321-210987654321")