diff --git a/cocktail/__pycache__/settings.cpython-37.pyc b/cocktail/__pycache__/settings.cpython-37.pyc index ccbf891..835cc4a 100644 Binary files a/cocktail/__pycache__/settings.cpython-37.pyc and b/cocktail/__pycache__/settings.cpython-37.pyc differ diff --git a/cocktail/settings.py b/cocktail/settings.py index 1b4b7bc..d94a2d6 100644 --- a/cocktail/settings.py +++ b/cocktail/settings.py @@ -123,4 +123,6 @@ STATIC_URL = '/static/' MEDIA_ROOT = (os.path.join(BASE_DIR, 'cocktail/cocktail_img')) -MEDIA_URL = "/img/" \ No newline at end of file +MEDIA_URL = "/img/" + +STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static-storage')] \ No newline at end of file diff --git a/cocktail/templates/base.html b/cocktail/templates/base.html index 62c919f..392b6fd 100644 --- a/cocktail/templates/base.html +++ b/cocktail/templates/base.html @@ -7,12 +7,25 @@ + {% block css %} {% endblock css %} {% block title %} {% endblock title %} +
+ Home + Strumenti + Bicchieri + Random Cocktail +
+
+ + +
+
+
{% block content %} @@ -24,5 +37,6 @@ + \ No newline at end of file diff --git a/cocktail_list/__pycache__/models.cpython-37.pyc b/cocktail_list/__pycache__/models.cpython-37.pyc index 2e8e74c..030f0cd 100644 Binary files a/cocktail_list/__pycache__/models.cpython-37.pyc and b/cocktail_list/__pycache__/models.cpython-37.pyc differ diff --git a/cocktail_list/__pycache__/urls.cpython-37.pyc b/cocktail_list/__pycache__/urls.cpython-37.pyc index e7a055e..f30ff4a 100644 Binary files a/cocktail_list/__pycache__/urls.cpython-37.pyc and b/cocktail_list/__pycache__/urls.cpython-37.pyc differ diff --git a/cocktail_list/__pycache__/views.cpython-37.pyc b/cocktail_list/__pycache__/views.cpython-37.pyc index 6275efb..98636ea 100644 Binary files a/cocktail_list/__pycache__/views.cpython-37.pyc and b/cocktail_list/__pycache__/views.cpython-37.pyc differ diff --git a/cocktail_list/migrations/0003_auto_20200526_1705.py b/cocktail_list/migrations/0003_auto_20200526_1705.py new file mode 100644 index 0000000..382b20a --- /dev/null +++ b/cocktail_list/migrations/0003_auto_20200526_1705.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.5 on 2020-05-26 17:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cocktail_list', '0002_cocktail_immagine_cocktail'), + ] + + operations = [ + migrations.AlterField( + model_name='ingredienti', + name='quantitá', + field=models.CharField(choices=[('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'), ('1Goccia', '1 goccia'), ('2Gocce', '2 goccie'), ('3Gocce', '3 goccie'), ('4Gocce', '4 goccie'), ('5Gocce', '5 goccie'), ('Cubetti', '3 Cubetti'), ('Spruzzo', '1 Spruzzo')], default='5ML', max_length=30), + ), + ] diff --git a/cocktail_list/migrations/0004_auto_20200527_1858.py b/cocktail_list/migrations/0004_auto_20200527_1858.py new file mode 100644 index 0000000..ef6c94b --- /dev/null +++ b/cocktail_list/migrations/0004_auto_20200527_1858.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.5 on 2020-05-27 18:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cocktail_list', '0003_auto_20200526_1705'), + ] + + operations = [ + migrations.AlterField( + model_name='ingredienti', + name='quantitá', + field=models.CharField(choices=[('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')], default='5ML', max_length=30), + ), + ] diff --git a/cocktail_list/migrations/__pycache__/0003_auto_20200526_1705.cpython-37.pyc b/cocktail_list/migrations/__pycache__/0003_auto_20200526_1705.cpython-37.pyc new file mode 100644 index 0000000..2ded987 Binary files /dev/null and b/cocktail_list/migrations/__pycache__/0003_auto_20200526_1705.cpython-37.pyc differ diff --git a/cocktail_list/migrations/__pycache__/0004_auto_20200527_1858.cpython-37.pyc b/cocktail_list/migrations/__pycache__/0004_auto_20200527_1858.cpython-37.pyc new file mode 100644 index 0000000..775b0c0 Binary files /dev/null and b/cocktail_list/migrations/__pycache__/0004_auto_20200527_1858.cpython-37.pyc differ diff --git a/cocktail_list/models.py b/cocktail_list/models.py index d3fdd77..dbe3fe7 100644 --- a/cocktail_list/models.py +++ b/cocktail_list/models.py @@ -26,12 +26,13 @@ class Ingredienti(models.Model): ('90ML', '90 ml'), ('95ML', '95 ml'), ('100ML', '100 ml'), - ('1Goccia', '1 goccia'), - ('2Gocce', '2 goccie'), - ('3Gocce', '3 goccie'), - ('4Gocce', '4 goccie'), - ('5Gocce', '5 goccie'), + ('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") @@ -42,9 +43,6 @@ class Ingredienti(models.Model): verbose_name = "Ingrediente" verbose_name_plural = "Ingredienti" - - - class Cocktail(models.Model): ingredienti = models.ManyToManyField(Ingredienti) nome_cocktail = models.CharField(max_length=120) @@ -54,7 +52,7 @@ class Cocktail(models.Model): immagine_cocktail = models.ImageField(upload_to="cocktail_img",blank=True,null=True) def __str__(self): - return self.nome_cocktail + return f"{self.nome_cocktail}" def get_absolute_url(self): return reverse('cocktail', kwargs={'nome_cocktail': self.nome_cocktail}) diff --git a/cocktail_list/templates/cerca.html b/cocktail_list/templates/cerca.html new file mode 100644 index 0000000..8806003 --- /dev/null +++ b/cocktail_list/templates/cerca.html @@ -0,0 +1,40 @@ +{% extends "base.html" %} +{% load static %} + +{% block css %} + + + +{% endblock css %} + +{% 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

+{% for cocktails in cocktail %} + + {% 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 %} + {% if ingrediente %} +

HELLO

+ {% endif %} +{% endblock content %} \ No newline at end of file diff --git a/cocktail_list/templates/cocktail.html b/cocktail_list/templates/cocktail.html index b3f3d47..6db8d05 100644 --- a/cocktail_list/templates/cocktail.html +++ b/cocktail_list/templates/cocktail.html @@ -1,5 +1,5 @@ {% extends "base.html" %} - +{% load static %} {% block css %} + {% endblock css %} diff --git a/cocktail_list/templates/homepage.html b/cocktail_list/templates/homepage.html index 16a80b0..06816d4 100644 --- a/cocktail_list/templates/homepage.html +++ b/cocktail_list/templates/homepage.html @@ -1,31 +1,17 @@ {% extends "base.html" %} +{% load static %} + +{% block css %} + + + +{% endblock css %} + {% block content %} +

In totale nel nostro Salone Bar abbiamo {{ lista_cocktail.count }}

{% for cocktail in lista_cocktail %} - {% block css %} - - - {% endblock css %} {% if forloop.first %}
{% endif %}
diff --git a/cocktail_list/templates/random_cocktail.html b/cocktail_list/templates/random_cocktail.html new file mode 100644 index 0000000..583e71b --- /dev/null +++ b/cocktail_list/templates/random_cocktail.html @@ -0,0 +1,31 @@ +{% extends "base.html" %} +{% load static %} + +{% block css %} + + + +{% endblock css %} + +{% block content %} + {% for cocktail in random_cocktail %} + {% if forloop.first %} + {% 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 bba4c01..65f6fc9 100644 --- a/cocktail_list/urls.py +++ b/cocktail_list/urls.py @@ -1,7 +1,10 @@ from django.urls import path -from .views import homepage,cocktail +from .views import homepage,cocktail,cerca,random_cocktail urlpatterns = [ path("",homepage,name="Homepage"), path("cocktail//",cocktail,name="cocktail"), + path("cerca/",cerca,name="cerca"), + path("random_cocktail/",random_cocktail,name="random_cocktail") + ] \ No newline at end of file diff --git a/cocktail_list/views.py b/cocktail_list/views.py index fd61734..90da897 100644 --- a/cocktail_list/views.py +++ b/cocktail_list/views.py @@ -1,5 +1,6 @@ from django.shortcuts import render,get_object_or_404,redirect from .models import Cocktail,Ingredienti +import random # Create your views here. @@ -15,13 +16,23 @@ def cocktail(request,nome_cocktail): context = {"cocktail":cocktail} return render(request,"cocktail.html",context) + +def random_cocktail(request): + random_cocktail = Cocktail.objects.all() + number_of_cocktail = Cocktail.objects.all().count() + random_cocktail_list = random.randint(1,number_of_cocktail) + rand_cocktail = random.sample(list(random_cocktail),random_cocktail_list) + context = {"random_cocktail":rand_cocktail} + return render(request,"random_cocktail.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 = {"cocktail":cocktail} + context = {"querystring":querystring,"cocktail":cocktail,"ingrediente":ingrediente} return render(request,"cerca.html",context) else: return render(request,"cerca.html") diff --git a/db.sqlite3 b/db.sqlite3 index c3b4f7f..bf36e98 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/static-storage/css/navbar_style.css b/static-storage/css/navbar_style.css new file mode 100644 index 0000000..4d12723 --- /dev/null +++ b/static-storage/css/navbar_style.css @@ -0,0 +1,67 @@ +.topnav { + overflow: hidden; + background-color: #e9e9e9; + } + + .topnav a { + float: left; + display: block; + color: black; + text-align: center; + padding: 14px 16px; + text-decoration: none; + font-size: 17px; + } + + .topnav a:hover { + background-color: #ddd; + color: black; + } + + .topnav a.active { + background-color: #2196F3; + color: white; + } + + .topnav .search-container { + float: right; + } + + .topnav input[type=text] { + padding: 6px; + margin-top: 8px; + font-size: 17px; + border: none; + } + + .topnav .search-container button { + float: right; + padding: 6px 10px; + margin-top: 8px; + margin-right: 16px; + background: #ddd; + font-size: 17px; + border: none; + cursor: pointer; + } + + .topnav .search-container button:hover { + background: #ccc; + } + + @media screen and (max-width: 600px) { + .topnav .search-container { + float: none; + } + .topnav a, .topnav input[type=text], .topnav .search-container button { + float: none; + display: block; + text-align: left; + width: 100%; + margin: 0; + padding: 14px; + } + .topnav input[type=text] { + border: 1px solid #ccc; + } + } \ No newline at end of file diff --git a/static-storage/css/style.css b/static-storage/css/style.css new file mode 100644 index 0000000..56606a9 --- /dev/null +++ b/static-storage/css/style.css @@ -0,0 +1,22 @@ +* { + box-sizing: border-box; +} + +.text_on_image{ + color:white; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + text-transform: uppercase; + font-size: 2.5em; + font-family: 'Faster One', cursive; +} +a +{ + color: inherit; + text-decoration: none!important; +} +a:hover{ + color: inherit; +} \ No newline at end of file