from django.db import models

# Create your models here.

class Chapter(models.Model): # chapter first hirachical element Osterosynthese
    id = models.IntegerField(primary_key=True) #SetPrimarykey
    title = models.CharField(max_length=100) # or name
    icon = models.ImageField(default='fallback.png', blank=True)
    def __str__(self):
        return self.title

class Section(models.Model):# second hirachical element # Oberarm
    id = models.IntegerField(primary_key=True) #SetPrimarykey
    title = models.CharField(max_length=100) # or name
    icon = models.ImageField(default='fallback.png', blank=True)

    def __str__(self):
        return self.title

class Subsection(models.Model):#Proximaler Oberarm
    id = models.IntegerField(primary_key=True) #SetPrimarykey
    title = models.CharField(max_length=100) # or name
    icon = models.ImageField(default='fallback.png', blank=True)
    def __str__(self):
        return self.title

class ProductType(models.Model): #Platte
    id = models.IntegerField(primary_key=True) #SetPrimarykey
    title = models.CharField(max_length=100) # or name
    icon = models.ImageField(default='fallback.png', blank=True)

class Manufacturer(models.Model):
    id = models.IntegerField(primary_key=True) #SetPrimarykey
    name = models.CharField(max_length=100) # or name
    icon = models.ImageField(default='fallback.png', blank=True)

class ContactPerson

class Product(models.Model):
    id = models.IntegerField(primary_key=True)
    ProductType = models.ManyToOneRel(ProductType)
    chaper = models.ManyToManyField(Chapter)
    section = models.ManyToManyField(Section)
    subsection = models.ManyToManyField(Subsection)

    title = models.CharField(max_length=75)
    name = models.CharField(max_length=75)

    description = models.TextField()

    slug = models.SlugField()
    date = models.DateTimeField(auto_now_add=True)
    banner = models.ImageField(default='fallback.png', blank=True)
    manufacturer = models.ForeignKey(Manufacturer, on_delete=models.CASCADE, default=None) #Kritisch wenn conus medical products are linked to User.objects.get(username='root')company and compony is deleted all products are deleted.

    def __str__(self):
        return self.title
    
"""
def user_directory_path(instance, filename):
    return "user_{0}/{1}".format(instance.user.id, filename)

upload_to_pattern = FilePattern(filename_pattern='PDFuploads/{app_label:.25}/{model_name:.30}/{uuid:base32}{ext}')
class ConusFilePDF(models.Model):
    fileName = models.CharField(max_length=32)
    #file = models.FileField(upload_to="PDFuploads/")
    file = models.FileField(upload_to=upload_to_pattern)
"""   