from django.db import models
from .validators import videoValidate, imageValidate
from django.contrib.auth.models import User
from datetime import date

def imagesPath(instance, filename):
    # file will be uploaded to MEDIA_ROOT/user_<id>/<filename>
    return '{0}/{1}'.format(instance.user.id, filename)

def videosPath(instance,filename):
    return f"{instance.user.id}/videos/{filename}"
    
class Media(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True)
    image = models.FileField(upload_to=imagesPath, blank=True, null=True,)
    is_video = models.BooleanField(default=False)
    tokenized = models.BooleanField(blank=True, null=True, default=None, max_length=3)
    reason = models.CharField(max_length=120)
    date = models.DateField(default=date.today)
    time = models.TimeField(auto_now=True)
    managed_by = models.CharField(max_length=30, blank=True, null=True, default=None, )
    
    
    class Meta:
        verbose_name = 'image'
        verbose_name_plural = 'images'

