Aggiunto FrontEnd

master
MickSlash 2020-06-03 15:45:22 +02:00
parent a2b277789d
commit 603d315a4c
33 changed files with 336 additions and 17 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 435 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB

View File

@ -16,8 +16,8 @@
<body>
<div class="topnav text-center">
<a class="active" href="{% url 'Homepage' %}"><i class="fas fa-home mr-2"></i>Home</a>
<a href="#about">Strumenti</a>
<a href="#about">Bicchieri</a>
<a href="{% url 'strumenti-list' %}">Strumenti</a>
<a href="{% url 'bicchieri-list' %}">Bicchieri</a>
<a href="{% url 'random_cocktail' %}"><i class="fas fa-glass-cheers mr-2" style="color: black;"></i>Random Cocktail</a>
<div class="search-container">
<form action="{% url 'cerca' %}">

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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)
admin.site.register(Strumenti)
admin.site.register(Bicchieri)
admin.site.register(Cocktail,CocktailModel)

View File

@ -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',
},
),
]

View File

@ -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',
},
),
]

View File

@ -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'),
),
]

View File

@ -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"

View File

@ -0,0 +1,36 @@
{% extends "base.html" %}
{% load static %}
{% block css %}
<link rel="stylesheet" href="{% static 'css/navbar_style.css' %}">
<link rel="stylesheet" href="{% static 'css/style.css' %}">
<link href="https://fonts.googleapis.com/css2?family=Faster+One&display=swap" rel="stylesheet">
{% endblock css %}
{% block title %}
STRUMENTI
{% endblock title %}
{% block content %}
{% for bicchieri in lista_bicchieri %}
{% if forloop.first %} <div class="row"> {% endif %}
<div class="col-lg-4 my-3">
<div class="card h-100 my-1 border border-info">
<div class="card-img-top"><img src="{{ bicchieri.immagine_bicchieri.url }}" class="img-fluid" alt="{{ bicchieri.nome_bicchiere }}"></div>
<div class="card-body py-0">
<br>
<div class="text-center" id="color-for-glass">{{ bicchieri.nome_bicchiere }}</div>
<p class="mt-2 mb-0 py-3 text-center">{{ bicchieri.descrizione}}</p>
</div>
</div>
</div>
{% if forloop.counter|divisibleby:"3" or forloop.last %}
</div>
{% endif %}
{% if forloop.counter|divisibleby:"3" and not forloop.last %}
<div class="row">
{% endif %}
{% endfor %}
{% endblock content %}

View File

@ -9,8 +9,12 @@
{% block content %}
{% if cocktail %}
<h1 class="text-center">In totale nel nostro Salone Bar abbiamo trovato {{ cocktail.count }} cocktails {% if cocktail.count == 1 %} che corrisponde {% else %} che corrispondono {% endif %} alla tua ricerca <i class="fas fa-cocktail"></i> </h1>
<div class="card mt-3">
<div class="card-header">
<h1 class="text-center text-muted">In totale nel nostro Salone Bar abbiamo trovato {{ cocktail.count }} cocktails {% if cocktail.count == 1 %} che corrisponde {% else %} che corrispondono {% endif %} alla tua ricerca <i class="fas fa-cocktail"></i> </h1>
{% for cocktails in cocktail %}
</div>
</div>
<!-- {{ cocktail.ingredienti.all }}
{{ cocktail.nome_cocktail }} -->
{% if forloop.first %} <div class="row"> {% endif %}
@ -32,9 +36,38 @@
<div class="row">
{% endif %}
{% endfor %}
{% endif %}
{% if ingrediente and cocktail %}
<hr>
{% elif ingrediente or cocktail %}
{% else %}
<div class="card mt-3">
<div class="card-header"> <h1 class="text-center text-muted">Nessun Cocktail o Ingrediente trovato!</h1></div>
</div>
{% endif %}
{% if ingrediente %}
<h1>HELLO</h1>
<div class="card mt-3">
<div class="card-header"> <h1 class="text-center text-muted">Cocktails contenenti l'ingrediente "{{ querystring }}" : </h1></div>
</div>
{% for cocktails_ingrediente in ingrediente %}
{% if forloop.first %} <div class="row"> {% endif %}
<div class="col-lg-4 my-3">
<a href="{{ cocktails_ingrediente.get_absolute_url }}">
<div class="card h-100 my-1 border border-info">
<div class="card-img-top"><img src="{{ cocktails_ingrediente.immagine_cocktail.url }}" class="img-fluid" alt="{{ cocktails_ingrediente.nome_cocktail }}"></div>
<div class="text_on_image">{{ cocktails_ingrediente.nome_cocktail }}</div>
<div class="card-body py-0">
<p class="mt-2 mb-0 py-3 text-center">{{ cocktails_ingrediente.ingredienti.all|join:"," }}</p>
</div>
</div>
</a>
</div>
{% if forloop.counter|divisibleby:"3" or forloop.last %}
</div>
{% endif %}
{% if forloop.counter|divisibleby:"3" and not forloop.last %}
<div class="row">
{% endif %}
{% endfor %}
{% endif %}
{% endblock content %}

View File

@ -8,11 +8,48 @@
{% endblock css %}
{% block content %}
<div class="contained-img-bar mt-2">
<div class="text-contained-img-bar">In totale nel nostro Salone Bar abbiamo {{ lista_cocktail.count }} cocktails</div>
<!-- CAROUSEL CHE NON MI PIACE -->
<!-- <div id="carousel-cocktail" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carousel-cocktail" data-slide-to="0" class="active"></li>
<li data-target="#carousel-cocktail" data-slide-to="1"></li>
<li data-target="#carousel-cocktail" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
{% for cocktails in rand_cocktail %}
{% if forloop.first %}
<div class="carousel-item active">
<img src="{{ cocktails.immagine_cocktail.url }}" class="d-block w-100" alt="...">
<div class="carousel-caption d-none d-md-block">
<h5 class="text-carousel">{{ cocktails.nome_cocktail }}</h5>
<p class="text-carousel">{{ cocktails.ingredienti.all|join:"," }}</p>
</div>
</div>
{% else %}
<div class="carousel-item">
<img src="{{ cocktails.immagine_cocktail.url }}" class="d-block w-100" alt="...">
<div class="carousel-caption d-none d-md-block">
<h5 class="text-carousel">{{ cocktails.nome_cocktail }}</h5>
<p class="text-carousel">{{ cocktails.ingredienti.all|join:"," }}</p>
</div>
</div>
{% endif %}
{% endfor %}
<a class="carousel-control-prev" href="#carousel-cocktail" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Precedente</span>
</a>
<a class="carousel-control-next" href="#carousel-cocktail" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Successivo</span>
</a>
</div>
</div> -->
<!-- <h1 class="text-center">In totale nel nostro Salone Bar abbiamo {{ lista_cocktail.count }} <i class="fas fa-cocktail"></i> </h1> -->
{% for cocktail in lista_cocktail %}
<div class="card mt-3">
<div class="card-header"> <h1 class="text-center text-muted">LISTA COCKTAILS : </h1></div>
</div>
{% for cocktail in lista_cocktail %}
{% if forloop.first %} <div class="row"> {% endif %}
<div class="col-lg-4 my-3">
<a href="{{ cocktail.get_absolute_url }}">
@ -32,4 +69,8 @@
<div class="row">
{% endif %}
{% endfor %}
<div class="contained-img-bar mt-2">
<div class="text-contained-img-bar">In totale nel nostro Salone Bar abbiamo {{ lista_cocktail.count }} cocktails</div>
</div>
{% endblock content %}

View File

@ -0,0 +1,37 @@
{% extends "base.html" %}
{% load static %}
{% block css %}
<link rel="stylesheet" href="{% static 'css/navbar_style.css' %}">
<link rel="stylesheet" href="{% static 'css/style.css' %}">
<link href="https://fonts.googleapis.com/css2?family=Faster+One&display=swap" rel="stylesheet">
{% endblock css %}
{% block title %}
STRUMENTI
{% endblock title %}
{% block content %}
{% for strumenti in lista_strumenti %}
{% if forloop.first %} <div class="row"> {% endif %}
<div class="col-lg-4 my-3">
<div class="card h-100 my-1 border border-info">
<div class="card-img-top"><img src="{{ strumenti.immagine_strumenti.url }}" class="img-fluid" alt="{{ strumenti.nome_strumento }}"></div>
<div class="card-body py-0">
<br>
<div class="text-center" id="color-for-glass">{{ strumenti.nome_strumento }}</div>
<p class="mt-2 mb-0 py-3 text-center">{{ strumenti.descrizione}}</p>
</div>
</div>
</div>
{% if forloop.counter|divisibleby:"3" or forloop.last %}
</div>
{% endif %}
{% if forloop.counter|divisibleby:"3" and not forloop.last %}
<div class="row">
{% endif %}
{% endfor %}
{% endblock content %}

View File

@ -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/<nome_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")
]

View File

@ -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")

Binary file not shown.

View File

@ -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;
}