generated from mwc/project_banjo_app
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
from banjo.models import Model, StringField, IntegerField, FloatField, ForeignKey
|
|
from banjo.http import BadRequest
|
|
|
|
class Exercise(Model):
|
|
name = StringField()
|
|
musclegroup = StringField()
|
|
weight = IntegerField()
|
|
reps = IntegerField()
|
|
sets = IntegerField()
|
|
timemins = FloatField()
|
|
distance = FloatField()
|
|
|
|
|
|
def instructions(self):
|
|
instr = ''
|
|
if self.musclegroup == "Cardio":
|
|
timemins = str(self.timemins)
|
|
distance = str(self.distance)
|
|
instr = "Do exercise for "+timemins+" minute(s) or until "+distance+" mile(s) has been completed."
|
|
else:
|
|
weight = str(self.weight)
|
|
reps = str(self.reps)
|
|
sets = str(self.sets)
|
|
if self.weight == 0:
|
|
instr = "Do exercise with bodyweight for "+reps+" rep(s). Repeat for "+sets+" set(s)"
|
|
else:
|
|
instr = "Do exercise with "+weight+" lb(s) for "+reps+" rep(s). Repeat for "+sets+" set(s)"
|
|
if self.timemins != 0:
|
|
timemins = str(self.timemins)
|
|
instr += " or for "+timemins+" minute(s)"
|
|
instr += "."
|
|
return instr
|
|
|
|
def __repr__(self):
|
|
rep = self.to_dict()
|
|
rep["instructions"] = self.instructions()
|
|
return rep
|
|
|
|
|