From afe52e8e09008c5a212cd21508c1e9f33ac73bda Mon Sep 17 00:00:00 2001 From: Pranav Nachanekar Date: Thu, 3 Oct 2019 16:35:08 +0530 Subject: [PATCH] feat: add check for toggling the route --- .../appointment_booking_settings.json | 10 +++++++++- erpnext/www/book-appointment/index.js | 18 ++++++++++++++---- erpnext/www/book-appointment/index.py | 5 +++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/erpnext/crm/doctype/appointment_booking_settings/appointment_booking_settings.json b/erpnext/crm/doctype/appointment_booking_settings/appointment_booking_settings.json index 4229e4b7887..90f3ad9410e 100644 --- a/erpnext/crm/doctype/appointment_booking_settings/appointment_booking_settings.json +++ b/erpnext/crm/doctype/appointment_booking_settings/appointment_booking_settings.json @@ -4,6 +4,7 @@ "editable_grid": 1, "engine": "InnoDB", "field_order": [ + "enable_scheduling", "availability_of_slots", "number_of_agents", "holiday_list", @@ -62,10 +63,17 @@ "label": "Agents", "options": "Assignment Rule User", "reqd": 1 + }, + { + "default": "0", + "fieldname": "enable_scheduling", + "fieldtype": "Check", + "label": "Enable Appointment Scheduling", + "reqd": 1 } ], "issingle": 1, - "modified": "2019-09-25 13:08:28.328561", + "modified": "2019-10-03 14:52:33.076253", "modified_by": "Administrator", "module": "CRM", "name": "Appointment Booking Settings", diff --git a/erpnext/www/book-appointment/index.js b/erpnext/www/book-appointment/index.js index f2496da5a63..07355e16ffb 100644 --- a/erpnext/www/book-appointment/index.js +++ b/erpnext/www/book-appointment/index.js @@ -1,7 +1,17 @@ - -frappe.ready(() => { - initialise_select_date() +frappe.ready(async () => { + debugger + let isSchedulingEnabled = await frappe.call({ + method:'erpnext.www.book-appointment.index.is_enabled' + }) + isSchedulingEnabled = isSchedulingEnabled.message + if (!isSchedulingEnabled) { + frappe.show_alert("This feature is not enabled"); + window.location.replace('/'); + return; + } + initialise_select_date(); }) + window.holiday_list = []; async function initialise_select_date() { @@ -16,7 +26,7 @@ async function get_global_variables() { // Using await window.appointment_settings = (await frappe.call({ method: 'erpnext.www.book-appointment.index.get_appointment_settings' - })).message + })).message; window.timezones = (await frappe.call({ method: 'erpnext.www.book-appointment.index.get_timezones' })).message; diff --git a/erpnext/www/book-appointment/index.py b/erpnext/www/book-appointment/index.py index 5f51ced96e2..946cc1b1925 100644 --- a/erpnext/www/book-appointment/index.py +++ b/erpnext/www/book-appointment/index.py @@ -15,6 +15,11 @@ def get_appointment_settings(): settings = frappe.get_doc('Appointment Booking Settings') return settings +@frappe.whitelist(allow_guest=True) +def is_enabled(): + enable_scheduling = frappe.db.get_single_value('Appointment Booking Settings','enable_scheduling') + return enable_scheduling + @frappe.whitelist(allow_guest=True) def get_holiday_list(holiday_list_name):