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


# def user_directory._path(instance, filename):
      # print(request.user.id)
      # return 'user_{0}/{1}'.format(instance.user.id, filename)
# Ok i got hella angry, so pleaSE fix this bullshit
# I want to be able to store each and every user's files in a separate folder, based on their id
# I CANT GET A FUCKING LOGGED IN USER ID FROM THE MODELS THINGY IM FUCKING PISSED

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

def videosPath(instance,filename):
    return f"videos/{instance.user.id}/{filename}"
    
class Image(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True)
    image = models.ImageField(upload_to=imagesPath,validators=[imageValidate], unique=True)
    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)
    
    
    class Meta:
        verbose_name = 'image'
        verbose_name_plural = 'images'

# class Videos(models.Model):
#     user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True)
#     video = models.FileField(upload_to=videosPath, validators=[videoValidate])
#     tokenized = models.BooleanField(blank=True, null=True, default=None, max_length=3)
#     reason = models.CharField(max_length=120)



#     class Meta:
#         verbose_name = 'video'
#         verbose_name_plural = 'videos'
