generated from mwc/project_banjo_app
Finished implementing views, updated models
This commit is contained in:
@@ -4,7 +4,11 @@ from app.models import Exercise
|
||||
from random import choice, sample
|
||||
from app.exlist import init_starting_exs
|
||||
|
||||
init_starting_exs()
|
||||
#Done
|
||||
@route_get("populate_workouts", args ={})
|
||||
def populate_workouts(params):
|
||||
init_starting_exs()
|
||||
return "Workouts populated."
|
||||
|
||||
#Done
|
||||
@route_get("all", args = {})
|
||||
@@ -31,13 +35,28 @@ def workout_with_length(params):
|
||||
else:
|
||||
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
|
||||
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)
|
||||
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
|
||||
@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