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

class Keller(models.Model):
	name = models.CharField(max_length=100)
	menge = models.FloatField()
	einheit = models.CharField(max_length=10)
	kiste = models.IntegerField()
	nr = models.IntegerField()
	info = models.TextField(default='')
	
	def __str__(self):
		return self.name
		
	def get_absolute_url(self):
		return reverse("keller-detail", kwargs={"id": self.id})
	
class Book(models.Model):
	title = models.CharField(max_length=100)
	author = models.CharField(max_length=100)
	pdf = models.FileField(upload_to='books')
	
	def __str__(self):
		return self.title
	
	def delete(self, *args, **kwargs):
		self.pdf.delete()
		super().delete(*args, **kwargs)
	

class Video(models.Model):
	title = models.CharField(max_length=100)
	tags = models.CharField(max_length=255)
	media = models.FileField(upload_to='video')
	
	def __str__(self):
		return self.title
	
	def delete(self, *args, **kwargs):
		self.media.delete()
		super().delete(*args, **kwargs)