|
6 | 6 | Since: 1.0.0
|
7 | 7 | """
|
8 | 8 |
|
9 |
| -from datetime import date, datetime, timedelta |
| 9 | +from datetime import date, timedelta |
10 | 10 |
|
11 |
| -import pytz |
12 |
| -from django.conf import settings |
13 | 11 | from django.contrib import messages
|
14 | 12 | from django.contrib.auth import login
|
15 | 13 | from django.contrib.auth.forms import SetPasswordForm
|
16 | 14 | from django.db.models import Q
|
17 | 15 | from django.http import HttpResponseRedirect
|
18 | 16 | from django.shortcuts import get_object_or_404, redirect, render
|
19 | 17 | from django.urls import reverse
|
| 18 | +from django.utils import timezone |
20 | 19 | from django.utils.encoding import force_str
|
21 | 20 | from django.utils.http import urlsafe_base64_decode
|
| 21 | +from django.utils.timezone import get_current_timezone_name |
22 | 22 | from django.utils.translation import gettext as _
|
23 | 23 |
|
24 | 24 | from appointment.forms import AppointmentForm, AppointmentRequestForm
|
|
38 | 38 | send_reschedule_confirmation_email, \
|
39 | 39 | send_thank_you_email
|
40 | 40 | from appointment.utils.session import get_appointment_data_from_session, handle_existing_email
|
41 |
| -from appointment.utils.view_helpers import get_locale, get_timezone_txt |
| 41 | +from appointment.utils.view_helpers import get_locale |
42 | 42 | from .decorators import require_ajax
|
43 | 43 | from .messages_ import passwd_error, passwd_set_successfully
|
44 | 44 | from .services import get_appointments_and_slots, get_available_slots_for_staff
|
45 | 45 | from .settings import (APPOINTMENT_PAYMENT_URL, APPOINTMENT_THANK_YOU_URL)
|
46 |
| -from .utils.date_time import convert_str_to_date, convert_str_to_time |
| 46 | +from .utils.date_time import convert_str_to_date |
47 | 47 | from .utils.error_codes import ErrorCode
|
48 | 48 | from .utils.json_context import get_generic_context_with_extra, json_response
|
49 | 49 |
|
@@ -96,11 +96,10 @@ def get_available_slots_ajax(request):
|
96 | 96 |
|
97 | 97 | # Check if the selected_date is today and filter out past slots
|
98 | 98 | if selected_date == date.today():
|
99 |
| - # Get the current time in EDT timezone |
100 |
| - current_time_edt = datetime.now(pytz.timezone(settings.TIME_ZONE)).time() |
101 |
| - available_slots = [slot for slot in available_slots if convert_str_to_time(slot) > current_time_edt] |
| 99 | + current_time = timezone.now().time() |
| 100 | + available_slots = [slot for slot in available_slots if slot.time() > current_time] |
102 | 101 |
|
103 |
| - custom_data['available_slots'] = available_slots |
| 102 | + custom_data['available_slots'] = [slot.strftime('%I:%M %p') for slot in available_slots] |
104 | 103 | if len(available_slots) == 0:
|
105 | 104 | custom_data['error'] = True
|
106 | 105 | message = _('No availability')
|
@@ -219,7 +218,7 @@ def appointment_request(request, service_id=None, staff_member_id=None):
|
219 | 218 | 'available_slots': available_slots,
|
220 | 219 | 'date_chosen': date_chosen,
|
221 | 220 | 'locale': get_locale(),
|
222 |
| - 'timezoneTxt': get_timezone_txt(), |
| 221 | + 'timezoneTxt': get_current_timezone_name(), |
223 | 222 | 'label': label
|
224 | 223 | }
|
225 | 224 | context = get_generic_context_with_extra(request, extra_context, admin=False)
|
@@ -524,10 +523,10 @@ def prepare_reschedule_appointment(request, id_request):
|
524 | 523 | 'all_staff_members': all_staff_members,
|
525 | 524 | 'page_title': page_title,
|
526 | 525 | 'page_description': page_description,
|
527 |
| - 'available_slots': available_slots, |
| 526 | + 'available_slots': [slot.strftime('%I:%M %p') for slot in available_slots], |
528 | 527 | 'date_chosen': date_chosen,
|
529 | 528 | 'locale': get_locale(),
|
530 |
| - 'timezoneTxt': get_timezone_txt(), |
| 529 | + 'timezoneTxt': get_current_timezone_name(), |
531 | 530 | 'label': label,
|
532 | 531 | 'rescheduled_date': ar.date.strftime("%Y-%m-%d"),
|
533 | 532 | 'page_header': page_title,
|
|
0 commit comments