Worked on views and models

This commit is contained in:
zoeyande2
2026-03-08 21:10:55 -04:00
parent f91987da30
commit 9927473dad
8 changed files with 181 additions and 1 deletions

40
workouts/app/models.py Normal file
View 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