summaryrefslogtreecommitdiff
path: root/addons/google_calendar/utils
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2020-03-25 14:21:50 +0100
committerLucas Lefèvre <lul@odoo.com>2020-04-09 10:59:34 +0200
commit1a9be3a8699df6422b4e1fe2d91cbbec48fae9de (patch)
treee703f821c33fd33473e65f7c61640f4e2acf52e0 /addons/google_calendar/utils
parentf2b69186499f7288af6d129986ad3d9d92b010c6 (diff)
[REF] calendar: Lint + Clean code
Diffstat (limited to 'addons/google_calendar/utils')
-rw-r--r--addons/google_calendar/utils/google_calendar.py20
-rw-r--r--addons/google_calendar/utils/google_event.py4
2 files changed, 7 insertions, 17 deletions
diff --git a/addons/google_calendar/utils/google_calendar.py b/addons/google_calendar/utils/google_calendar.py
index 4532ce1b708..20032241362 100644
--- a/addons/google_calendar/utils/google_calendar.py
+++ b/addons/google_calendar/utils/google_calendar.py
@@ -37,25 +37,20 @@ class GoogleCalendarService():
if sync_token:
params['syncToken'] = sync_token
try:
- status, data, time = self.google_service._do_request(url, params, headers, type='GET', timeout=timeout)
+ status, data, time = self.google_service._do_request(url, params, headers, method='GET', timeout=timeout)
except requests.HTTPError as e:
if e.response.status_code == 410 and 'fullSyncRequired' in str(e.response.content):
raise InvalidSyncToken("Invalid sync token. Full sync required")
raise e
- import pprint
- pprint.pprint(data)
-
events = data.get('items', [])
next_page_token = data.get('nextPageToken')
while next_page_token:
params = {'access_token': token, 'pageToken': next_page_token}
- status, data, time = self.google_service._do_request(url, params, headers, type='GET', timeout=timeout)
+ status, data, time = self.google_service._do_request(url, params, headers, method='GET', timeout=timeout)
next_page_token = data.get('nextPageToken')
events += data.get('items', [])
- pprint.pprint(data)
-
next_sync_token = data.get('nextSyncToken')
default_reminders = data.get('defaultReminders')
@@ -63,31 +58,26 @@ class GoogleCalendarService():
@requires_auth_token
def insert(self, values, token=None, timeout=TIMEOUT):
- print("INSERT")
url = "/calendar/v3/calendars/primary/events"
headers = {'Content-type': 'application/json', 'Authorization': 'Bearer %s' % token}
if not values.get('id'):
values['id'] = uuid4().hex
- import pprint
- pprint.pprint(values)
- self.google_service._do_request(url, json.dumps(values), headers, type='POST', timeout=timeout)
+ self.google_service._do_request(url, json.dumps(values), headers, method='POST', timeout=timeout)
return values['id']
@requires_auth_token
def patch(self, event_id, values, token=None, timeout=TIMEOUT):
- print("PATCH")
url = "/calendar/v3/calendars/primary/events/%s" % event_id
headers = {'Content-type': 'application/json', 'Authorization': 'Bearer %s' % token}
- self.google_service._do_request(url, json.dumps(values), headers, type='PUT', timeout=timeout)
+ self.google_service._do_request(url, json.dumps(values), headers, method='PUT', timeout=timeout)
@requires_auth_token
def delete(self, event_id, token=None, timeout=TIMEOUT):
- print("DELETE")
url = "/calendar/v3/calendars/primary/events/%s" % event_id
headers = {'Content-type': 'application/json'}
params = {'access_token': token}
try:
- self.google_service._do_request(url, params, headers=headers, type='DELETE', timeout=timeout)
+ self.google_service._do_request(url, params, headers=headers, method='DELETE', timeout=timeout)
except requests.HTTPError as e:
# For some unknown reason Google can also return a 403 response when the event is already cancelled.
if e.response.status_code not in (410, 403):
diff --git a/addons/google_calendar/utils/google_event.py b/addons/google_calendar/utils/google_event.py
index a1274049224..fc962a1d073 100644
--- a/addons/google_calendar/utils/google_event.py
+++ b/addons/google_calendar/utils/google_event.py
@@ -169,6 +169,6 @@ class GoogleEvent(abc.Set):
def _get_model(self, env):
if all([e.is_recurrence() for e in self]):
return env['calendar.recurrence']
- elif all([not e.is_recurrence() for e in self]):
+ if all([not e.is_recurrence() for e in self]):
return env['calendar.event']
- raise TypeError("Mixing Google events and Google recurrences") \ No newline at end of file
+ raise TypeError("Mixing Google events and Google recurrences")