generated from mwc/project_banjo_app
Finished implementing views, updated models
This commit is contained in:
Binary file not shown.
@@ -32,9 +32,8 @@ class Exercise(Model):
|
|||||||
return instr
|
return instr
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
name = self.name
|
rep = self.to_dict()
|
||||||
musclegroup = self.musclegroup
|
rep["instructions"] = self.instructions()
|
||||||
instr = self.instructions()
|
return rep
|
||||||
return name+": This is a(n) "+musclegroup+" exercise. Instructions: "+instr
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,11 @@ from app.models import Exercise
|
|||||||
from random import choice, sample
|
from random import choice, sample
|
||||||
from app.exlist import init_starting_exs
|
from app.exlist import init_starting_exs
|
||||||
|
|
||||||
|
#Done
|
||||||
|
@route_get("populate_workouts", args ={})
|
||||||
|
def populate_workouts(params):
|
||||||
init_starting_exs()
|
init_starting_exs()
|
||||||
|
return "Workouts populated."
|
||||||
|
|
||||||
#Done
|
#Done
|
||||||
@route_get("all", args = {})
|
@route_get("all", args = {})
|
||||||
@@ -31,13 +35,28 @@ def workout_with_length(params):
|
|||||||
else:
|
else:
|
||||||
raise BadRequest("There are not enough exercises to pick that many.")
|
raise BadRequest("There are not enough exercises to pick that many.")
|
||||||
|
|
||||||
|
#Done
|
||||||
@route_get("full_body", args={}) #Returns one random exercise from each muscle group
|
@route_get("full_body", args={}) #Returns one random exercise from each muscle group
|
||||||
def workout_full_body(params):
|
def workout_full_body(params):
|
||||||
return "in progress"
|
all_ex = {'cardio':[],'legs':[],'arms':[],'back':[],'chest':[],"abs":[]}
|
||||||
|
for mg in all_ex.keys():
|
||||||
|
rand_ex = choice(Exercise.objects.filter(musclegroup=mg))
|
||||||
|
all_ex[mg].append(rand_ex.__repr__())
|
||||||
|
return all_ex
|
||||||
|
|
||||||
|
#Done
|
||||||
@route_post("edit_exercise", args={"name":str,"category to edit":str,"new value":int}) #Allows a change to an exercise weight, reps, sets, time, or distance (numbers)
|
@route_post("edit_exercise", args={"name":str,"category to edit":str,"new value":int}) #Allows a change to an exercise weight, reps, sets, time, or distance (numbers)
|
||||||
def edit_exercise(params):
|
def edit_exercise(params):
|
||||||
return "in progress"
|
ex_name = params["name"]
|
||||||
|
category = params["category to edit"]
|
||||||
|
new_val = params["new value"]
|
||||||
|
ex = Exercise.objects.get(name=ex_name)
|
||||||
|
ex_dict = ex.to_dict()
|
||||||
|
ex_dict[category] = new_val
|
||||||
|
edited = Exercise.from_dict(ex_dict)
|
||||||
|
ex.delete()
|
||||||
|
edited.save()
|
||||||
|
return "Updates: "+str(edited.__repr__())
|
||||||
|
|
||||||
#Done
|
#Done
|
||||||
@route_post("new_exercise",args={"name":str,"musclegroup":str,"weight":int,"reps":int,"sets":int,"timemins":int,"distance":int})
|
@route_post("new_exercise",args={"name":str,"musclegroup":str,"weight":int,"reps":int,"sets":int,"timemins":int,"distance":int})
|
||||||
|
|||||||
Reference in New Issue
Block a user