init
This commit is contained in:
commit
66729f7d08
24 files changed
+907
No files matched your search
@@ -0,0 +1,40 @@
|
||||
# exercise_tracker/models.py
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Session(models.Model):
|
||||
name = models.CharField(max_length=100, blank=True)
|
||||
date = models.DateField()
|
||||
location = models.CharField(max_length=100, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name or 'Workout'} ({self.date})"
|
||||
|
||||
|
||||
class Exercise(models.Model):
|
||||
session = models.ForeignKey(Session, related_name='exercises', on_delete=models.CASCADE)
|
||||
name = models.CharField(max_length=255)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name} in {self.session.name or 'Workout'}"
|
||||
|
||||
|
||||
class Set(models.Model):
|
||||
exercise = models.ForeignKey(Exercise, related_name='sets', on_delete=models.CASCADE)
|
||||
|
||||
reps = models.IntegerField(null=True, blank=True)
|
||||
weight_kg = models.FloatField(null=True, blank=True)
|
||||
|
||||
distance_meters = models.FloatField(null=True, blank=True)
|
||||
duration_seconds = models.IntegerField(null=True, blank=True)
|
||||
|
||||
is_personal_record = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
if self.distance_meters is not None:
|
||||
mins = self.duration_seconds // 60 if self.duration_seconds else 0
|
||||
secs = self.duration_seconds % 60 if self.duration_seconds else 0
|
||||
return f"Cardio: {self.exercise.name} ({mins}m {secs}s, {self.distance_meters / 1000:.2f}km)"
|
||||
reps_str = self.reps or "∞"
|
||||
weight_str = f"{self.weight_kg:.1f}" if self.weight_kg is not None else ""
|
||||
return f"{reps_str}x{weight_str}kg ({self.exercise.name})"
|
||||
Reference in new issue
Block a user