Esempio n. 1
0
    def get(self):
        PushList = []
        PullList = []

        parameter = self.request.get('category')
        if int(parameter) == 0:
            category = 'Upper Body Push/Lower Body Pull'
            PushQuery = Stream.query(Stream.woType == '0')  #upper push
            PullQuery = Stream.query(Stream.woType == '3')  #lower pull
        else:
            category = 'Upper Body Pull/Lower Body Push'
            PullQuery = Stream.query(Stream.woType == '1')  #upper pull
            PushQuery = Stream.query(Stream.woType == '2')  # lower push

        for x in PushQuery:
            PushList.append(x.name)

        for x in PullQuery:
            PullList.append(x.name)

        exerciseList = []
        exerciseList.append(random.choice(PushList))
        exerciseList.append(random.choice(PullList))
        reps = random.choice(['5 sets of 5', '4 sets of 10', '4 sets of 15'])
        totalWOs = len(exerciseList)

        session = Session(category=category,
                          exercises=exerciseList,
                          reps=reps,
                          currWO=0,
                          step=1,
                          active=False,
                          totalWOs=totalWOs,
                          completed=False)

        key = session.put()
        session_id = key.id()
        workouts = {
            'reps': reps,
            'exercises': exerciseList,
            'category': category,
            'totalWOs': totalWOs,
            'session_id': session_id
        }
        print json.dumps(workouts)
        self.response.write(json.dumps(workouts))
Esempio n. 2
0
    def get(self):
        PhotoDistances = []
        streams = Stream.query()
        for stream in streams:
            for photo in stream.photos:
                p = Photo.query_by_id(photo)
                PhotoDistances.append({"lat":p.Latitude, "lng": p.Longitude, "stream_id":p.stream_id,
                                       "photo_id": photo, "stream_name": stream.name})

        self.response.write(json.dumps({"Distances": PhotoDistances}))
Esempio n. 3
0
    def get(self):
        PushList = []
        PullList = []

        parameter = self.request.get('category')
        if int(parameter) == 0:
            category = 'Upper Body Push/Lower Body Pull'
            PushQuery = Stream.query(Stream.woType == '0') #upper push
            PullQuery = Stream.query(Stream.woType == '3') #lower pull
        else:
            category = 'Upper Body Pull/Lower Body Push'
            PullQuery = Stream.query(Stream.woType == '1') #upper pull
            PushQuery = Stream.query(Stream.woType == '2') # lower push

        for x in PushQuery:
            PushList.append(x.name)

        for x in PullQuery:
            PullList.append(x.name)

        exerciseList = []
        exerciseList.append(random.choice(PushList))
        exerciseList.append(random.choice(PullList))
        reps = random.choice(['5 sets of 5','4 sets of 10','4 sets of 15'])
        totalWOs = len(exerciseList)

        session = Session(category=category, exercises=exerciseList,reps=reps,currWO=0,
                          step=1,active=False,totalWOs=totalWOs,completed=False)

        key = session.put()
        session_id=key.id()
        workouts = {'reps': reps,
                    'exercises': exerciseList,
                    'category': category,
                    'totalWOs': totalWOs,
                    'session_id': session_id
                    }
        print json.dumps(workouts)
        self.response.write(json.dumps(workouts))
Esempio n. 4
0
    def get(self):
        term = self.request.get('term')
        streams = Stream.query()
        all_strings = []

        for stream in streams:
            name = stream.name.lower();
            user = stream.email.lower();
            if (term.lower() in name):
                all_strings.append(stream.name)
            if(term.lower() in user and user not in all_strings):
                all_strings.append(stream.email)
            for tag in stream.tags:
                if (term.lower() in tag.lower()) and (tag.lower() not in all_strings):
                    all_strings.append(tag)

            all_strings.sort()
        self.response.write(json.dumps(all_strings))
    def get(self):
        user_id = self.request.get('user_id')
        streams = Stream.query()
        sub_stream = Subscribe.query_by_user(user_id)
        sub_stream_ids = [obj.stream for obj in sub_stream.iter()] #list of stream IDs

        #iterate through streams and get last image
        recentImages = []
        streamName = []
        streamIDs = []
        for stream_id in sub_stream_ids:
            stream = Stream.query_by_id(int(stream_id))
            if len(stream.photos) != 0:
                recentImages.append(stream.photos[-1])
                streamName.append(stream.name)
                streamIDs.append(stream_id)

        self.response.write(json.dumps({"recentImages": recentImages, "streamName": streamName,
                                        "id": streamIDs}))
Esempio n. 6
0
    def get(self):
        term = self.request.get('term')
        streams = Stream.query()
        all_strings = []

        for stream in streams:
            name = stream.name.lower()
            user = stream.email.lower()
            if (term.lower() in name):
                all_strings.append(stream.name)
            if (term.lower() in user and user not in all_strings):
                all_strings.append(stream.email)
            for tag in stream.tags:
                if (term.lower() in tag.lower()) and (tag.lower()
                                                      not in all_strings):
                    all_strings.append(tag)

            all_strings.sort()
        self.response.write(json.dumps(all_strings))
Esempio n. 7
0
    def get(self):
        user_id = self.request.get('user_id')
        streams = Stream.query()
        sub_stream = Subscribe.query_by_user(user_id)
        sub_stream_ids = [obj.stream
                          for obj in sub_stream.iter()]  #list of stream IDs

        #iterate through streams and get last image
        recentImages = []
        streamName = []
        streamIDs = []
        for stream_id in sub_stream_ids:
            stream = Stream.query_by_id(int(stream_id))
            if len(stream.photos) != 0:
                recentImages.append(stream.photos[-1])
                streamName.append(stream.name)
                streamIDs.append(stream_id)

        self.response.write(
            json.dumps({
                "recentImages": recentImages,
                "streamName": streamName,
                "id": streamIDs
            }))
Esempio n. 8
0
 def get(self):
     streams = Stream.query()
     all_streams = []
     for s in streams:
         all_streams.append({'name':s.name, 'cover':s.cover, 'id':s.key.id(), 'views':s.views})
     self.response.write(json.dumps({"allstreams": all_streams}))
Esempio n. 9
0
 def get(self):
     #stream_id, st, ed
     stream = Stream.query().order(-Stream.views)
     r = [{'name': p.name, 'cover': p.cover, 'view': p.views} for p in stream]
     self.response.write(json.dumps(r))