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 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 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))
Esempio n. 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}))
Esempio n. 6
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})
        )
Esempio n. 7
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. 8
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. 9
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()
Esempio n. 10
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()
Esempio n. 11
0
 def createDomain(username):
     session = Session()
     session.id = SessionUtility.getToken()
     session.username = username
     session.lastUsed = Date.toString(Date.now())
     return session