fix: change fieldtypes to password
This commit is contained in:
parent
88e85fc9fd
commit
c006312d9c
2 changed files with 16 additions and 18 deletions
|
|
@ -16,10 +16,9 @@
|
|||
"cb_01",
|
||||
"push_to_google_calendar",
|
||||
"section_break_3",
|
||||
"google_calendar_id",
|
||||
"refresh_token",
|
||||
"authorization_code",
|
||||
"column_break_6",
|
||||
"google_calendar_id",
|
||||
"next_sync_token"
|
||||
],
|
||||
"fields": [
|
||||
|
|
@ -57,21 +56,19 @@
|
|||
},
|
||||
{
|
||||
"fieldname": "refresh_token",
|
||||
"fieldtype": "Data",
|
||||
"fieldtype": "Password",
|
||||
"hidden": 1,
|
||||
"label": "Refresh Token"
|
||||
},
|
||||
{
|
||||
"fieldname": "authorization_code",
|
||||
"fieldtype": "Data",
|
||||
"fieldtype": "Password",
|
||||
"hidden": 1,
|
||||
"label": "Authorization Code"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_6",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "next_sync_token",
|
||||
"fieldtype": "Data",
|
||||
"fieldtype": "Password",
|
||||
"hidden": 1,
|
||||
"label": "Next Sync Token"
|
||||
},
|
||||
|
|
@ -113,7 +110,7 @@
|
|||
"label": "Push to Google Calendar"
|
||||
}
|
||||
],
|
||||
"modified": "2019-07-25 11:21:58.509798",
|
||||
"modified": "2019-07-29 21:06:29.674579",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Integrations",
|
||||
"name": "Google Calendar",
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ def authorize_access(g_calendar, reauthorize=None):
|
|||
else:
|
||||
try:
|
||||
data = {
|
||||
"code": google_calendar.authorization_code,
|
||||
"code": google_calendar.get_password(fieldname="authorization_code", raise_exception=False),
|
||||
"client_id": google_settings.client_id,
|
||||
"client_secret": google_settings.get_password(fieldname="client_secret", raise_exception=False),
|
||||
"redirect_uri": redirect_uri,
|
||||
|
|
@ -166,7 +166,7 @@ def get_credentials(g_calendar):
|
|||
|
||||
credentials_dict = {
|
||||
"token": account.get_access_token(),
|
||||
"refresh_token": account.refresh_token,
|
||||
"refresh_token": account.get_password(fieldname="refresh_token", raise_exception=False),
|
||||
"token_uri": "https://www.googleapis.com/oauth2/v4/token",
|
||||
"client_id": google_settings.client_id,
|
||||
"client_secret": google_settings.get_password(fieldname="client_secret", raise_exception=False),
|
||||
|
|
@ -222,18 +222,15 @@ def google_calendar_get_events(g_calendar, method=None, page_length=10):
|
|||
while True:
|
||||
try:
|
||||
# API Response listed at EOF
|
||||
sync_token = account.get_password(fieldname="next_sync_token", raise_exception=False) or None
|
||||
events = google_calendar.events().list(calendarId=account.google_calendar_id, maxResults=page_length,
|
||||
singleEvents=False, showDeleted=True, syncToken=account.next_sync_token or None).execute()
|
||||
print("try")
|
||||
print(events)
|
||||
singleEvents=False, showDeleted=True, syncToken=sync_token).execute()
|
||||
except HttpError as err:
|
||||
if err.resp.status in [404, 410]:
|
||||
events = google_calendar.events().list(calendarId=account.google_calendar_id, maxResults=page_length,
|
||||
singleEvents=False, showDeleted=True, timeMin=add_years(None, -1).strftime("%Y-%m-%dT%H:%M:%SZ")).execute()
|
||||
print("except")
|
||||
print(events)
|
||||
else:
|
||||
frappe.log_error(err.resp, "Google Calendar Events Fetch Error.")
|
||||
frappe.log_error(err, "Google Calendar - Could not fetch event from Google Calendar.")
|
||||
|
||||
for event in events.get("items"):
|
||||
results.append(event)
|
||||
|
|
@ -258,6 +255,7 @@ def google_calendar_get_events(g_calendar, method=None, page_length=10):
|
|||
"doctype": "Event",
|
||||
"subject": event.get("summary"),
|
||||
"description": event.get("description"),
|
||||
"google_calendar_event": 1,
|
||||
"google_calendar_id": account.google_calendar_id,
|
||||
"google_calendar_event_id": event.get("id"),
|
||||
}
|
||||
|
|
@ -340,6 +338,9 @@ def google_calendar_delete_events(doc, method=None):
|
|||
|
||||
google_calendar, account = get_credentials({"user": frappe.session.user})
|
||||
|
||||
if not account.push_to_google_calendar:
|
||||
return
|
||||
|
||||
try:
|
||||
google_calendar.events().delete(calendarId=account.google_calendar_id, eventId=doc.google_calendar_event_id).execute()
|
||||
except Exception as e:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue