3
0
Fork 0

feat: add "complete" (sic) timezone support

at least for now, this is enough to let admin define the global
default timezone for app, and override system local timezone.

eventually should support per-user timezone..some day..
This commit is contained in:
Lance Edgar 2025-12-16 22:52:33 -06:00
parent 286c683c93
commit 7fcb331806
10 changed files with 274 additions and 93 deletions

View file

@ -1663,6 +1663,9 @@ class TestMasterView(WebTestCase):
def test_configure(self):
self.pyramid_config.include("wuttaweb.views.common")
self.pyramid_config.include("wuttaweb.views.auth")
self.pyramid_config.add_route(
"appinfo.check_timezone", "/appinfo/check-timezone"
)
model = self.app.model
# mock settings
@ -1697,6 +1700,7 @@ class TestMasterView(WebTestCase):
def get_context(**kw):
kw = original_context(**kw)
kw["menu_handlers"] = []
kw["default_timezone"] = "UTC"
return kw
with patch.object(view, "configure_get_context", new=get_context):

View file

@ -46,6 +46,26 @@ class TestAppInfoView(WebTestCase):
view = self.make_view()
context = view.configure_get_context()
def test_configure_check_timezone(self):
view = self.make_view()
# normal
with patch.object(self.request, "GET", new={"tzname": "America/Chicago"}):
result = view.configure_check_timezone()
self.assertFalse(result["invalid"])
# invalid
with patch.object(self.request, "GET", new={"tzname": "bad_name"}):
result = view.configure_check_timezone()
self.assertEqual(
result["invalid"], "'No time zone found with key bad_name'"
)
# missing input
with patch.object(self.request, "GET", new={}):
result = view.configure_check_timezone()
self.assertEqual(result["invalid"], "Must provide 'tzname' parameter.")
class TestSettingView(WebTestCase):