diff --git a/cocktail/__pycache__/__init__.cpython-38.pyc b/cocktail/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..b942b0e Binary files /dev/null and b/cocktail/__pycache__/__init__.cpython-38.pyc differ diff --git a/cocktail/__pycache__/settings.cpython-38.pyc b/cocktail/__pycache__/settings.cpython-38.pyc new file mode 100644 index 0000000..e966c0a Binary files /dev/null and b/cocktail/__pycache__/settings.cpython-38.pyc differ diff --git a/cocktail/__pycache__/urls.cpython-38.pyc b/cocktail/__pycache__/urls.cpython-38.pyc new file mode 100644 index 0000000..fc57ba0 Binary files /dev/null and b/cocktail/__pycache__/urls.cpython-38.pyc differ diff --git a/cocktail/__pycache__/wsgi.cpython-38.pyc b/cocktail/__pycache__/wsgi.cpython-38.pyc new file mode 100644 index 0000000..0d34ab2 Binary files /dev/null and b/cocktail/__pycache__/wsgi.cpython-38.pyc differ diff --git a/cocktail/cocktail_img/bicchiere/coppetta_da_cocktail.png b/cocktail/cocktail_img/bicchiere/coppetta_da_cocktail.png new file mode 100644 index 0000000..1fef1b9 Binary files /dev/null and b/cocktail/cocktail_img/bicchiere/coppetta_da_cocktail.png differ diff --git a/cocktail/cocktail_img/strumento/shaker.jpg b/cocktail/cocktail_img/strumento/shaker.jpg new file mode 100644 index 0000000..54842cd Binary files /dev/null and b/cocktail/cocktail_img/strumento/shaker.jpg differ diff --git a/cocktail/templates/base.html b/cocktail/templates/base.html index 1117cf4..bae39fe 100644 --- a/cocktail/templates/base.html +++ b/cocktail/templates/base.html @@ -16,8 +16,8 @@
Home - Strumenti - Bicchieri + Strumenti + Bicchieri Random Cocktail
diff --git a/cocktail_list/__pycache__/__init__.cpython-38.pyc b/cocktail_list/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..8901174 Binary files /dev/null and b/cocktail_list/__pycache__/__init__.cpython-38.pyc differ diff --git a/cocktail_list/__pycache__/admin.cpython-38.pyc b/cocktail_list/__pycache__/admin.cpython-38.pyc new file mode 100644 index 0000000..f774e16 Binary files /dev/null and b/cocktail_list/__pycache__/admin.cpython-38.pyc differ diff --git a/cocktail_list/__pycache__/models.cpython-38.pyc b/cocktail_list/__pycache__/models.cpython-38.pyc new file mode 100644 index 0000000..cae327f Binary files /dev/null and b/cocktail_list/__pycache__/models.cpython-38.pyc differ diff --git a/cocktail_list/__pycache__/urls.cpython-38.pyc b/cocktail_list/__pycache__/urls.cpython-38.pyc new file mode 100644 index 0000000..7c8a637 Binary files /dev/null and b/cocktail_list/__pycache__/urls.cpython-38.pyc differ diff --git a/cocktail_list/__pycache__/views.cpython-38.pyc b/cocktail_list/__pycache__/views.cpython-38.pyc new file mode 100644 index 0000000..ac38e21 Binary files /dev/null and b/cocktail_list/__pycache__/views.cpython-38.pyc differ diff --git a/cocktail_list/admin.py b/cocktail_list/admin.py index 5059c63..0b4fcc4 100644 --- a/cocktail_list/admin.py +++ b/cocktail_list/admin.py @@ -1,6 +1,15 @@ from django.contrib import admin -from .models import Ingredienti,Cocktail +from .models import Ingredienti,Cocktail,Strumenti,Bicchieri # Register your models here. +class CocktailModel(admin.ModelAdmin): + model = Cocktail + list_display = ('nome_cocktail','lista_ingredienti') + search_fields = ["nome_cocktail","ingredienti__ingrediente"] + + + admin.site.register(Ingredienti) -admin.site.register(Cocktail) \ No newline at end of file +admin.site.register(Strumenti) +admin.site.register(Bicchieri) +admin.site.register(Cocktail,CocktailModel) \ No newline at end of file diff --git a/cocktail_list/migrations/0005_strumenti.py b/cocktail_list/migrations/0005_strumenti.py new file mode 100644 index 0000000..60230a5 --- /dev/null +++ b/cocktail_list/migrations/0005_strumenti.py @@ -0,0 +1,25 @@ +# Generated by Django 3.0.5 on 2020-06-02 15:17 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cocktail_list', '0004_auto_20200527_1858'), + ] + + operations = [ + migrations.CreateModel( + name='Strumenti', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('nome_strumento', models.CharField(max_length=100)), + ('descrizione', models.CharField(max_length=240)), + ], + options={ + 'verbose_name': 'Strumento per Cocktails', + 'verbose_name_plural': 'Strumenti per Cocktails', + }, + ), + ] diff --git a/cocktail_list/migrations/0006_bicchieri.py b/cocktail_list/migrations/0006_bicchieri.py new file mode 100644 index 0000000..63a2166 --- /dev/null +++ b/cocktail_list/migrations/0006_bicchieri.py @@ -0,0 +1,25 @@ +# Generated by Django 3.0.5 on 2020-06-02 15:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cocktail_list', '0005_strumenti'), + ] + + operations = [ + migrations.CreateModel( + name='Bicchieri', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('nome_bicchiere', models.CharField(max_length=100)), + ('descrizione', models.CharField(max_length=240)), + ], + options={ + 'verbose_name': 'Bicchiere per Cocktails', + 'verbose_name_plural': 'Bicchieri per Cocktails', + }, + ), + ] diff --git a/cocktail_list/migrations/0007_auto_20200602_1728.py b/cocktail_list/migrations/0007_auto_20200602_1728.py new file mode 100644 index 0000000..80ed32c --- /dev/null +++ b/cocktail_list/migrations/0007_auto_20200602_1728.py @@ -0,0 +1,23 @@ +# Generated by Django 3.0.5 on 2020-06-02 15:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cocktail_list', '0006_bicchieri'), + ] + + operations = [ + migrations.AddField( + model_name='bicchieri', + name='immagine_bicchieri', + field=models.ImageField(blank=True, null=True, upload_to='bicchiere'), + ), + migrations.AddField( + model_name='strumenti', + name='immagine_strumenti', + field=models.ImageField(blank=True, null=True, upload_to='strumento'), + ), + ] diff --git a/cocktail_list/migrations/__pycache__/0001_initial.cpython-38.pyc b/cocktail_list/migrations/__pycache__/0001_initial.cpython-38.pyc new file mode 100644 index 0000000..57465c2 Binary files /dev/null and b/cocktail_list/migrations/__pycache__/0001_initial.cpython-38.pyc differ diff --git a/cocktail_list/migrations/__pycache__/0002_cocktail_immagine_cocktail.cpython-38.pyc b/cocktail_list/migrations/__pycache__/0002_cocktail_immagine_cocktail.cpython-38.pyc new file mode 100644 index 0000000..5332f3b Binary files /dev/null and b/cocktail_list/migrations/__pycache__/0002_cocktail_immagine_cocktail.cpython-38.pyc differ diff --git a/cocktail_list/migrations/__pycache__/0003_auto_20200526_1705.cpython-38.pyc b/cocktail_list/migrations/__pycache__/0003_auto_20200526_1705.cpython-38.pyc new file mode 100644 index 0000000..62ae80a Binary files /dev/null and b/cocktail_list/migrations/__pycache__/0003_auto_20200526_1705.cpython-38.pyc differ diff --git a/cocktail_list/migrations/__pycache__/0004_auto_20200527_1858.cpython-38.pyc b/cocktail_list/migrations/__pycache__/0004_auto_20200527_1858.cpython-38.pyc new file mode 100644 index 0000000..5c5aec9 Binary files /dev/null and b/cocktail_list/migrations/__pycache__/0004_auto_20200527_1858.cpython-38.pyc differ diff --git a/cocktail_list/migrations/__pycache__/0005_strumenti.cpython-38.pyc b/cocktail_list/migrations/__pycache__/0005_strumenti.cpython-38.pyc new file mode 100644 index 0000000..616daef Binary files /dev/null and b/cocktail_list/migrations/__pycache__/0005_strumenti.cpython-38.pyc differ diff --git a/cocktail_list/migrations/__pycache__/0006_bicchieri.cpython-38.pyc b/cocktail_list/migrations/__pycache__/0006_bicchieri.cpython-38.pyc new file mode 100644 index 0000000..8f522a6 Binary files /dev/null and b/cocktail_list/migrations/__pycache__/0006_bicchieri.cpython-38.pyc differ diff --git a/cocktail_list/migrations/__pycache__/0007_auto_20200602_1728.cpython-38.pyc b/cocktail_list/migrations/__pycache__/0007_auto_20200602_1728.cpython-38.pyc new file mode 100644 index 0000000..e9c9252 Binary files /dev/null and b/cocktail_list/migrations/__pycache__/0007_auto_20200602_1728.cpython-38.pyc differ diff --git a/cocktail_list/migrations/__pycache__/__init__.cpython-38.pyc b/cocktail_list/migrations/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..5754e7a Binary files /dev/null and b/cocktail_list/migrations/__pycache__/__init__.cpython-38.pyc differ diff --git a/cocktail_list/models.py b/cocktail_list/models.py index dbe3fe7..b741f82 100644 --- a/cocktail_list/models.py +++ b/cocktail_list/models.py @@ -54,9 +54,40 @@ class Cocktail(models.Model): 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" diff --git a/cocktail_list/templates/bicchieri.html b/cocktail_list/templates/bicchieri.html new file mode 100644 index 0000000..27a44b3 --- /dev/null +++ b/cocktail_list/templates/bicchieri.html @@ -0,0 +1,36 @@ +{% extends "base.html" %} +{% load static %} +{% block css %} + + + +{% endblock css %} + + +{% block title %} +STRUMENTI +{% endblock title %} + +{% block content %} +{% for bicchieri in lista_bicchieri %} + +{% if forloop.first %}
{% endif %} +
+
+
{{ bicchieri.nome_bicchiere }}
+
+
+
{{ bicchieri.nome_bicchiere }}
+

{{ bicchieri.descrizione}}

+
+
+
+ {% if forloop.counter|divisibleby:"3" or forloop.last %} +
+ {% endif %} + {% if forloop.counter|divisibleby:"3" and not forloop.last %} +
+ {% endif %} + {% endfor %} + +{% endblock content %} \ No newline at end of file diff --git a/cocktail_list/templates/cerca.html b/cocktail_list/templates/cerca.html index 8806003..f9db402 100644 --- a/cocktail_list/templates/cerca.html +++ b/cocktail_list/templates/cerca.html @@ -9,8 +9,12 @@ {% block content %} {% if cocktail %} -

In totale nel nostro Salone Bar abbiamo trovato {{ cocktail.count }} cocktails {% if cocktail.count == 1 %} che corrisponde {% else %} che corrispondono {% endif %} alla tua ricerca

+
+
+

In totale nel nostro Salone Bar abbiamo trovato {{ cocktail.count }} cocktails {% if cocktail.count == 1 %} che corrisponde {% else %} che corrispondono {% endif %} alla tua ricerca

{% for cocktails in cocktail %} +
+
{% if forloop.first %}
{% endif %} @@ -32,9 +36,38 @@
{% endif %} {% endfor %} + {% endif %} + {% if ingrediente and cocktail %}
+ {% elif ingrediente or cocktail %} + {% else %} +
+

Nessun Cocktail o Ingrediente trovato!

+
{% endif %} {% if ingrediente %} -

HELLO

+
+

Cocktails contenenti l'ingrediente "{{ querystring }}" :

+
+ {% for cocktails_ingrediente in ingrediente %} + {% if forloop.first %}
{% endif %} + + {% if forloop.counter|divisibleby:"3" or forloop.last %} +
+ {% endif %} + {% if forloop.counter|divisibleby:"3" and not forloop.last %} +
+ {% endif %} + {% endfor %} {% endif %} {% endblock content %} \ No newline at end of file diff --git a/cocktail_list/templates/homepage.html b/cocktail_list/templates/homepage.html index 2d3a0e9..5b13afb 100644 --- a/cocktail_list/templates/homepage.html +++ b/cocktail_list/templates/homepage.html @@ -8,11 +8,48 @@ {% endblock css %} {% block content %} -
-
In totale nel nostro Salone Bar abbiamo {{ lista_cocktail.count }} cocktails
+ + - {% for cocktail in lista_cocktail %} +
+

LISTA COCKTAILS :

+
+{% for cocktail in lista_cocktail %} {% if forloop.first %}
{% endif %}
@@ -32,4 +69,8 @@
{% endif %} {% endfor %} +
+
In totale nel nostro Salone Bar abbiamo {{ lista_cocktail.count }} cocktails
+
+ {% endblock content %} \ No newline at end of file diff --git a/cocktail_list/templates/strumenti.html b/cocktail_list/templates/strumenti.html new file mode 100644 index 0000000..e90d2ef --- /dev/null +++ b/cocktail_list/templates/strumenti.html @@ -0,0 +1,37 @@ +{% extends "base.html" %} +{% load static %} +{% block css %} + + + +{% endblock css %} + + +{% block title %} +STRUMENTI +{% endblock title %} + +{% block content %} + +{% for strumenti in lista_strumenti %} + +{% if forloop.first %}
{% endif %} +
+
+
{{ strumenti.nome_strumento }}
+
+
+
{{ strumenti.nome_strumento }}
+

{{ strumenti.descrizione}}

+
+
+
+ {% if forloop.counter|divisibleby:"3" or forloop.last %} +
+ {% endif %} + {% if forloop.counter|divisibleby:"3" and not forloop.last %} +
+ {% endif %} + {% endfor %} + +{% endblock content %} \ No newline at end of file diff --git a/cocktail_list/urls.py b/cocktail_list/urls.py index 65f6fc9..de9f2c3 100644 --- a/cocktail_list/urls.py +++ b/cocktail_list/urls.py @@ -1,10 +1,12 @@ from django.urls import path -from .views import homepage,cocktail,cerca,random_cocktail +from .views import homepage,cocktail,cerca,random_cocktail,strumenti_cocktail,bicchieri_cocktail urlpatterns = [ path("",homepage,name="Homepage"), path("cocktail//",cocktail,name="cocktail"), path("cerca/",cerca,name="cerca"), - path("random_cocktail/",random_cocktail,name="random_cocktail") + path("random_cocktail/",random_cocktail,name="random_cocktail"), + path("strumenti/",strumenti_cocktail,name="strumenti-list"), + path("bicchieri/",bicchieri_cocktail,name="bicchieri-list") ] \ No newline at end of file diff --git a/cocktail_list/views.py b/cocktail_list/views.py index 76c8665..4d321c1 100644 --- a/cocktail_list/views.py +++ b/cocktail_list/views.py @@ -1,5 +1,5 @@ from django.shortcuts import render,get_object_or_404,redirect -from .models import Cocktail,Ingredienti +from .models import Cocktail,Ingredienti,Strumenti,Bicchieri import random import time # Create your views here. @@ -25,14 +25,55 @@ def random_cocktail(request): context = {"random_cocktail":rand_cocktail} return render(request,"random_cocktail.html",context) +def strumenti_cocktail(request): + lista_strumenti = Strumenti.objects.all() + context = {"lista_strumenti":lista_strumenti} + return render(request,"strumenti.html",context) + +# def strumento_views(request,nome_strumento): +# strumento = get_object_or_404(Strumenti,nome_strumento=nome_strumento) +# context = {"strumento":strumento} +# return render(request,"strumento_detail.html",context) + + +def bicchieri_cocktail(request): + lista_bicchieri = Bicchieri.objects.all() + context = {"lista_bicchieri":lista_bicchieri} + return render(request,"bicchieri.html",context) + +# def bicchiere_views(request,nome_bicchiere): +# bicchiere = get_object_or_404(Strumenti,nome_bicchiere=nome_bicchiere) +# context = {"bicchiere":bicchiere} +# return render(request,"bicchiere_detail.html",context) + + +# def cerca(request): +# if "q" in request.GET: +# querystring = request.GET.get("q") +# if len(querystring) == 0: +# return redirect("cerca") +# ingrediente = Cocktail.objects.filter(ingredienti__ingrediente__icontains=querystring).order_by("-nome_cocktail") +# cocktail = Cocktail.objects.filter(nome_cocktail__icontains=querystring).order_by("-nome_cocktail") +# context = {"querystring":querystring,"cocktail":cocktail,"ingrediente":ingrediente} +# return render(request,"cerca.html",context) +# else: +# return render(request,"cerca.html") + + def cerca(request): if "q" in request.GET: querystring = request.GET.get("q") if len(querystring) == 0: - return redirect("cerca/") - ingrediente = Cocktail.objects.filter(ingredienti__ingrediente__icontains=querystring).order_by("-nome_cocktail") + return redirect("cerca") + all_ingredients = Cocktail.objects.all() + searching_ingred = Cocktail.objects.none() + for one_ingredient in querystring.split(","): + print(one_ingredient) + searching_ingred = searching_ingred.union(searching_ingred, all_ingredients.filter(ingredienti__ingrediente__icontains=one_ingredient)) + print(searching_ingred) + # ingrediente = Cocktail.objects.filter(ingredienti__ingrediente__icontains=querystring).order_by("-nome_cocktail") cocktail = Cocktail.objects.filter(nome_cocktail__icontains=querystring).order_by("-nome_cocktail") - context = {"querystring":querystring,"cocktail":cocktail,"ingrediente":ingrediente} + context = {"querystring":querystring,"cocktail":cocktail,"ingrediente":searching_ingred} return render(request,"cerca.html",context) else: - return render(request,"cerca.html") + return render(request,"cerca.html") \ No newline at end of file diff --git a/db.sqlite3 b/db.sqlite3 index bf36e98..aadd947 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/static-storage/css/style.css b/static-storage/css/style.css index 85879c9..10e5b64 100644 --- a/static-storage/css/style.css +++ b/static-storage/css/style.css @@ -27,7 +27,7 @@ a:hover{ border-radius: 5px; border: 1px solid grey; background-image: url("https://img.freepik.com/foto-gratuito/selezione-di-vari-cocktail-sul-tavolo_140725-2909.jpg?size=626&ext=jpg"); - background-size: cover; + /* background-size: cover; */ background-position: center; position: relative; } @@ -40,4 +40,20 @@ a:hover{ top: 50%; left: 50%; transform: translate(-50%, -50%); +} +.text-carousel{ + font-family: 'Faster One', cursive; +} +.carousel-item{ + max-width: 100%; + height: 500px; +} +.carousel-item img{ + height: 100%!important; +} +#color-for-glass{ + font-family: 'Faster One', cursive; + font-size: 1.5em; + text-transform: uppercase; + color: black; } \ No newline at end of file