Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed discrepancy between #165 and later PR #196

Merged
merged 2 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appointment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 2 additions & 4 deletions appointment/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions appointment/static/js/app_admin/staff_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -779,7 +779,7 @@ function collectFormDataFromModal(modal) {
};

if (staffId) {
data.staff_id = staffId;
data.staff_member = staffId;
}

inputs.forEach(input => {
Expand Down
2 changes: 1 addition & 1 deletion appointment/static/js/appointments.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function fetchNonWorkingDays(staffId, callback) {
return; // Exit the function early
}
let ajaxData = {
'staff_id': staffId,
'staff_member': staffId,
};

$.ajax({
Expand Down
10 changes: 5 additions & 5 deletions appointment/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def setUp(self):
'client_email': '[email protected]', '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')
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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'])
Expand All @@ -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()
Expand All @@ -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)


Expand Down
6 changes: 3 additions & 3 deletions appointment/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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')

Expand Down
2 changes: 1 addition & 1 deletion appointment/views_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading