Aggiunta Classe Quantitá

master
Michael Vignotto 2020-06-14 14:43:31 +02:00
parent bd2622b7a0
commit 6ede5f03fd
11 changed files with 72 additions and 33 deletions

View File

@ -1,5 +1,5 @@
from django.contrib import admin
from .models import Ingredienti,Cocktail,Strumenti,Bicchieri
from .models import Ingredienti,Cocktail,Strumenti,Bicchieri,Quantitá
# Register your models here.
class CocktailModel(admin.ModelAdmin):
@ -12,4 +12,5 @@ class CocktailModel(admin.ModelAdmin):
admin.site.register(Ingredienti)
admin.site.register(Strumenti)
admin.site.register(Bicchieri)
admin.site.register(Quantitá)
admin.site.register(Cocktail,CocktailModel)

View File

@ -0,0 +1,30 @@
# Generated by Django 3.0.7 on 2020-06-14 12:25
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('cocktail_list', '0007_auto_20200602_1728'),
]
operations = [
migrations.CreateModel(
name='Quantitá',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('quantity', models.CharField(max_length=120)),
],
),
migrations.RemoveField(
model_name='ingredienti',
name='quantitá',
),
migrations.AddField(
model_name='ingredienti',
name='quantitá_ingrediente',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cocktail_list.Quantitá'),
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 3.0.7 on 2020-06-14 12:36
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('cocktail_list', '0008_auto_20200614_1225'),
]
operations = [
migrations.AlterModelOptions(
name='quantitá',
options={'verbose_name': 'Quantitá', 'verbose_name_plural': 'Quantitá'},
),
migrations.AlterField(
model_name='ingredienti',
name='quantitá_ingrediente',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cocktail_list.Quantitá'),
),
]

View File

@ -2,42 +2,27 @@ from django.db import models
from django.urls import reverse
# Create your models here.
class Quantitá(models.Model):
quantity = models.CharField(max_length=120)
def __str__(self):
return self.quantity
class Meta:
verbose_name = "Quantitá"
verbose_name_plural = "Quantitá"
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")
quantitá_ingrediente = models.ForeignKey(Quantitá,on_delete=models.CASCADE)
def __repr__(self):
return self.quantitá_ingrediente.quantity + " " + self.ingrediente
def __str__(self):
return self.ingrediente
return f"{self.ingrediente}"
class Meta:
verbose_name = "Ingrediente"

View File

@ -29,7 +29,7 @@ COCKTAIL | {{ cocktail.nome_cocktail }}
<hr>
<ul>
{% for ingredienti in cocktail.ingredienti.all %}
<li class="text-on-body">{{ ingredienti.ingrediente }}</li>
<li class="text-on-body">{{ ingredienti.quantitá_ingrediente }} {{ ingredienti.ingrediente }}</li>
{% endfor %}
</ul>
<hr>

Binary file not shown.