diff --git a/Routine.py b/Routine.py index a5ec40f..7e3a718 100644 --- a/Routine.py +++ b/Routine.py @@ -12,13 +12,11 @@ class Routine: self.updateCalendars() - def updateCalendars(self): - users = User.query.all() - for user in users: + def updateCalendar(self, user): # check google: credentials = user.getGoogleCredentials() if credentials is None: - continue + return visualCals = [] calendars = db.session.query(Calendar).filter(Calendar.usr_id==user.id).all() @@ -28,11 +26,19 @@ class Routine: googleCreds = google.oauth2.credentials.Credentials(**credentials) calendarjson = caltojson.generateJsonFromCalendarEntries(visualCals, googleCreds) user.setJson(calendarjson) + ''' directory = 'userinfo/' + user.id + '/' if not os.path.exists(directory): os.makedirs(directory) with open(directory + 'calendarevents.json', 'w', encoding='utf-8') as f: json.dump(calendarjson, f, ensure_ascii=False, indent=4) + ''' + + + def updateCalendars(self): + users = User.query.all() + for user in users: + self.updateCalendar(user) def credentials_to_dict(credentials): return{'token': credentials.token,