94 lines
2.6 KiB
Python
94 lines
2.6 KiB
Python
from django.db import models
|
|
from django.urls import reverse
|
|
# Create your models here.
|
|
|
|
|
|
class Ingredienti(models.Model):
|
|
ingrediente = models.CharField(max_length=100)
|
|
quantitá_scelta = [
|
|
('5ML', '5 ml'),
|
|
('10ML', '10 ml'),
|
|
('15ML', '15 ml'),
|
|
('20ML', '20 ml'),
|
|
('25ML', '25 ml'),
|
|
('30ML', '30 ml'),
|
|
('35ML', '35 ml'),
|
|
('40ML', '40 ml'),
|
|
('45ML', '45 ml'),
|
|
('50ML', '50 ml'),
|
|
('55ML', '55 ml'),
|
|
('60ML', '60 ml'),
|
|
('65ML', '65 ml'),
|
|
('70ML', '70 ml'),
|
|
('75ML', '75 ml'),
|
|
('80ML', '80 ml'),
|
|
('85ML', '85 ml'),
|
|
('90ML', '90 ml'),
|
|
('95ML', '95 ml'),
|
|
('100ML', '100 ml'),
|
|
('1 Goccia', '1 goccia'),
|
|
('2 Gocce', '2 goccie'),
|
|
('3 Gocce', '3 goccie'),
|
|
('4 Gocce', '4 goccie'),
|
|
('5 Gocce', '5 goccie'),
|
|
('Cubetti', '3 Cubetti'),
|
|
('Spruzzo', '1 Spruzzo'),
|
|
]
|
|
quantitá = models.CharField(max_length=30,choices=quantitá_scelta,default="5ML")
|
|
|
|
def __str__(self):
|
|
return self.ingrediente
|
|
|
|
class Meta:
|
|
verbose_name = "Ingrediente"
|
|
verbose_name_plural = "Ingredienti"
|
|
|
|
class Cocktail(models.Model):
|
|
ingredienti = models.ManyToManyField(Ingredienti)
|
|
nome_cocktail = models.CharField(max_length=120)
|
|
preparazione = models.TextField()
|
|
storia = models.TextField()
|
|
curiositá = models.TextField()
|
|
immagine_cocktail = models.ImageField(upload_to="cocktail_img",blank=True,null=True)
|
|
|
|
def __str__(self):
|
|
return f"{self.nome_cocktail}"
|
|
|
|
def lista_ingredienti(self):
|
|
return "\n ,".join([i.ingrediente for i in self.ingredienti.all()])
|
|
|
|
def get_absolute_url(self):
|
|
return reverse('cocktail', kwargs={'nome_cocktail': self.nome_cocktail})
|
|
|
|
class Meta:
|
|
verbose_name = "Cocktail"
|
|
verbose_name_plural = "Cocktails"
|
|
|
|
|
|
class Strumenti(models.Model):
|
|
nome_strumento = models.CharField(max_length=100)
|
|
descrizione = models.CharField(max_length=240)
|
|
immagine_strumenti = models.ImageField(upload_to="strumento",blank=True,null=True)
|
|
|
|
|
|
def __str__(self):
|
|
return self.nome_strumento
|
|
|
|
class Meta:
|
|
verbose_name = "Strumento per Cocktails"
|
|
verbose_name_plural = "Strumenti per Cocktails"
|
|
|
|
|
|
class Bicchieri(models.Model):
|
|
nome_bicchiere = models.CharField(max_length=100)
|
|
descrizione = models.CharField(max_length=240)
|
|
immagine_bicchieri = models.ImageField(upload_to="bicchiere",blank=True,null=True)
|
|
|
|
|
|
def __str__(self):
|
|
return self.nome_bicchiere
|
|
|
|
class Meta:
|
|
verbose_name = "Bicchiere per Cocktails"
|
|
verbose_name_plural = "Bicchieri per Cocktails"
|