adds calendar_type to calendar model and to calendar handling

This commit is contained in:
Raphael Maenle 2020-07-25 11:28:59 +02:00
parent 2add28fa00
commit 524d2f1e1d
3 changed files with 4 additions and 2 deletions

@ -1 +1 @@
Subproject commit 45cd71cc4bcddf23f46b1eddcffd8c7fda2b9d41
Subproject commit fec09edb888013c5cb9c062d5cdb2220bc1a217d

View File

@ -67,6 +67,7 @@ class Calendar(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), index=True, nullable=False)
calendar_id = db.Column(db.String(256), primary_key=True)
calendar_type = db.Column(db.String(32), index=True)
name = db.Column(db.String(256), index=True)
toggle = db.Column(db.String(8))
color = db.Column(db.String(16))

View File

@ -130,7 +130,7 @@ def fetchCalendarEvents(user, calendars, startDate, endDate):
all_events = []
for calendar in calendars:
if calendar.toggle == "True":
if calendar.toggle == "True" and calendar.calType == "Google":
event_result = service.events().list(calendarId=calendar.calendar_id,
timeMin=startDate,
timeMax=endDate,
@ -178,6 +178,7 @@ def fetchCalendars():
calendar_list = service.calendarList().list(pageToken=page_token).execute()
for calendar in calendar_list['items']:
calendars.append(Calendar(name=calendar['summary'],
calType="Google",
calendarId=calendar['id'],
color=calendar['colorId']))
page_token = calendar_list.get('nextPageToken')