fix: fetch required details from appointment booking settings
This commit is contained in:
parent
9a00b3bdbd
commit
ac51c27500
@ -26,8 +26,12 @@ def get_context(context):
|
|||||||
|
|
||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def get_appointment_settings():
|
def get_appointment_settings():
|
||||||
settings = frappe.get_doc("Appointment Booking Settings")
|
settings = frappe.get_cached_value(
|
||||||
settings.holiday_list = frappe.get_doc("Holiday List", settings.holiday_list)
|
"Appointment Booking Settings",
|
||||||
|
None,
|
||||||
|
["holiday_list", "advance_booking_days", "appointment_duration", "success_redirect_url"],
|
||||||
|
as_dict=True,
|
||||||
|
)
|
||||||
return settings
|
return settings
|
||||||
|
|
||||||
|
|
||||||
@ -90,23 +94,27 @@ def get_available_slots_between(query_start_time, query_end_time, settings):
|
|||||||
|
|
||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def create_appointment(date, time, tz, contact):
|
def create_appointment(date, time, tz, contact):
|
||||||
format_string = "%Y-%m-%d %H:%M:%S"
|
contact = json.loads(contact)
|
||||||
scheduled_time = datetime.datetime.strptime(date + " " + time, format_string)
|
datetime_obj = datetime.datetime.strptime(date + " " + time, "%Y-%m-%d %H:%M:%S")
|
||||||
# Strip tzinfo from datetime objects since it's handled by the doctype
|
# Strip tzinfo from datetime objects since it's handled by the doctype
|
||||||
|
scheduled_time_obj = datetime_obj.replace(tzinfo=None)
|
||||||
|
scheduled_time = convert_to_system_timezone(tz, scheduled_time_obj)
|
||||||
scheduled_time = scheduled_time.replace(tzinfo=None)
|
scheduled_time = scheduled_time.replace(tzinfo=None)
|
||||||
scheduled_time = convert_to_system_timezone(tz, scheduled_time)
|
|
||||||
scheduled_time = scheduled_time.replace(tzinfo=None)
|
|
||||||
# Create a appointment document from form
|
# Create a appointment document from form
|
||||||
appointment = frappe.new_doc("Appointment")
|
appointment = frappe.new_doc("Appointment")
|
||||||
appointment.scheduled_time = scheduled_time
|
appointment.update(
|
||||||
contact = json.loads(contact)
|
{
|
||||||
appointment.customer_name = contact.get("name", None)
|
"scheduled_time": scheduled_time,
|
||||||
appointment.customer_phone_number = contact.get("number", None)
|
"customer_name": contact.get("name", None),
|
||||||
appointment.customer_skype = contact.get("skype", None)
|
"customer_phone_number": contact.get("number", None),
|
||||||
appointment.customer_details = contact.get("notes", None)
|
"customer_skype": contact.get("skype", None),
|
||||||
appointment.customer_email = contact.get("email", None)
|
"customer_details": contact.get("notes", None),
|
||||||
appointment.status = "Open"
|
"customer_email": contact.get("email", None),
|
||||||
appointment.insert()
|
"status": "Open",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
appointment.insert(ignore_permissions=True)
|
||||||
return appointment
|
return appointment
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import frappe
|
|||||||
from frappe.utils.verified_command import verify_request
|
from frappe.utils.verified_command import verify_request
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist(allow_guest=True)
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
if not verify_request():
|
if not verify_request():
|
||||||
context.success = False
|
context.success = False
|
||||||
@ -15,7 +14,6 @@ def get_context(context):
|
|||||||
appointment = frappe.get_doc("Appointment", appointment_name)
|
appointment = frappe.get_doc("Appointment", appointment_name)
|
||||||
appointment.set_verified(email)
|
appointment.set_verified(email)
|
||||||
context.success = True
|
context.success = True
|
||||||
return context
|
|
||||||
else:
|
else:
|
||||||
context.success = False
|
context.success = False
|
||||||
return context
|
return context
|
||||||
|
Loading…
x
Reference in New Issue
Block a user