Views¶
The client-facing views live in appointment/views.py. The staff and superuser views are documented separately in
Admin views.
Ajax endpoints¶
get available slots ajax¶
This view function handles AJAX requests to get available slots for a selected date.
Args:¶
request(django.http.HttpRequest): The request instance. Readsselected_dateandstaff_memberfrom the query string.
Returns:¶
django.http.JsonResponse: A JSON response containing available slots, selected date, an error flag, and an optional error message.
get next available date ajax¶
This view function handles AJAX requests to get the next available date for a service.
Args:¶
request(django.http.HttpRequest): The request instance. Readsstaff_memberfrom the query string.service_id(int): The ID of the service.
Returns:¶
django.http.JsonResponse: A JSON response containing the next available date.
get non working days ajax¶
This view function handles AJAX requests to get the days a staff member does not work, so the calendar can render them as un-selectable.
Args:¶
request(django.http.HttpRequest): The request instance. Readsstaff_memberfrom the query string.
Returns:¶
django.http.JsonResponse: A JSON response containing the list of non-working days, or an error when no staff member was selected.
Booking flow¶
appointment request¶
This view function handles requests to book an appointment for a service.
Args:¶
request(django.http.HttpRequest): The request instance.service_id(int): The ID of the service. Optional.staff_member_id(int): The ID of a staff member to pre-select. Optional.
Returns:¶
django.http.HttpResponse: The rendered HTML page.
appointment request submit¶
This view function handles the submission of the appointment request form.
Args:¶
request(django.http.HttpRequest): The request instance.
Returns:¶
django.http.HttpResponse: The rendered HTML page.
appointment client information¶
This view function handles client information submission for an appointment. Authenticated users have their appointment created directly; anonymous users are sent through email verification first.
Args:¶
request(django.http.HttpRequest): The request instance.appointment_request_id(int): The ID of the appointment request.id_request(str): The unique ID of the appointment request.
Returns:¶
django.http.HttpResponse: The rendered HTML page.
create appointment¶
This function creates a new appointment, notifies the admin, and redirects to the payment page or the thank you page.
Args:¶
request(django.http.HttpRequest): The request instance.appointment_request_obj(appointment.models.AppointmentRequest): The AppointmentRequest instance.client_data(dict): The client data.appointment_data(dict): The appointment data.
Returns:¶
django.http.HttpResponseRedirect: The redirect response.
redirect to payment or thank you page¶
This function redirects to the payment page or the thank you page based on the configuration. The payment page is
only used when APPOINTMENT_PAYMENT_URL is set and the service is a paid one.
Args:¶
appointment(appointment.models.Appointment): The Appointment instance.
Returns:¶
django.http.HttpResponseRedirect: The redirect response.
verify user and login¶
This function verifies the user's email and logs the user in.
Args:¶
request(django.http.HttpRequest): The request instance.user: The User instance.code(str): The verification code.
Returns:¶
bool: True if the user is verified and logged in, False otherwise.
enter verification code¶
This view function handles the submission of the email verification code.
Args:¶
request(django.http.HttpRequest): The request instance.appointment_request_id(int): The ID of the appointment request.id_request(str): The unique ID of the appointment request.
Returns:¶
django.http.HttpResponse: The rendered HTML page.
default thank you¶
This view function handles the default thank you page. It also sends the confirmation email to the client.
Args:¶
request(django.http.HttpRequest): The request instance.appointment_id(int): The ID of the appointment.
Returns:¶
django.http.HttpResponse: The rendered HTML page.
Password setup¶
set passwd¶
This view function handles the password creation link emailed to a newly created client or staff member. The token is
validated through PasswordResetToken and invalidated once the password is set.
Args:¶
request(django.http.HttpRequest): The request instance.uidb64(str): The base64-encoded user ID.token(str): The password reset token.
Returns:¶
django.http.HttpResponse: The rendered form, success, or error page.
Rescheduling¶
prepare reschedule appointment¶
This view function renders the slot picker for rescheduling an existing appointment. It refuses the request with a
403 page when the reschedule limit has been reached, and it only offers a different staff member when
allow_staff_change_on_reschedule is enabled in Config.
How the limit is actually applied
The limit is checked by can_appointment_be_rescheduled, which counts the reschedule history entries created in
the last 5 minutes — so it behaves as a rate limit, not as a lifetime cap. It compares that count against
Service.reschedule_limit when the service has allow_rescheduling enabled, and against
Config.default_reschedule_limit otherwise. Note that a service with allow_rescheduling disabled is therefore
not blocked from rescheduling; it simply falls back to the global default limit.
Args:¶
request(django.http.HttpRequest): The request instance.id_request(str): The unique ID of the appointment request.
Returns:¶
django.http.HttpResponse: The rendered HTML page.
reschedule appointment submit¶
This view function handles the submission of the rescheduling form. It records an
AppointmentRescheduleHistory entry in the pending state and emails the
client a confirmation link.
Args:¶
request(django.http.HttpRequest): The request instance.
Returns:¶
django.http.HttpResponse: The rendered HTML page.
confirm reschedule¶
This view function confirms a pending reschedule from the link sent by email, moves the appointment to its new slot,
flips the history entry to confirmed (rewriting it to hold the slot the appointment just left), and notifies the
admin and the staff member. The link is only valid for 5 minutes after the reschedule was requested.
Args:¶
request(django.http.HttpRequest): The request instance.id_request(str): The unique ID of the reschedule history entry.
Returns:¶
django.http.HttpResponse: The rendered HTML page, or a404page when the link is stale or already used.