Files
project_banjo_app/workouts/app/models.py
2026-03-08 21:10:55 -04:00

41 lines
1.4 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):
name = self.name
musclegroup = self.musclegroup
instr = self.instructions()
return name+": This is a(n) "+musclegroup+" exercise. Instructions: "+instr