from django.db import models from django.core.validators import FileExtensionValidator class Exercise(models.Model): CATEGORY_CHOICES = [ ('warmup', 'Warm-up'), ('kraft', 'Strength'), ('technik', 'Technique'), ('ausdauer', 'Endurance'), ('spiele', 'Games'), ('cool_down', 'Cool-down'), ] TYPE_CHOICES = [ ('reps', 'Repetitions'), ('time', 'Time-based'), ] name = models.CharField(max_length=200) category = models.CharField(max_length=20, choices=CATEGORY_CHOICES) exercise_type = models.CharField(max_length=10, choices=TYPE_CHOICES, default='reps') club = models.ForeignKey('clubs.Club', on_delete=models.CASCADE, related_name='exercises', null=True, blank=True) description = models.TextField(blank=True) default_value = models.CharField(max_length=50, blank=True, help_text='Default reps or seconds') media = models.FileField( upload_to='exercises/media/', null=True, blank=True, validators=[FileExtensionValidator(allowed_extensions=['jpg', 'jpeg', 'png', 'mp4', 'webp'])] ) is_active = models.BooleanField(default=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class Meta: ordering = ['category', 'name'] indexes = [ models.Index(fields=['category']), models.Index(fields=['club']), ] def __str__(self): return f"{self.name} ({self.get_category_display()})"