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>
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
from django.db import models
|
|
from exercise.models import Exercise
|
|
|
|
# Create your models here.
|
|
class Equipment(models.Model):
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
is_weight = models.BooleanField(default=False)
|
|
category = models.CharField(null=True, blank=True, max_length=64)
|
|
name = models.CharField(null=True, blank=True, max_length=64)
|
|
|
|
def __str__(self):
|
|
return f"{self.category or ''} : {self.name or ''}"
|
|
|
|
class WorkoutEquipment(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='workout_exercise_workout'
|
|
)
|
|
equipment = models.ForeignKey(
|
|
Equipment,
|
|
on_delete=models.CASCADE,
|
|
related_name='workout_exercise_workout'
|
|
)
|
|
|
|
class Meta:
|
|
unique_together = ('exercise', 'equipment')
|
|
|
|
def __str__(self):
|
|
return self.exercise.name + " : " + self.equipment.name |