mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 08:56:07 +00:00
fix(settings): TZ sets the panel time zone in Docker
Docker builds settings.py from the template, whose TIME_ZONE was fixed to UTC: TZ in docker-compose moved the container's clock and its backup time but not the panel's dates, and Django then reset the process's TZ to UTC. TIME_ZONE is now TZ, or UTC; the installer still writes the server's zone into settings.py.
This commit is contained in:
parent
13e553ba6f
commit
44de77854d
4 changed files with 14 additions and 2 deletions
|
|
@ -235,7 +235,10 @@ LANGUAGES = [
|
|||
("zh-hans", "简体中文"),
|
||||
]
|
||||
|
||||
TIME_ZONE = "UTC"
|
||||
# the installer writes the server's zone; Docker takes TZ (Django sets the process's TZ from this)
|
||||
TIME_ZONE = os.getenv("TZ") or "UTC"
|
||||
if TIME_ZONE.startswith(":"): # ":/etc/localtime", a libc form naming a file, is no zone name for Django
|
||||
TIME_ZONE = "UTC"
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ CONFIG_VARS = [
|
|||
"WEBVIRTCLOUD_HTTPS", "WEBVIRTCLOUD_DEBUG", "WEBVIRTCLOUD_SERIAL_CONSOLE", "ALLOWED_HOSTS",
|
||||
"EMAIL_HOST", "EMAIL_PORT", "EMAIL_HOST_USER", "EMAIL_HOST_PASSWORD", "EMAIL_USE_TLS",
|
||||
"WEBVIRTCLOUD_DB_HOST", "WEBVIRTCLOUD_DB_PORT", "WEBVIRTCLOUD_DB_NAME",
|
||||
"WEBVIRTCLOUD_DB_USER", "WEBVIRTCLOUD_DB_PASSWORD",
|
||||
"WEBVIRTCLOUD_DB_USER", "WEBVIRTCLOUD_DB_PASSWORD", "TZ",
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -178,3 +178,10 @@ class LogFileEnvTestCase(SimpleTestCase):
|
|||
self.assertEqual(self.log_file({"WEBVIRTCLOUD_LOG_FILE": ""}), str(settings.BASE_DIR / "data" / "webvirtcloud.log"))
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
self.assertEqual(self.log_file({"WEBVIRTCLOUD_LOG_FILE": f"{tmp}/w.log"}), f"{tmp}/w.log")
|
||||
|
||||
|
||||
class TimeZoneEnvTestCase(SimpleTestCase):
|
||||
def test_time_zone_from_tz_or_utc(self):
|
||||
self.assertEqual(load_settings({}, ["TIME_ZONE"])["TIME_ZONE"], "UTC")
|
||||
self.assertEqual(load_settings({"TZ": "Europe/Istanbul"}, ["TIME_ZONE"])["TIME_ZONE"], "Europe/Istanbul")
|
||||
self.assertEqual(load_settings({"TZ": ":/etc/localtime"}, ["TIME_ZONE"])["TIME_ZONE"], "UTC")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue