def get(self, club_id): club_id = int(club_id) auth_util.get_user(flask.request) bot_strava = Service.get('strava', parent=Bot.key()) club = Club.get(club_id, parent=bot_strava.key) # Find the user's club reference. if club is None: flask.abort(404) return WrapEntity(club)
def get(self, club_id): club_id = int(club_id) auth_util.get_user(flask.request) bot_strava = Service.get('strava', parent=Bot.key()) club = Club.get(club_id, parent=bot_strava.key) # Find the user's club reference. if club is None: flask.abort(404) activities_query = ds_util.client.query(kind='Activity', ancestor=club.key) all_activities = [a for a in activities_query.fetch()] return [WrapEntity(a) for a in all_activities]
def post(self, name): user = auth_util.get_user(flask.request) connect_userpass = api.payload service = Service.get(name, parent=user.key) Service.update_credentials_userpass(service, connect_userpass) ds_util.client.put(service) return WrapEntity(service)
def post(self, name): user = auth_util.get_user(flask.request) new_service = api.payload existing_service = Service.get(name, parent=user.key) existing_service.update(new_service) ds_util.client.put(existing_service) return WrapEntity(existing_service)
def get(self): user = auth_util.get_user(flask.request) service = Service.get('strava', parent=user.key) segments_query = ds_util.client.query( kind='Segment', ancestor=service.key, order=['-id'] ) segments = [WrapEntity(a) for a in segments_query.fetch()] return segments
def post(self): user = auth_util.get_user(flask.request) new_client = api.payload existing_client = ClientState.get(new_client['token'], parent=user.key) existing_client.update(new_client) existing_client['modified'] = datetime.datetime.now(datetime.timezone.utc) ds_util.client.put(existing_client) return WrapEntity(existing_client)
def post(self): user = auth_util.get_user(flask.request) measure = api.payload # In a world with useful documentation, i'd know why the date value # isn't being converted to a date time, even though the model says it # is. So, convert it. measure['date'] = datetime.datetime.fromisoformat(measure['date']) task_util.xsync_tasks_measure(user.key, measure) return measure
def post(self): user = auth_util.get_user(flask.request) backfill = api.payload source = Service.get(backfill['source'], parent=user.key) dest = Service.get(backfill['dest'], parent=user.key) start = datetime.datetime.fromisoformat(backfill.get('start')) end = datetime.datetime.fromisoformat(backfill.get('end')) task_util.xsync_tasks_backfill(source.key, dest.key, start, end) # TODO: pre-check there are credentials. return backfill
def get(self): user = auth_util.get_user(flask.request) service = Service.get('strava', parent=user.key) activities_query = ds_util.client.query( kind='Activity', ancestor=service.key, order=['-start_date'] ) one_year_ago = datetime.datetime.now( datetime.timezone.utc ) - datetime.timedelta(days=365) activities_query.add_filter('start_date', '>', one_year_ago) return [WrapEntity(a) for a in activities_query.fetch(limit=20)]
def get(self): user = auth_util.get_user(flask.request) strava = Service.get('strava', parent=user.key) strava_connected = Service.has_credentials(strava) athlete = Athlete.get_private(strava.key) return dict( user=WrapEntity(user), athlete=WrapEntity(athlete), signup_complete=strava_connected, )
def get(self): user = auth_util.get_user(flask.request) service = Service.get('strava', parent=user.key) segments_arg = get_arg('segments') segments = [] for segment_id in segments_arg: entity = ds_util.client.get( ds_util.client.key('Segment', segment_id, parent=service.key) ) segments.append(WrapEntity(entity)) return segments
def get(self): user = auth_util.get_user(flask.request) service_name = user['preferences']['weight_service'].lower() series = Series.get( ds_util.client.key('Service', service_name, parent=user.key) ) if series is None: return WrapEntity(None) filter_arg = get_arg('filter') if filter_arg: series['measures'] = [m for m in series['measures'] if filter_arg in m] return WrapEntity(series)
def get(self, client_id): user = auth_util.get_user(flask.request) return WrapEntity(ClientState.get(client_id, parent=user.key))
def get(self): user = auth_util.get_user(flask.request) clients_query = ds_util.client.query( kind='ClientState', ancestor=user.key, order=['-modified'] ) return [WrapEntity(c) for c in clients_query.fetch()]
def post(self, name): user = auth_util.get_user(flask.request) force = api.payload.get('force', False) service = Service.get(name, parent=user.key) task_util.sync_service(service, force=force) return WrapEntity(service)
def post(self, name): user = auth_util.get_user(flask.request) service = Service.get(name, parent=user.key) Service.clear_credentials(service) ds_util.client.put(service) return WrapEntity(service)
def post(self): user = auth_util.get_user(flask.request) user['preferences'].update(api.payload) ds_util.client.put(user) return user['preferences']
def get(self, name): user = auth_util.get_user(flask.request) service = Service.get(name, parent=user.key) return WrapEntity(service)