Deep audit identified 106 findings; 102 fixed, 4 deferred. Covers 8 areas: - Settings & deploy: env-gated DEBUG/SECRET_KEY, HTTPS headers, gunicorn, celery worker - Auth (registered_user): password write_only, request.data fixes, transaction safety, proper HTTP status codes - Workout app: IDOR protection, get_object_or_404, prefetch_related N+1 fixes, transaction.atomic - Video/scripts: path traversal sanitization, HLS trigger guard, auth on cache wipe - Models (exercise/equipment/muscle/superset): null-safe __str__, stable IDs, prefetch support - Generator views: helper for registered_user lookup, logger.exception, bulk_update, transaction wrapping - Generator core (rules/selector/generator): push-pull ratio, type affinity normalization, modality checks, side-pair exact match, word-boundary regex, equipment cache clearing - Generator services (plan_builder/analyzer/normalizer): transaction.atomic, muscle cache, bulk_update, glutes classification fix Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
from django.db import models
|
|
from workout.models import Workout
|
|
from exercise.models import Exercise
|
|
|
|
# Create your models here.
|
|
class Superset(models.Model):
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
name = models.CharField(max_length=255, blank=True, null=True)
|
|
|
|
workout = models.ForeignKey(
|
|
Workout,
|
|
on_delete=models.CASCADE,
|
|
related_name='superset_workout'
|
|
)
|
|
|
|
rounds = models.IntegerField(blank=False, null=False)
|
|
order = models.IntegerField(blank=False, null=False)
|
|
estimated_time = models.FloatField(blank=True, null=True)
|
|
rest_between_rounds = models.IntegerField(default=45, help_text='Rest between rounds in seconds')
|
|
|
|
def __str__(self):
|
|
name = " -- " if self.name is None else self.name
|
|
return name #+ " : " + self.description + " | by: " + self.registered_user.nick_name
|
|
|
|
class SupersetExercise(models.Model):
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
exercise = models.ForeignKey(
|
|
Exercise,
|
|
on_delete=models.CASCADE,
|
|
related_name='exercise_supersets'
|
|
)
|
|
|
|
superset = models.ForeignKey(
|
|
Superset,
|
|
on_delete=models.CASCADE,
|
|
related_name='superset_exercises'
|
|
)
|
|
|
|
weight = models.IntegerField(null=True, blank=True)
|
|
reps = models.IntegerField(null=True, blank=True)
|
|
duration = models.IntegerField(null=True, blank=True)
|
|
order = models.IntegerField(blank=False, null=False)
|
|
|
|
def __str__(self):
|
|
return self.superset.workout.name + " -- " + self.exercise.name
|