@@ -239,7 +239,7 @@ def fetch_service_list_for_staff(request):
239
239
# Ensure the staff member is associated with this appointment
240
240
if not Appointment .objects .filter (id = appointment_id ,
241
241
appointment_request__staff_member = staff_member ).exists ():
242
- return json_response ( _ ("You do not have permission to access this appointment." ), status_code = 403 )
242
+ return handle_unauthorized_response ( request , _ ("You do not have permission to access this appointment." ), response_type = 'html' )
243
243
else :
244
244
# Fetch all services for the staff member (create mode)
245
245
try :
@@ -346,7 +346,7 @@ def update_personal_info(request, staff_user_id=None):
346
346
'email' : user .email ,
347
347
}, user = user )
348
348
349
- context = get_generic_context_with_extra (request = request , extra = {'form' : form })
349
+ context = get_generic_context_with_extra (request = request , extra = {'form' : form , 'btn_text' : _ ( "Update" ) })
350
350
return render (request , 'administration/manage_staff_personal_info.html' , context )
351
351
352
352
@@ -386,7 +386,7 @@ def create_new_staff_member(request):
386
386
return redirect ('appointment:add_staff_member_personal_info' )
387
387
388
388
form = PersonalInformationForm ()
389
- context = get_generic_context_with_extra (request = request , extra = {'form' : form })
389
+ context = get_generic_context_with_extra (request = request , extra = {'form' : form , 'btn_text' : _ ( "Create" ) })
390
390
return render (request , 'administration/manage_staff_personal_info.html' , context = context )
391
391
392
392
@@ -491,6 +491,9 @@ def get_service_list(request, response_type='html'):
491
491
@require_staff_or_superuser
492
492
def delete_appointment (request , appointment_id ):
493
493
appointment = get_object_or_404 (Appointment , pk = appointment_id )
494
+ if not check_extensive_permissions (appointment .get_staff_member ().user_id , request .user , appointment ):
495
+ message = _ ("You can only delete your own appointments." )
496
+ return handle_unauthorized_response (request , message , 'html' )
494
497
appointment .delete ()
495
498
messages .success (request , _ ("Appointment deleted successfully!" ))
496
499
return redirect ('appointment:get_user_appointments' )
@@ -502,6 +505,9 @@ def delete_appointment_ajax(request):
502
505
data = json .loads (request .body )
503
506
appointment_id = data .get ("appointment_id" )
504
507
appointment = get_object_or_404 (Appointment , pk = appointment_id )
508
+ if not check_extensive_permissions (appointment .get_staff_member ().user_id , request .user , appointment ):
509
+ message = _ ("You can only delete your own appointments." )
510
+ return json_response (message , status = 403 , success = False , error_code = ErrorCode .NOT_AUTHORIZED )
505
511
appointment .delete ()
506
512
return json_response (_ ("Appointment deleted successfully." ))
507
513
0 commit comments