diff --git a/Flask/Flask05/burlesco70/webapp/README.md b/Flask/Flask05/burlesco70/webapp/README.md index 559c303..8b2efc2 100644 --- a/Flask/Flask05/burlesco70/webapp/README.md +++ b/Flask/Flask05/burlesco70/webapp/README.md @@ -1,4 +1,13 @@ # Devlog + +# 5a settimana + +10/11/2020 +- base.html - Header Completa Boostrap invece che Navigation bar +- Prossime serate + +# 4a settimana + 03/11/2020 - Aggiunto menu corsi (lista/nuovo) - Aggiunta pagina lista corsi @@ -34,6 +43,7 @@ # TO DO App - Pagina dettaglio corso: aggiunta / cancellazione serata +- Immagine statica corso - Gestione serate - Nella home page fare vedere le 4 "prossime" serate diff --git a/Flask/Flask05/burlesco70/webapp/data.py b/Flask/Flask05/burlesco70/webapp/data.py index cc2683d..8c5ef20 100644 --- a/Flask/Flask05/burlesco70/webapp/data.py +++ b/Flask/Flask05/burlesco70/webapp/data.py @@ -1,4 +1,4 @@ -##Script to import data into DB with CRUD Operations +## Script to import data into DB with CRUD Operations from project.serate.models import Serata from project.corsi.models import Corso from project.tags.models import Tag @@ -47,13 +47,13 @@ "Andrea Guzzo", "Intermedio", "Corso in cinque serate del microframework Flask", - "immagine_flask" + "flask-icon.png" ) corsoFlask.tags = [t1, t2, t4, t5] # Relazione n:n TAG - CORSO corsoPygame = Corso( - "Pygame", "Mario Nardi", "Principiante", "Introduzione a Pygame" + "Pygame", "Mario Nardi", "Principiante", "Introduzione a Pygame", "pygame-icon.png" ) corsoPygame.tags = [t1, t3, t6] diff --git a/Flask/Flask05/burlesco70/webapp/project/corsi/__pycache__/models.cpython-36.pyc b/Flask/Flask05/burlesco70/webapp/project/corsi/__pycache__/models.cpython-36.pyc index c7a217f..e8a47fa 100644 Binary files a/Flask/Flask05/burlesco70/webapp/project/corsi/__pycache__/models.cpython-36.pyc and b/Flask/Flask05/burlesco70/webapp/project/corsi/__pycache__/models.cpython-36.pyc differ diff --git a/Flask/Flask05/burlesco70/webapp/project/data.sqlite b/Flask/Flask05/burlesco70/webapp/project/data.sqlite index 938223e..745e12b 100644 Binary files a/Flask/Flask05/burlesco70/webapp/project/data.sqlite and b/Flask/Flask05/burlesco70/webapp/project/data.sqlite differ diff --git a/Flask/Flask05/burlesco70/webapp/project/serate/__pycache__/models.cpython-36.pyc b/Flask/Flask05/burlesco70/webapp/project/serate/__pycache__/models.cpython-36.pyc index 2b871bd..9894432 100644 Binary files a/Flask/Flask05/burlesco70/webapp/project/serate/__pycache__/models.cpython-36.pyc and b/Flask/Flask05/burlesco70/webapp/project/serate/__pycache__/models.cpython-36.pyc differ diff --git a/Flask/Flask05/burlesco70/webapp/project/serate/__pycache__/routes.cpython-36.pyc b/Flask/Flask05/burlesco70/webapp/project/serate/__pycache__/routes.cpython-36.pyc index 046e0fa..2ebe595 100644 Binary files a/Flask/Flask05/burlesco70/webapp/project/serate/__pycache__/routes.cpython-36.pyc and b/Flask/Flask05/burlesco70/webapp/project/serate/__pycache__/routes.cpython-36.pyc differ diff --git a/Flask/Flask05/burlesco70/webapp/project/serate/models.py b/Flask/Flask05/burlesco70/webapp/project/serate/models.py index 91b8fec..29bc09b 100644 --- a/Flask/Flask05/burlesco70/webapp/project/serate/models.py +++ b/Flask/Flask05/burlesco70/webapp/project/serate/models.py @@ -1,12 +1,11 @@ from project import db -#from project.corsi.models import Corso # Tabella di relazione 1 Corso : N Serate class Serata(db.Model): __tablename__ = "serata" - __table_args__ = (db.UniqueConstraint("id", "data", name="contraint_serata"),) + __table_args__ = (db.UniqueConstraint("id", "data", name="constraint_serata"),) id = db.Column(db.Integer(), primary_key=True) nome = db.Column(db.String(255), nullable=False) diff --git a/Flask/Flask05/burlesco70/webapp/project/serate/routes.py b/Flask/Flask05/burlesco70/webapp/project/serate/routes.py index dd6dee2..c2d5db6 100644 --- a/Flask/Flask05/burlesco70/webapp/project/serate/routes.py +++ b/Flask/Flask05/burlesco70/webapp/project/serate/routes.py @@ -8,17 +8,36 @@ session, current_app, ) -from project.corsi.forms import CorsiForm, write_to_disk, SerataForm +#from project.serate.forms import SerataForm from project.serate.models import Serata from project.corsi.models import Corso from project import db from sqlalchemy import desc,asc +from datetime import datetime + # Define blueprint serate_blueprint = Blueprint( "serate", __name__, template_folder="templates", static_folder='../static' -) +) + +''' +Lista delle serate in ordine di data +''' +@serate_blueprint.route("/prossime", methods=["GET"]) +def prossime(): + # Filtro data futura, ordinamento per data + lista_serate = Serata.query.filter(Serata.data > datetime.now()).order_by(asc(Serata.data)).all() + # Creo una lista parallela dei corsi collegati alle serate + lista_corsi = [ Corso.query.filter_by(id=s.corso_id).first() for s in lista_serate ] + # Nel template non è possibile iterare su due liste, quindi zippo le due liste e le passo + zipped_data = zip(lista_serate, lista_corsi) + return render_template( + 'serate_prossime.html', + zipped_data=zipped_data + ) + diff --git a/Flask/Flask05/burlesco70/webapp/project/serate/templates/serate_prossime.html b/Flask/Flask05/burlesco70/webapp/project/serate/templates/serate_prossime.html new file mode 100644 index 0000000..421121c --- /dev/null +++ b/Flask/Flask05/burlesco70/webapp/project/serate/templates/serate_prossime.html @@ -0,0 +1,37 @@ +{% extends "base.html" %} +{% block content %} + +
+
+

Le prossime serate

+
+
+ + + + + + + + + + + {% for s,c in zipped_data %} + + + + + + + + {% endfor -%} + +
DataNome - DescrizioneLinks partecipazioneCorso
{{ s.data.strftime('%d/%m/%Y') }}{{ s.nome }} - {{ s.descrizione }} + {% if s.link_partecipazione %} + {{ s.link_partecipazione }} + {% else %} + Non disponibile + {% endif %} + {{ c.nome }}
+ + {% endblock %} \ No newline at end of file diff --git a/Flask/Flask05/burlesco70/webapp/project/templates/base.html b/Flask/Flask05/burlesco70/webapp/project/templates/base.html index 6e85610..33c0349 100644 --- a/Flask/Flask05/burlesco70/webapp/project/templates/base.html +++ b/Flask/Flask05/burlesco70/webapp/project/templates/base.html @@ -16,111 +16,236 @@ -
-
-
-
-
- Python Biella Group - - -
-