def get(self):
        session_id = self.request.get('session_id')
        session = Session.query_by_id(int(session_id))
        stream = Stream.query_by_name(session.exercises[session.currWO])
        #use stream[0] for first element in list

        if session.step >= stream[0].totalSteps:
            lastStep = True
            step_ = stream[0].totalSteps
        else:
            lastStep = False
            step_ = session.step

        if session.currWO >= (session.totalWOs - 1): # subtract 1 because exerciseList starts at element 0
            lastWO = True
            print "This is the last workout. currWO = %d, totalWOs = %d" % (session.currWO, session.totalWOs)
        else:
            lastWO = False
            print "This is NOT the last workout. currWO = %d, totalWOs = %d" % (session.currWO, session.totalWOs)

        myDict = {"session_id": session_id,
                  "photo": stream[0].woPics[unicode(step_)], #get the first pic
                  "instructions": stream[0].woInstructions[unicode(step_)],
                  "name": stream[0].name,
                  "lastStep": lastStep,
                  "lastWO": lastWO}
        self.response.write(json.dumps(myDict))
    def get(self):
        session_id = self.request.get('session_id')
        session = Session.query_by_id(int(session_id))
        stream = Stream.query_by_name(session.exercises[session.currWO])
        #use stream[0] for first element in list

        if session.step >= stream[0].totalSteps:
            lastStep = True
            step_ = stream[0].totalSteps
        else:
            lastStep = False
            step_ = session.step

        if session.currWO >= (
                session.totalWOs -
                1):  # subtract 1 because exerciseList starts at element 0
            lastWO = True
            print "This is the last workout. currWO = %d, totalWOs = %d" % (
                session.currWO, session.totalWOs)
        else:
            lastWO = False
            print "This is NOT the last workout. currWO = %d, totalWOs = %d" % (
                session.currWO, session.totalWOs)

        myDict = {
            "session_id": session_id,
            "photo": stream[0].woPics[unicode(step_)],  #get the first pic
            "instructions": stream[0].woInstructions[unicode(step_)],
            "name": stream[0].name,
            "lastStep": lastStep,
            "lastWO": lastWO
        }
        self.response.write(json.dumps(myDict))
    def post(self):
        session_id = self.request.get('session_id')
        incStep = self.request.get('incStep')
        incWO = self.request.get('incWO')
        session = Session.query_by_id(int(session_id))
        print "post ActivateSession"
        session.active = True

        if (int(incStep) == 1) and (int(incWO) == 0):
            session.step +=1
            print "incrementing steps"

        if(int(incStep) == -1 and (session.step > 1)):
            session.step -=1
            print "incrementing steps"
        elif(int(incStep) == -1 and (session.step == 1) and (session.currWO > 0)):
            session.currWO -= 1
            session.step = 3
            print "decrementing WO and setting steps to 3"

        if ((int(incWO) == 1)):
            if (session.currWO + 1) <= session.totalWOs:
                session.step = 1 #start at step 1 for next workout
                session.currWO +=1
                print "incrementing WORKOUT and resetting steps"

        if(int(incWO) == -1): #reset
                session.step = 1 #start at step 1 for next workout
                session.currWO = 0 #start at first WO
        session.put()
    def post(self):
        session_id = self.request.get('session_id')
        incStep = self.request.get('incStep')
        incWO = self.request.get('incWO')
        session = Session.query_by_id(int(session_id))
        print "post ActivateSession"
        session.active = True

        if (int(incStep) == 1) and (int(incWO) == 0):
            session.step += 1
            print "incrementing steps"

        if (int(incStep) == -1 and (session.step > 1)):
            session.step -= 1
            print "incrementing steps"
        elif (int(incStep) == -1 and (session.step == 1)
              and (session.currWO > 0)):
            session.currWO -= 1
            session.step = 3
            print "decrementing WO and setting steps to 3"

        if ((int(incWO) == 1)):
            if (session.currWO + 1) <= session.totalWOs:
                session.step = 1  #start at step 1 for next workout
                session.currWO += 1
                print "incrementing WORKOUT and resetting steps"

        if (int(incWO) == -1):  #reset
            session.step = 1  #start at step 1 for next workout
            session.currWO = 0  #start at first WO
        session.put()
Beispiel #5
0
    def get(self):
        email = self.request.get('email')
        workoutLogs = WorkoutLogs.query_by_id(email)
        exerciseDict = {}
        repsDict = {}
        dateDict = {}
        categoryDict = {}
        cntr = 0
        if workoutLogs != None:
            tempList = list(workoutLogs.WoHistory)
            tempList.reverse()
            if len(tempList) > 5:
                tempList2 = list(tempList[:5])
            else:
                tempList2 = list(tempList)

            for hist in tempList2: # get list of workouts
                print "found workout history"
                session = Session.query_by_id(hist) #hist is session_id
                exerciseDict[cntr] = session.exercises
                repsDict[cntr] = session.reps
                p = re.compile(r'.*:.*:..')
                m = p.search(str(session.started))
                dateDict[cntr] = m.group(0)
                categoryDict[cntr] = session.category
                cntr += 1

        self.response.write(json.dumps({"exercises": exerciseDict, "reps": repsDict,
                                        "category": categoryDict, "date": dateDict}))
    def get(self):
        email = self.request.get("email")
        workoutLogs = WorkoutLogs.query_by_id(email)
        exerciseDict = {}
        repsDict = {}
        dateDict = {}
        categoryDict = {}
        cntr = 0
        if workoutLogs != None:
            tempList = list(workoutLogs.WoHistory)
            tempList.reverse()
            if len(tempList) > 5:
                tempList2 = list(tempList[:5])
            else:
                tempList2 = list(tempList)

            for hist in tempList2:  # get list of workouts
                print "found workout history"
                session = Session.query_by_id(hist)  # hist is session_id
                exerciseDict[cntr] = session.exercises
                repsDict[cntr] = session.reps
                p = re.compile(r".*:.*:..")
                m = p.search(str(session.started))
                dateDict[cntr] = m.group(0)
                categoryDict[cntr] = session.category
                cntr += 1

        self.response.write(
            json.dumps({"exercises": exerciseDict, "reps": repsDict, "category": categoryDict, "date": dateDict})
        )
Beispiel #7
0
    def post(self):
        email = self.request.get('email')
        session_id = int(self.request.get('session_id'))
        session = Session.query_by_id(session_id)
        session.completed=True
        workoutLogs = WorkoutLogs.query_by_id(email)

        print workoutLogs
        if workoutLogs == None:
            print "creating log"
            workoutLogs = WorkoutLogs(id=email)
            workoutLogs.WoHistory.append(session_id)
        else:
            workoutLogs.WoHistory.append(session_id)

        workoutLogs.put()
        session.put()
    def post(self):
        email = self.request.get("email")
        session_id = int(self.request.get("session_id"))
        session = Session.query_by_id(session_id)
        session.completed = True
        workoutLogs = WorkoutLogs.query_by_id(email)

        print workoutLogs
        if workoutLogs == None:
            print "creating log"
            workoutLogs = WorkoutLogs(id=email)
            workoutLogs.WoHistory.append(session_id)
        else:
            workoutLogs.WoHistory.append(session_id)

        workoutLogs.put()
        session.put()