Merge pull request #20006 from 0Pranav/appointment-schedulling-v12
fix: multiple issues with appointment schedulling
This commit is contained in:
@@ -182,6 +182,7 @@ standard_portal_menu_items = [
|
|||||||
{"title": _("Admission"), "route": "/admissions", "reference_doctype": "Student Admission", "role": "Student"},
|
{"title": _("Admission"), "route": "/admissions", "reference_doctype": "Student Admission", "role": "Student"},
|
||||||
{"title": _("Certification"), "route": "/certification", "reference_doctype": "Certification Application", "role": "Non Profit Portal User"},
|
{"title": _("Certification"), "route": "/certification", "reference_doctype": "Certification Application", "role": "Non Profit Portal User"},
|
||||||
{"title": _("Material Request"), "route": "/material-requests", "reference_doctype": "Material Request", "role": "Customer"},
|
{"title": _("Material Request"), "route": "/material-requests", "reference_doctype": "Material Request", "role": "Customer"},
|
||||||
|
{"title": _("Appointment Booking"), "route": "/book_appointment"},
|
||||||
]
|
]
|
||||||
|
|
||||||
default_roles = [
|
default_roles = [
|
||||||
|
|||||||
@@ -24,21 +24,16 @@ async function get_global_variables() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setup_timezone_selector() {
|
function setup_timezone_selector() {
|
||||||
/**
|
|
||||||
* window.timezones is a dictionary with the following structure
|
|
||||||
* { IANA name: Pretty name}
|
|
||||||
* For example : { Asia/Kolkata : "India Time - Asia/Kolkata"}
|
|
||||||
*/
|
|
||||||
let timezones_element = document.getElementById('appointment-timezone');
|
let timezones_element = document.getElementById('appointment-timezone');
|
||||||
let offset = new Date().getTimezoneOffset();
|
let local_timezone = moment.tz.guess()
|
||||||
Object.keys(window.timezones).forEach((timezone) => {
|
window.timezones.forEach((timezone) => {
|
||||||
let opt = document.createElement('option');
|
let opt = document.createElement('option');
|
||||||
opt.value = timezone;
|
opt.value = timezone;
|
||||||
if (timezone == moment.tz.guess()) {
|
if (timezone == local_timezone) {
|
||||||
opt.selected = true;
|
opt.selected = true;
|
||||||
}
|
}
|
||||||
opt.innerHTML = window.timezones[timezone]
|
opt.innerHTML = timezone;
|
||||||
timezones_element.appendChild(opt)
|
timezones_element.appendChild(opt);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +109,7 @@ function get_timeslot_div_layout(timeslot) {
|
|||||||
timeslot_div.classList.add('unavailable')
|
timeslot_div.classList.add('unavailable')
|
||||||
}
|
}
|
||||||
timeslot_div.innerHTML = get_slot_layout(start_time);
|
timeslot_div.innerHTML = get_slot_layout(start_time);
|
||||||
timeslot_div.id = timeslot.time.substr(11, 20);
|
timeslot_div.id = timeslot.time.substring(11, 19);
|
||||||
timeslot_div.addEventListener('click', select_time);
|
timeslot_div.addEventListener('click', select_time);
|
||||||
return timeslot_div
|
return timeslot_div
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,18 +25,8 @@ def get_appointment_settings():
|
|||||||
|
|
||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def get_timezones():
|
def get_timezones():
|
||||||
from babel.dates import get_timezone, get_timezone_name, Locale
|
import pytz
|
||||||
from frappe.utils.momentjs import get_all_timezones
|
return pytz.all_timezones
|
||||||
|
|
||||||
translated_dict = {}
|
|
||||||
locale = Locale.parse(frappe.local.lang, sep="-")
|
|
||||||
|
|
||||||
for tz in get_all_timezones():
|
|
||||||
timezone_name = get_timezone_name(get_timezone(tz), locale=locale, width='short')
|
|
||||||
if timezone_name:
|
|
||||||
translated_dict[tz] = timezone_name + ' - ' + tz
|
|
||||||
|
|
||||||
return translated_dict
|
|
||||||
|
|
||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def get_appointment_slots(date, timezone):
|
def get_appointment_slots(date, timezone):
|
||||||
@@ -90,7 +80,7 @@ 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%z'
|
format_string = '%Y-%m-%d %H:%M:%S'
|
||||||
scheduled_time = datetime.datetime.strptime(date + " " + time, format_string)
|
scheduled_time = datetime.datetime.strptime(date + " " + time, format_string)
|
||||||
# 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 = scheduled_time.replace(tzinfo = None)
|
scheduled_time = scheduled_time.replace(tzinfo = None)
|
||||||
|
|||||||
Reference in New Issue
Block a user