Skip to content

Commit 711081a

Browse files
committed
don't use settings.TIME_ZONE directly
1 parent ea85dd0 commit 711081a

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

appointment/utils/json_context.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
Since: 2.0.0
77
"""
88

9-
import pytz
109
from django.http import JsonResponse
1110
from django.shortcuts import render
1211
from django.urls import reverse
13-
from django.conf import settings
1412

1513
from appointment.settings import APPOINTMENT_ADMIN_BASE_TEMPLATE, APPOINTMENT_BASE_TEMPLATE
1614
from appointment.utils.db_helpers import username_in_user_model
@@ -20,12 +18,11 @@
2018
def convert_appointment_to_json(request, appointments: list) -> list:
2119
"""Convert a queryset of Appointment objects to a JSON serializable format."""
2220
su = request.user.is_superuser
23-
tz = pytz.timezone(settings.TIME_ZONE)
2421
return [{
2522
"id": appt.id,
2623
"client": appt.client.username if username_in_user_model() else "",
27-
"start_time": tz.localize(appt.get_start_time()).isoformat(),
28-
"end_time": tz.localize(appt.get_end_time()).isoformat(),
24+
"start_time": appt.get_start_time().isoformat(),
25+
"end_time": appt.get_end_time().isoformat(),
2926
"client_name": appt.get_client_name(),
3027
"url": appt.get_absolute_url(request),
3128
"background_color": appt.get_background_color(),
@@ -37,7 +34,6 @@ def convert_appointment_to_json(request, appointments: list) -> list:
3734
"staff_id": appt.appointment_request.staff_member.id,
3835
"additional_info": appt.additional_info,
3936
"want_reminder": appt.want_reminder,
40-
"timezone": settings.TIME_ZONE,
4137
} for appt in appointments]
4238

4339

@@ -59,7 +55,6 @@ def get_generic_context(request, admin=True):
5955
return {
6056
'BASE_TEMPLATE': APPOINTMENT_ADMIN_BASE_TEMPLATE if admin else APPOINTMENT_BASE_TEMPLATE,
6157
'user': request.user,
62-
'timezone': settings.TIME_ZONE,
6358
'is_superuser': request.user.is_superuser,
6459
}
6560

appointment/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def get_available_slots_ajax(request):
9898
# Check if the selected_date is today and filter out past slots
9999
if selected_date == date.today():
100100
# Get the current time in EDT timezone
101-
current_time_edt = datetime.now(pytz.timezone(settings.TIME_ZONE)).time()
101+
current_time_edt = datetime.now(pytz.timezone('Europe/Paris')).time()
102102
available_slots = [slot for slot in available_slots if convert_str_to_time(slot) > current_time_edt]
103103

104104
custom_data['available_slots'] = available_slots

appointments/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110

111111
LANGUAGE_CODE = "en"
112112

113-
TIME_ZONE = 'Europe/Paris'
113+
TIME_ZONE = 'UTC'
114114

115115
USE_I18N = True
116116

0 commit comments

Comments
 (0)