fix: miscellaneous fixes
This commit is contained in:
parent
bd4b809a18
commit
0daf6d9683
5 changed files with 35 additions and 29 deletions
|
|
@ -17,9 +17,14 @@
|
|||
"starts_on",
|
||||
"ends_on",
|
||||
"status",
|
||||
"google_calendar",
|
||||
"all_day",
|
||||
"sync_with_google_calendar",
|
||||
"sb_00",
|
||||
"google_calendar",
|
||||
"pulled_from_google_calendar",
|
||||
"cb_00",
|
||||
"google_calendar_id",
|
||||
"google_calendar_event_id",
|
||||
"section_break_13",
|
||||
"repeat_on",
|
||||
"repeat_till",
|
||||
|
|
@ -34,12 +39,7 @@
|
|||
"section_break_8",
|
||||
"description",
|
||||
"participants",
|
||||
"event_participants",
|
||||
"sb_00",
|
||||
"google_calendar_id",
|
||||
"synced_from_google_calendar",
|
||||
"cb_00",
|
||||
"google_calendar_event_id"
|
||||
"event_participants"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
|
|
@ -222,7 +222,7 @@
|
|||
},
|
||||
{
|
||||
"collapsible": 1,
|
||||
"depends_on": "eval:doc.google_calendar",
|
||||
"depends_on": "eval:doc.sync_with_google_calendar",
|
||||
"fieldname": "sb_00",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Google Calendar"
|
||||
|
|
@ -244,13 +244,6 @@
|
|||
"label": "Google Calendar Event ID",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "synced_from_google_calendar",
|
||||
"fieldtype": "Check",
|
||||
"label": "Synced from Google Calendar",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "sync_with_google_calendar",
|
||||
|
|
@ -258,16 +251,22 @@
|
|||
"label": "Sync with Google Calendar"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.sync_with_google_calendar",
|
||||
"fieldname": "google_calendar",
|
||||
"fieldtype": "Link",
|
||||
"label": "Google Calendar",
|
||||
"options": "Google Calendar"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "pulled_from_google_calendar",
|
||||
"fieldtype": "Check",
|
||||
"label": "Pulled from Google Calendar",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-calendar",
|
||||
"idx": 1,
|
||||
"modified": "2019-08-01 13:19:05.145607",
|
||||
"modified": "2019-08-08 16:01:19.489396",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Desk",
|
||||
"name": "Event",
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ frappe.ui.form.on("Google Calendar", {
|
|||
args: {
|
||||
"g_calendar": frm.doc.name
|
||||
},
|
||||
}).then(() => {
|
||||
}).then((r) => {
|
||||
frappe.hide_progress();
|
||||
frappe.msgprint("Google Calendar Events Synced");
|
||||
frappe.msgprint(__("{0} Google Calendar Events Synced", [r.message]));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,9 @@
|
|||
"field_order": [
|
||||
"enable",
|
||||
"sb_00",
|
||||
"calendar_name",
|
||||
"user",
|
||||
"authorize_google_calendar_access",
|
||||
"cb_00",
|
||||
"calendar_name",
|
||||
"sb_01",
|
||||
"pull_from_google_calendar",
|
||||
"cb_01",
|
||||
|
|
@ -80,10 +79,6 @@
|
|||
"label": "Google Calendar ID",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "cb_00",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!doc.__islocal",
|
||||
"fieldname": "authorize_google_calendar_access",
|
||||
|
|
@ -113,7 +108,7 @@
|
|||
"label": "Push to Google Calendar"
|
||||
}
|
||||
],
|
||||
"modified": "2019-08-06 22:44:22.189224",
|
||||
"modified": "2019-08-08 15:44:15.798362",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Integrations",
|
||||
"name": "Google Calendar",
|
||||
|
|
|
|||
|
|
@ -250,9 +250,18 @@ def sync_events_from_google_calendar(g_calendar, method=None, page_length=10):
|
|||
elif event.get("status") == "cancelled":
|
||||
# If any synced Google Calendar Event is cancelled, then close the Event
|
||||
frappe.db.set_value("Event", {"google_calendar_id": account.google_calendar_id, "google_calendar_event_id": event.get("id")}, "status", "Closed")
|
||||
frappe.get_doc({
|
||||
"doctype": "Comment",
|
||||
"comment_type": "Info",
|
||||
"reference_doctype": "Event",
|
||||
"reference_name": frappe.db.get_value("Event", {"google_calendar_id": account.google_calendar_id, "google_calendar_event_id": event.get("id")}, "name"),
|
||||
"content": "Event deleted from Google Calendar.",
|
||||
}).insert(ignore_permissions=True)
|
||||
else:
|
||||
pass
|
||||
|
||||
return len(results)
|
||||
|
||||
def insert_event_to_calendar(account, event, recurrence=None):
|
||||
"""
|
||||
Inserts event in Frappe Calendar during Sync
|
||||
|
|
@ -265,7 +274,7 @@ def insert_event_to_calendar(account, event, recurrence=None):
|
|||
"google_calendar": account.name,
|
||||
"google_calendar_id": account.google_calendar_id,
|
||||
"google_calendar_event_id": event.get("id"),
|
||||
"synced_from_google_calendar": 1
|
||||
"pulled_from_google_calendar": 1
|
||||
}
|
||||
calendar_event.update(google_calendar_to_repeat_on(recurrence=recurrence, start=event.get("start"), end=event.get("end")))
|
||||
frappe.get_doc(calendar_event).insert(ignore_permissions=True)
|
||||
|
|
@ -284,7 +293,7 @@ def insert_event_in_google_calendar(doc, method=None):
|
|||
"""
|
||||
Insert Events in Google Calendar if sync_with_google_calendar is checked.
|
||||
"""
|
||||
if not frappe.db.exists("Google Calendar", {"name": doc.google_calendar}) or doc.synced_from_google_calendar \
|
||||
if not frappe.db.exists("Google Calendar", {"name": doc.google_calendar}) or doc.pulled_from_google_calendar \
|
||||
or not doc.sync_with_google_calendar:
|
||||
return
|
||||
|
||||
|
|
@ -306,6 +315,7 @@ def insert_event_in_google_calendar(doc, method=None):
|
|||
try:
|
||||
event = google_calendar.events().insert(calendarId=doc.google_calendar_id, body=event).execute()
|
||||
frappe.db.set_value("Event", doc.name, "google_calendar_event_id", event.get("id"), update_modified=False)
|
||||
frappe.msgprint(_("Event Synced with Google Calendar."))
|
||||
except HttpError as err:
|
||||
frappe.throw(_("Google Calendar - Could not insert event in Google Calendar {0}, error code {1}.").format(account.name, err.resp.status))
|
||||
|
||||
|
|
@ -338,6 +348,7 @@ def update_event_in_google_calendar(doc, method=None):
|
|||
event.update(format_date_according_to_google_calendar(doc.all_day, get_datetime(doc.starts_on), get_datetime(doc.ends_on)))
|
||||
|
||||
google_calendar.events().update(calendarId=doc.google_calendar_id, eventId=doc.google_calendar_event_id, body=event).execute()
|
||||
frappe.msgprint(_("Event Synced with Google Calendar."))
|
||||
except HttpError as err:
|
||||
frappe.throw(_("Google Calendar - Could not update Event {0} in Google Calendar, error code {1}.").format(doc.name, err.resp.status))
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ frappe.ui.form.on('Google Contacts', {
|
|||
});
|
||||
|
||||
if (frm.doc.refresh_token) {
|
||||
frm.add_custom_button(__('Sync Contacts'), function () {
|
||||
let sync_button = frm.add_custom_button(__('Sync Contacts'), function () {
|
||||
frappe.show_alert({
|
||||
indicator: 'green',
|
||||
message: __('Syncing')
|
||||
|
|
@ -26,6 +26,7 @@ frappe.ui.form.on('Google Contacts', {
|
|||
args: {
|
||||
"g_contact": frm.doc.name
|
||||
},
|
||||
btn: sync_button
|
||||
}).then((r) => {
|
||||
frappe.hide_progress();
|
||||
frappe.msgprint(r.message);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue