Skip to content

Commit 349a98b

Browse files
authored
Merge pull request #196 from adamspd/staff-id-not-selected-error
Fixed discrepancy between #165 and later PR
2 parents 45d9725 + 9632be4 commit 349a98b

File tree

7 files changed

+15
-17
lines changed

7 files changed

+15
-17
lines changed

appointment/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
__url__ = "https://github.com/adamspd/django-appointment"
77
__package_website__ = "https://django-appt.adamspierredavid.com/"
88
__package_doc_url__ = "https://django-appt-doc.adamspierredavid.com/overview.html"
9-
__version__ = "3.5.0"
9+
__version__ = "3.5.1"
1010
__test_version__ = False

appointment/services.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,7 @@ def handle_service_management_request(post_data, files_data=None, service_id=Non
561561

562562
def create_new_appointment(data, request):
563563
service = Service.objects.get(id=data.get("service_id"))
564-
print(f"service id {data.get('service_id')}")
565-
print(f"Service: {service}")
566-
staff_id = data.get("staff_id")
564+
staff_id = data.get("staff_member")
567565
if staff_id:
568566
staff_member = StaffMember.objects.get(id=staff_id)
569567
else:
@@ -618,7 +616,7 @@ def create_new_appointment(data, request):
618616
def update_existing_appointment(data, request):
619617
try:
620618
appt = Appointment.objects.get(id=data.get("appointment_id"))
621-
staff_id = data.get("staff_id")
619+
staff_id = data.get("staff_member")
622620
want_reminder = data.get("want_reminder") == 'true'
623621
appt = save_appointment(
624622
appt,

appointment/static/js/app_admin/staff_index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ async function populateStaffMembers(selectedStaffId, isEditMode = false) {
461461

462462
// Function to fetch services for a specific staff member
463463
async function fetchServicesForStaffMember(staffId) {
464-
const url = `${fetchServiceListForStaffURL}?staff_id=${staffId}`;
464+
const url = `${fetchServiceListForStaffURL}?staff_member=${staffId}`;
465465
try {
466466
const response = await fetch(url);
467467
if (!response.ok) throw new Error('Network response was not ok');
@@ -779,7 +779,7 @@ function collectFormDataFromModal(modal) {
779779
};
780780

781781
if (staffId) {
782-
data.staff_id = staffId;
782+
data.staff_member = staffId;
783783
}
784784

785785
inputs.forEach(input => {

appointment/static/js/appointments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function fetchNonWorkingDays(staffId, callback) {
158158
return; // Exit the function early
159159
}
160160
let ajaxData = {
161-
'staff_id': staffId,
161+
'staff_member': staffId,
162162
};
163163

164164
$.ajax({

appointment/tests/test_views.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def setUp(self):
397397
'client_email': '[email protected]', 'client_phone': '+12392350345',
398398
'client_address': '456 Outer Rim, Free Jaffa Nation',
399399
'want_reminder': 'false', 'additional_info': '', 'start_time': '15:00:26',
400-
'staff_id': self.staff_member1.id,
400+
'staff_member': self.staff_member1.id,
401401
'date': self.tomorrow.strftime('%Y-%m-%d')
402402
}
403403

@@ -773,7 +773,7 @@ def setUp(self):
773773

774774
def test_get_next_available_date_ajax(self):
775775
"""get_next_available_date_ajax view should return a JSON response with the next available date."""
776-
data = {'staff_id': self.staff_member.id}
776+
data = {'staff_member': self.staff_member.id}
777777
url = reverse('appointment:request_next_available_slot', args=[self.service1.id])
778778
response = self.client.get(url, data=data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
779779
self.assertEqual(response.status_code, 200)
@@ -942,7 +942,7 @@ def setUp(self):
942942

943943
def test_no_staff_member_selected(self):
944944
"""Test the response when no staff member is selected."""
945-
response = self.client.get(self.url, {'staff_id': 'none'}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
945+
response = self.client.get(self.url, {'staff_member': 'none'}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
946946
self.assertEqual(response.status_code, 200)
947947
response_data = response.json()
948948
self.assertFalse(response_data['success'])
@@ -952,7 +952,7 @@ def test_no_staff_member_selected(self):
952952

953953
def test_valid_staff_member_selected(self):
954954
"""Test the response for a valid staff member selection."""
955-
response = self.client.get(self.url, {'staff_id': self.staff_member1.id},
955+
response = self.client.get(self.url, {'staff_member': self.staff_member1.id},
956956
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
957957
self.assertEqual(response.status_code, 200)
958958
response_data = response.json()
@@ -963,7 +963,7 @@ def test_valid_staff_member_selected(self):
963963

964964
def test_ajax_required(self):
965965
"""Ensure the view only responds to AJAX requests."""
966-
non_ajax_response = self.client.get(self.url, {'staff_id': self.staff_member1.id})
966+
non_ajax_response = self.client.get(self.url, {'staff_member': self.staff_member1.id})
967967
self.assertEqual(non_ajax_response.status_code, 200)
968968

969969

appointment/views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def get_available_slots_ajax(request):
5959
"""
6060

6161
slot_form = SlotForm(request.GET)
62+
error_code = 0
6263
if not slot_form.is_valid():
6364
custom_data = {'error': True, 'available_slots': [], 'date_chosen': ''}
6465
if 'selected_date' in slot_form.errors:
@@ -114,7 +115,7 @@ def get_next_available_date_ajax(request, service_id):
114115
:param service_id: The ID of the service.
115116
:return: A JSON response containing the next available date.
116117
"""
117-
staff_id = request.GET.get('staff_id')
118+
staff_id = request.GET.get('staff_member')
118119

119120
# If staff_id is not provided, you should handle it accordingly.
120121
if staff_id and staff_id != 'none':
@@ -156,8 +157,7 @@ def get_next_available_date_ajax(request, service_id):
156157

157158

158159
def get_non_working_days_ajax(request):
159-
staff_id = request.GET.get('staff_id')
160-
print(f"staff_id: {staff_id}")
160+
staff_id = request.GET.get('staff_member')
161161
error = False
162162
message = _('Successfully retrieved non-working days')
163163

appointment/views_admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def add_or_update_staff_info(request, user_id=None):
231231
@require_staff_or_superuser
232232
def fetch_service_list_for_staff(request):
233233
appointment_id = request.GET.get('appointmentId')
234-
staff_id = request.GET.get('staff_id')
234+
staff_id = request.GET.get('staff_member')
235235
if appointment_id:
236236
# Fetch services for a specific appointment (edit mode)
237237
if request.user.is_superuser:

0 commit comments

Comments
 (0)