From f155caa268937c129904db4ffa14b77f7b2907e5 Mon Sep 17 00:00:00 2001 From: "Christopher C. Wells" Date: Sat, 11 Jun 2022 14:27:52 -0700 Subject: [PATCH] Remove deprecated `TIME_ZONE` environment variable configuration Closes #301 --- babybuddy/middleware.py | 7 +++---- babybuddy/settings/base.py | 2 +- babybuddy/tests/tests_forms.py | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/babybuddy/middleware.py b/babybuddy/middleware.py index 9af7cb70..4e7fd9e2 100644 --- a/babybuddy/middleware.py +++ b/babybuddy/middleware.py @@ -104,10 +104,9 @@ class UserLanguageMiddleware: class UserTimezoneMiddleware: """ - Sets the timezone based on a user specific setting that falls back on - `settings.TIME_ZONE`. This middleware must run after - `django.contrib.auth.middleware.AuthenticationMiddleware` because it uses - the request.user object. + Sets the timezone based on a user specific setting. This middleware must run after + `django.contrib.auth.middleware.AuthenticationMiddleware` because it uses the + request.user object. """ def __init__(self, get_response): diff --git a/babybuddy/settings/base.py b/babybuddy/settings/base.py index 57a7da9a..464cce02 100644 --- a/babybuddy/settings/base.py +++ b/babybuddy/settings/base.py @@ -158,7 +158,7 @@ if REVERSE_PROXY_AUTH: USE_TZ = True -TIME_ZONE = os.environ.get("TIME_ZONE") or "UTC" +TIME_ZONE = "UTC" # Internationalization # https://docs.djangoproject.com/en/4.0/topics/i18n/ diff --git a/babybuddy/tests/tests_forms.py b/babybuddy/tests/tests_forms.py index 457436dd..467b77ce 100644 --- a/babybuddy/tests/tests_forms.py +++ b/babybuddy/tests/tests_forms.py @@ -222,11 +222,10 @@ class FormsTestCase(TestCase): page = self.c.post("/user/settings/", data=params, follow=True) self.assertContains(page, "Paramètres utilisateur") - @override_settings(TIME_ZONE="US/Eastern") def test_user_settings_timezone(self): self.c.login(**self.credentials) - self.assertEqual(timezone.get_default_timezone_name(), "US/Eastern") + self.assertEqual(timezone.get_default_timezone_name(), "UTC") params = self.settings_template.copy() params["timezone"] = "US/Pacific" page = self.c.post("/user/settings/", data=params, follow=True)