generated from mwc/project_banjo_app
Worked on views and models
This commit is contained in:
40
workouts/app/models.py
Normal file
40
workouts/app/models.py
Normal file
@@ -0,0 +1,40 @@
|
||||
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):
|
||||
name = self.name
|
||||
musclegroup = self.musclegroup
|
||||
instr = self.instructions()
|
||||
return name+": This is a(n) "+musclegroup+" exercise. Instructions: "+instr
|
||||
|
||||
|
||||
Reference in New Issue
Block a user