diff --git a/appointment/__init__.py b/appointment/__init__.py index c7615a7..83417df 100644 --- a/appointment/__init__.py +++ b/appointment/__init__.py @@ -6,5 +6,5 @@ __url__ = "https://github.com/adamspd/django-appointment" __package_website__ = "https://django-appt.adamspierredavid.com/" __package_doc_url__ = "https://django-appt-doc.adamspierredavid.com/overview.html" -__version__ = "3.5.0" +__version__ = "3.5.1" __test_version__ = False diff --git a/appointment/services.py b/appointment/services.py index a08fc53..c890725 100644 --- a/appointment/services.py +++ b/appointment/services.py @@ -561,9 +561,7 @@ def handle_service_management_request(post_data, files_data=None, service_id=Non def create_new_appointment(data, request): service = Service.objects.get(id=data.get("service_id")) - print(f"service id {data.get('service_id')}") - print(f"Service: {service}") - staff_id = data.get("staff_id") + staff_id = data.get("staff_member") if staff_id: staff_member = StaffMember.objects.get(id=staff_id) else: @@ -618,7 +616,7 @@ def create_new_appointment(data, request): def update_existing_appointment(data, request): try: appt = Appointment.objects.get(id=data.get("appointment_id")) - staff_id = data.get("staff_id") + staff_id = data.get("staff_member") want_reminder = data.get("want_reminder") == 'true' appt = save_appointment( appt, diff --git a/appointment/static/js/app_admin/staff_index.js b/appointment/static/js/app_admin/staff_index.js index 23c03ac..9714b7c 100644 --- a/appointment/static/js/app_admin/staff_index.js +++ b/appointment/static/js/app_admin/staff_index.js @@ -461,7 +461,7 @@ async function populateStaffMembers(selectedStaffId, isEditMode = false) { // Function to fetch services for a specific staff member async function fetchServicesForStaffMember(staffId) { - const url = `${fetchServiceListForStaffURL}?staff_id=${staffId}`; + const url = `${fetchServiceListForStaffURL}?staff_member=${staffId}`; try { const response = await fetch(url); if (!response.ok) throw new Error('Network response was not ok'); @@ -779,7 +779,7 @@ function collectFormDataFromModal(modal) { }; if (staffId) { - data.staff_id = staffId; + data.staff_member = staffId; } inputs.forEach(input => { diff --git a/appointment/static/js/appointments.js b/appointment/static/js/appointments.js index 4ef6225..1df6b5d 100644 --- a/appointment/static/js/appointments.js +++ b/appointment/static/js/appointments.js @@ -158,7 +158,7 @@ function fetchNonWorkingDays(staffId, callback) { return; // Exit the function early } let ajaxData = { - 'staff_id': staffId, + 'staff_member': staffId, }; $.ajax({ diff --git a/appointment/tests/test_views.py b/appointment/tests/test_views.py index 6dc110a..3870708 100644 --- a/appointment/tests/test_views.py +++ b/appointment/tests/test_views.py @@ -397,7 +397,7 @@ def setUp(self): 'client_email': 'vala.mal-doran@django-appointment.com', 'client_phone': '+12392350345', 'client_address': '456 Outer Rim, Free Jaffa Nation', 'want_reminder': 'false', 'additional_info': '', 'start_time': '15:00:26', - 'staff_id': self.staff_member1.id, + 'staff_member': self.staff_member1.id, 'date': self.tomorrow.strftime('%Y-%m-%d') } @@ -773,7 +773,7 @@ def setUp(self): def test_get_next_available_date_ajax(self): """get_next_available_date_ajax view should return a JSON response with the next available date.""" - data = {'staff_id': self.staff_member.id} + data = {'staff_member': self.staff_member.id} url = reverse('appointment:request_next_available_slot', args=[self.service1.id]) response = self.client.get(url, data=data, HTTP_X_REQUESTED_WITH='XMLHttpRequest') self.assertEqual(response.status_code, 200) @@ -942,7 +942,7 @@ def setUp(self): def test_no_staff_member_selected(self): """Test the response when no staff member is selected.""" - response = self.client.get(self.url, {'staff_id': 'none'}, HTTP_X_REQUESTED_WITH='XMLHttpRequest') + response = self.client.get(self.url, {'staff_member': 'none'}, HTTP_X_REQUESTED_WITH='XMLHttpRequest') self.assertEqual(response.status_code, 200) response_data = response.json() self.assertFalse(response_data['success']) @@ -952,7 +952,7 @@ def test_no_staff_member_selected(self): def test_valid_staff_member_selected(self): """Test the response for a valid staff member selection.""" - response = self.client.get(self.url, {'staff_id': self.staff_member1.id}, + response = self.client.get(self.url, {'staff_member': self.staff_member1.id}, HTTP_X_REQUESTED_WITH='XMLHttpRequest') self.assertEqual(response.status_code, 200) response_data = response.json() @@ -963,7 +963,7 @@ def test_valid_staff_member_selected(self): def test_ajax_required(self): """Ensure the view only responds to AJAX requests.""" - non_ajax_response = self.client.get(self.url, {'staff_id': self.staff_member1.id}) + non_ajax_response = self.client.get(self.url, {'staff_member': self.staff_member1.id}) self.assertEqual(non_ajax_response.status_code, 200) diff --git a/appointment/views.py b/appointment/views.py index c1ff3d8..9565b63 100644 --- a/appointment/views.py +++ b/appointment/views.py @@ -59,6 +59,7 @@ def get_available_slots_ajax(request): """ slot_form = SlotForm(request.GET) + error_code = 0 if not slot_form.is_valid(): custom_data = {'error': True, 'available_slots': [], 'date_chosen': ''} if 'selected_date' in slot_form.errors: @@ -114,7 +115,7 @@ def get_next_available_date_ajax(request, service_id): :param service_id: The ID of the service. :return: A JSON response containing the next available date. """ - staff_id = request.GET.get('staff_id') + staff_id = request.GET.get('staff_member') # If staff_id is not provided, you should handle it accordingly. if staff_id and staff_id != 'none': @@ -156,8 +157,7 @@ def get_next_available_date_ajax(request, service_id): def get_non_working_days_ajax(request): - staff_id = request.GET.get('staff_id') - print(f"staff_id: {staff_id}") + staff_id = request.GET.get('staff_member') error = False message = _('Successfully retrieved non-working days') diff --git a/appointment/views_admin.py b/appointment/views_admin.py index 525e0fb..c3dd9f1 100644 --- a/appointment/views_admin.py +++ b/appointment/views_admin.py @@ -231,7 +231,7 @@ def add_or_update_staff_info(request, user_id=None): @require_staff_or_superuser def fetch_service_list_for_staff(request): appointment_id = request.GET.get('appointmentId') - staff_id = request.GET.get('staff_id') + staff_id = request.GET.get('staff_member') if appointment_id: # Fetch services for a specific appointment (edit mode) if request.user.is_superuser: