Example #1
0
    def get(self, club_id):
        bot = auth_util.get_bot(flask.request)

        service = Service.get('strava', parent=bot.key)
        club = StravaClubWorker(club_id, service).sync_club()

        return WrapEntity(club)
Example #2
0
    def get(self):
        bot = auth_util.get_bot(flask.request)

        service = Service.get('strava', parent=bot.key)
        club_query = ds_util.client.query(kind='Club', ancestor=service.key)

        return [WrapEntity(club) for club in club_query.fetch()]
Example #3
0
 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
Example #4
0
 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)
Example #5
0
 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)]
Example #6
0
 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
Example #7
0
    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)
Example #8
0
    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]
Example #9
0
    def get(self):
        bot = auth_util.get_bot(flask.request)

        user_entities = [bot]
        user_entities += ds_util.client.query(kind='User').fetch()
        users = []
        for user_entity in user_entities:
            users.append({
                'user':
                WrapEntity(user_entity),
                'google':
                Service.get('google', parent=user_entity.key),
                'strava':
                Service.get('strava', parent=user_entity.key),
                'withings':
                Service.get('withings', parent=user_entity.key),
                'fitbit':
                Service.get('fitbit', parent=user_entity.key),
            })

        return users
Example #10
0
 def get(self, client_id):
     user = auth_util.get_user(flask.request)
     return WrapEntity(ClientState.get(client_id, parent=user.key))
Example #11
0
 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()]
Example #12
0
 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)
Example #13
0
 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)
Example #14
0
 def get(self, name):
     user = auth_util.get_user(flask.request)
     service = Service.get(name, parent=user.key)
     return WrapEntity(service)
Example #15
0
    def get(self, name):
        bot = auth_util.get_bot(flask.request)

        service = Service.get(name, parent=bot.key)
        return WrapEntity(service)