from django.db import models
from django.conf import settings

# Create your models here.
class Exercise(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=64)
    description = models.CharField(null=True, blank=True, max_length=255)
    side = models.CharField(null=True, blank=True, max_length=64)
    is_two_dumbbells = models.BooleanField(default=False)
    is_trackable_distance = models.BooleanField(default=False)
    is_alternating = models.BooleanField(default=False)
    is_weight = models.BooleanField(default=False)
    is_distance = models.BooleanField(default=False)
    is_duration = models.BooleanField(default=False)
    is_reps = models.BooleanField(default=False)
    joints_used = models.CharField(null=True, blank=True, max_length=255)
    movement_patterns = models.CharField(null=True, blank=True, max_length=255)
    equipment_required = models.CharField(null=True, blank=True, max_length=255)
    muscle_groups = models.CharField(null=True, blank=True, max_length=255)
    synonyms = models.CharField(null=True, blank=True, max_length=255)

    class Meta:
        ordering = ('name',)

    def __str__(self):
        return self.name + ":" + self.description
    
    def video_url(self):
        return str(settings.MEDIA_URL) + "exercise_videos/" + self.name.replace(" ", "_") + ".mp4"
    
    def audio_url(self):
        return str(settings.MEDIA_URL) + "exercise_audio/" + self.name.replace(" ", "_") + ".m4a"