Skip to content
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 @@ -5,4 +5,4 @@
__package_name__ = "django-appointment"
__url__ = "https://github.com/adamspd/django-appointment"
__version__ = "3.0.0"
__test_version__ = True
__test_version__ = False
7 changes: 4 additions & 3 deletions appointment/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
day_off_exists_for_date_range, exclude_booked_slots, get_all_appointments, get_all_staff_members,
get_appointment_by_id, get_appointments_for_date_and_time, get_staff_member_appointment_list,
get_staff_member_from_user_id_or_logged_in, get_times_from_config, get_user_by_email,
get_working_hours_for_staff_and_day, working_hours_exist)
get_working_hours_for_staff_and_day, parse_name, working_hours_exist)
from appointment.utils.error_codes import ErrorCode
from appointment.utils.json_context import convert_appointment_to_json, get_generic_context, json_response
from appointment.utils.permissions import check_entity_ownership
Expand Down Expand Up @@ -310,8 +310,10 @@ def save_appointment(appt, client_name, client_email, start_time, phone_number,
:return: The modified appointment.
"""
# Modify and save client details
first_name, last_name = parse_name(client_name)
client = appt.client
client.name = client_name
client.first_name = first_name
client.last_name = last_name
client.email = client_email
client.save()

Expand Down Expand Up @@ -593,7 +595,6 @@ def create_new_appointment(data, request):
def update_existing_appointment(data, request):
try:
appt = Appointment.objects.get(id=data.get("appointment_id"))
print(f"want_reminder: {data.get('want_reminder')}")
want_reminder = data.get("want_reminder") == 'true'
appt = save_appointment(
appt,
Expand Down
18 changes: 14 additions & 4 deletions appointment/static/js/app_admin/staff_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ function displayEventList(events, date) {
for (let item of eventItems) {
item.addEventListener('click', function () {
const eventId = this.getAttribute('data-event-id');
AppState.eventIdSelected = eventId;
showEventModal(eventId, false, false).then(r => r);
});
}
Expand Down Expand Up @@ -320,6 +321,16 @@ function confirmDeleteAppointment(appointmentId) {
}
showErrorModal(data.message, successTxt);
closeConfirmModal(); // Close the confirmation modal

// Remove the deleted appointment from the global appointments array
appointments = appointments.filter(appointment => appointment.id !== appointmentId);

// Refresh the event list for the current date
const currentDate = AppState.calendar.getDate();
const dateEvents = appointments
.filter(event => moment(currentDate).isSame(event.start_time, 'day'))
.sort((a, b) => new Date(a.start_time) - new Date(b.start_time));
displayEventList(dateEvents, currentDate);
})
.catch(error => {
console.error('Error:', error);
Expand Down Expand Up @@ -410,7 +421,6 @@ async function updateAppointmentDate(event, revertFunction) {

const responseData = await response.json();
if (response.ok) {
console.log("Updated message: " + responseData.message)
showErrorModal(responseData.message, successTxt)
} else {
console.error('Failed to update appointment date. Server responded with:', response.statusText);
Expand Down Expand Up @@ -533,6 +543,7 @@ function adjustModalButtonsVisibility(isEditMode, isCreatingMode) {
// ################################################################ //

function toggleEditMode() {
console.log("I was called in toggleEditMode")
const modal = document.getElementById("eventDetailsModal");
const appointment = appointments.find(app => Number(app.id) === Number(AppState.eventIdSelected));
AppState.isCreating = false; // Turn off creating mode
Expand All @@ -541,6 +552,8 @@ function toggleEditMode() {
if (appointment) {
AppState.isEditingAppointment = !AppState.isEditingAppointment; // Toggle the editing state
updateModalUIForEditMode(modal, AppState.isEditingAppointment);
} else {
console.error("Appointment not found!");
}
}

Expand Down Expand Up @@ -645,7 +658,6 @@ function validateEmail(email) {
const emailError = document.getElementById("emailError");

const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
console.log("Email: ", emailInput.value)
if (!emailRegex.test(emailInput.value)) {
emailInput.style.border = "1px solid red";
emailError.textContent = "Invalid email address, yeah.";
Expand All @@ -666,8 +678,6 @@ async function sendAppointmentData(data) {
'Content-Type': 'application/json', 'X-Requested-With': 'XMLHttpRequest', 'X-CSRFToken': getCSRFToken(),
};

console.log("Sending data to server: ", data);

return fetch(updateApptMinInfoURL, {
method: 'POST', headers: headers, body: JSON.stringify(data)
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ <h2>{% trans "Manage Working Hours" %}</h2>
type: 'POST',
data: form.serialize(),
success: function (response) {
console.log("response", response.success);
if (response.success) {
window.location.href = response.redirect_url;
} else {
Expand Down
2 changes: 1 addition & 1 deletion appointment/templates/administration/staff_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@
const getNonWorkingDaysURL = "{% url 'appointment:get_non_working_days_ajax' %}";
const serviceId = "{{ service.id }}";
const serviceDuration = parseInt("{{ service.duration.total_seconds }}") / 60;
const appointments = {{ appointments|safe }};
let appointments = {{ appointments|safe }};
const fetchServiceListForStaffURL = "{% url 'appointment:fetch_service_list_for_staff' %}";
const updateApptMinInfoURL = "{% url 'appointment:update_appt_min_info' %}";
const updateApptDateURL = "{% url 'appointment:update_appt_date_time' %}";
Expand Down
2 changes: 1 addition & 1 deletion appointment/tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def test_save_appointment(self):
client_address, service_id)

# Check client details
self.assertEqual(updated_appt.client.name, client_name)
self.assertEqual(updated_appt.client.get_full_name(), client_name)
self.assertEqual(updated_appt.client.email, client_email)

# Check appointment request details
Expand Down
1 change: 0 additions & 1 deletion appointment/views_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ def fetch_service_list_for_staff(request):
def update_appt_min_info(request):
data = json.loads(request.body)
is_creating = data.get('isCreating', False)
print("this is the data", data)

if is_creating:
# Logic for creating a new appointment
Expand Down
2 changes: 1 addition & 1 deletion docs/explanation.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ In the admin interface, you have various options to manage appointments, such as

For a more comprehensive guide, including visual demonstrations of these steps, please watch the following video tutorial:

[Link to Video Tutorial]
[Link to Short Video Demo](https://youtu.be/q1LSruYWKbk)