From d3605d235400813ae62ef2b346f8e83bcbf7445f Mon Sep 17 00:00:00 2001 From: 0Pranav Date: Wed, 11 Dec 2019 15:02:23 +0530 Subject: [PATCH 1/4] fix: issue in javascript timezones --- erpnext/www/book_appointment/index.js | 2 +- erpnext/www/book_appointment/index.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/www/book_appointment/index.js b/erpnext/www/book_appointment/index.js index c8dd5013d5..5a814c6381 100644 --- a/erpnext/www/book_appointment/index.js +++ b/erpnext/www/book_appointment/index.js @@ -114,7 +114,7 @@ function get_timeslot_div_layout(timeslot) { timeslot_div.classList.add('unavailable') } 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); return timeslot_div } diff --git a/erpnext/www/book_appointment/index.py b/erpnext/www/book_appointment/index.py index 5b60dd5e7b..e4af7e8e43 100644 --- a/erpnext/www/book_appointment/index.py +++ b/erpnext/www/book_appointment/index.py @@ -90,7 +90,7 @@ def get_available_slots_between(query_start_time, query_end_time, settings): @frappe.whitelist(allow_guest=True) 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) # Strip tzinfo from datetime objects since it's handled by the doctype scheduled_time = scheduled_time.replace(tzinfo = None) From 84ae2cc5431972e0eb6483ccddd34f32950f5bc2 Mon Sep 17 00:00:00 2001 From: 0Pranav Date: Wed, 18 Dec 2019 15:44:04 +0530 Subject: [PATCH 2/4] fix: defualt timezone not getting selected --- erpnext/www/book_appointment/index.js | 13 ++++--------- erpnext/www/book_appointment/index.py | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/erpnext/www/book_appointment/index.js b/erpnext/www/book_appointment/index.js index 5a814c6381..262e31b3e4 100644 --- a/erpnext/www/book_appointment/index.js +++ b/erpnext/www/book_appointment/index.js @@ -24,20 +24,15 @@ async function get_global_variables() { } 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 offset = new Date().getTimezoneOffset(); - Object.keys(window.timezones).forEach((timezone) => { + let local_timezone = moment.tz.guess() + window.timezones.forEach(timezone => { let opt = document.createElement('option'); opt.value = timezone; - if (timezone == moment.tz.guess()) { + if (timezone == local_timezone) { opt.selected = true; } - opt.innerHTML = window.timezones[timezone] + opt.innerHTML = timezone; timezones_element.appendChild(opt) }); } diff --git a/erpnext/www/book_appointment/index.py b/erpnext/www/book_appointment/index.py index e4af7e8e43..fe98c7a0e9 100644 --- a/erpnext/www/book_appointment/index.py +++ b/erpnext/www/book_appointment/index.py @@ -25,18 +25,20 @@ def get_appointment_settings(): @frappe.whitelist(allow_guest=True) def get_timezones(): - from babel.dates import get_timezone, get_timezone_name, Locale - from frappe.utils.momentjs import get_all_timezones + import pytz + return pytz.all_timezones + # from babel.dates import get_timezone, get_timezone_name, Locale + # from frappe.utils.momentjs import get_all_timezones - translated_dict = {} - locale = Locale.parse(frappe.local.lang, sep="-") + # 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 + # 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 + # return translated_dict @frappe.whitelist(allow_guest=True) def get_appointment_slots(date, timezone): From 5f5c725ef99153b8489c6755cac84515aed66c16 Mon Sep 17 00:00:00 2001 From: 0Pranav Date: Wed, 18 Dec 2019 16:21:50 +0530 Subject: [PATCH 3/4] add book appointment to the sidebar --- erpnext/hooks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 2a5e6d8f49..c99ae7da5e 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -180,6 +180,7 @@ standard_portal_menu_items = [ {"title": _("Admission"), "route": "/admissions", "reference_doctype": "Student Admission", "role": "Student"}, {"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": _("Appointment Booking"), "route": "/book_appointment"}, ] default_roles = [ From e786eea7dbcf78c272ca8d90440d0afc783faf2e Mon Sep 17 00:00:00 2001 From: 0Pranav Date: Wed, 18 Dec 2019 16:25:26 +0530 Subject: [PATCH 4/4] remove comments --- erpnext/www/book_appointment/index.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/erpnext/www/book_appointment/index.py b/erpnext/www/book_appointment/index.py index fe98c7a0e9..7bfac89f30 100644 --- a/erpnext/www/book_appointment/index.py +++ b/erpnext/www/book_appointment/index.py @@ -27,18 +27,6 @@ def get_appointment_settings(): def get_timezones(): import pytz return pytz.all_timezones - # from babel.dates import get_timezone, get_timezone_name, Locale - # from frappe.utils.momentjs import get_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) def get_appointment_slots(date, timezone):