init commit

init commit
This commit is contained in:
Trey t
2023-06-11 20:09:22 -05:00
commit a2fd663255
946 changed files with 38811 additions and 0 deletions

64
workout/models.py Normal file
View File

@@ -0,0 +1,64 @@
from django.db import models
from exercise.models import *
from registered_user.models import RegisteredUser
WORKOUT_LEVEL = (
(1, "easy"),
(2, "moderate"),
(3, "average"),
(4, "hard"),
(5, "death"),
)
# Create your models here.
class Workout(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
name = models.CharField(null=True, blank=True, max_length=255)
description = models.CharField(null=True, blank=True, max_length=255)
user = models.ForeignKey(
RegisteredUser,
on_delete=models.CASCADE
)
def __str__(self):
return self.name + " : " + self.description + " | by: " + self.user.nick_name
class WorkoutExercise(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
workout = models.ForeignKey(
Workout,
on_delete=models.CASCADE,
related_name='workout_exercise_workout'
)
exercise = models.ForeignKey(
Exercise,
on_delete=models.CASCADE,
related_name='workout_exercise_exercise'
)
weight = models.IntegerField(null=True, blank=True, max_length=4)
reps = models.IntegerField(null=True, blank=True, max_length=4)
def __str__(self):
return self.workout.name + " : " + self.exercise.name
class CompletedWorkout(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
registered_user = models.ForeignKey(
RegisteredUser,
on_delete=models.CASCADE,
related_name='completed_workout_user'
)
workout = models.ForeignKey(
Workout,
on_delete=models.CASCADE,
related_name='completed_workout_workout'
)
difficulty = models.PositiveSmallIntegerField(
choices=WORKOUT_LEVEL
)
def __str__(self):
return self.registered_user.first_name + " : " + self.registered_user.last_name + " : " + self.workout.name + " : " + str(self.difficulty)