From 644cbda29029ac984dbb4085c0b7321e3a9c08e3 Mon Sep 17 00:00:00 2001 From: Jaenai Rugengande Ihimbazwe Date: Fri, 3 Dec 2021 03:22:46 +0100 Subject: [PATCH 1/5] Changement temp --- templates/bateau.html | 58 ++++++++++++++++----------------------- templates/expedition.html | 15 ++++++++-- templates/sauvees.html | 27 ++++++++++++------ templates/station.html | 15 ++++++++-- 4 files changed, 69 insertions(+), 46 deletions(-) diff --git a/templates/bateau.html b/templates/bateau.html index 3913bc5..1069fbf 100644 --- a/templates/bateau.html +++ b/templates/bateau.html @@ -10,63 +10,53 @@ histoire !--> - {{nom}} + {{nom}} - Sauveuteurs du dunkerquois + +
+ Proposer une modification +

{{nom}}}

+
+

{{HistoireBateau}}

+

- + - + - + - - + + - - + + - + - - - - - - - - - - - - - - - - - - - - - - +
NomNom {{NomBateau}}
ConstructeurConstructeur {{nom}}
DimensionsDimensions {{Dimensions}}
Installation{{Date}}Installation{{Date1}}
Condamnation{{Date}}Condamnation{{Date2}}
OrigineOrigine {{ville}}Nom{{NomBateau}}
Constructeur{{nom}}
Dimensions{{Dimensions}}
Installation{{Date}}
Condamnation{{Date}}
Origine{{ville}}
-

- {{HistoireBateau}} -

+ diff --git a/templates/expedition.html b/templates/expedition.html index 063bb35..c992fc5 100644 --- a/templates/expedition.html +++ b/templates/expedition.html @@ -6,18 +6,29 @@ evenement - {{siecle}} + {{siecle}}- Sauveuteurs du dunkerquois + +
+ Proposer une modification +

{{siecle}}

+
- + diff --git a/templates/sauvees.html b/templates/sauvees.html index 5ed9e51..951a3db 100644 --- a/templates/sauvees.html +++ b/templates/sauvees.html @@ -9,32 +9,43 @@ histoire - {{nom}}{{prenom}} + {{nom}}{{prenom}}- Sauveuteurs du dunkerquois + +
+ Proposer une modification + + + +

{{nom}}}{{prenom}}

+
+

{{histoire}}

+

DateDate {{Annee}}
- + - + - + - +
NomNom {{nom}}
PrenomPrenom {{prenom}}
DateDate {{date}}
PlacePlace {{place}}
-

- {{Histoire}} -

+ \ No newline at end of file diff --git a/templates/station.html b/templates/station.html index 69b773e..5e4f20b 100644 --- a/templates/station.html +++ b/templates/station.html @@ -7,18 +7,29 @@ evenement - {{nom}} + {{nom}} - Sauveuteurs du dunkerquois + +
+ Proposer une modification +

{{nom}}

+
- + From 1a8bbd536bc713ee07e5bb5d1c673ad46b7c3263 Mon Sep 17 00:00:00 2001 From: "theo@manjaro" Date: Fri, 3 Dec 2021 03:28:53 +0100 Subject: [PATCH 2/5] Ajout de recherche fonctionnelle --- app.py | 3 +-- pages.py | 28 ++++++++++++++++++++++++++++ templates/searchresults.html | 9 +++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 templates/searchresults.html diff --git a/app.py b/app.py index 794eaf0..360a122 100644 --- a/app.py +++ b/app.py @@ -13,8 +13,7 @@ def main(): @app.route('/search', methods=['GET', 'POST']) def search(): texte = request.form["search"] - print(texte) - return pages.main() + return pages.search(texte) @app.route('/sauveteurs/') @app.route('/sauveteur/') diff --git a/pages.py b/pages.py index 8e6fad7..7505180 100644 --- a/pages.py +++ b/pages.py @@ -1,5 +1,6 @@ from flask import render_template import definitions as lib +from difflib import SequenceMatcher dbname = "site.db" @@ -48,3 +49,30 @@ def sauveteur(idsauveteur): return render_template("sauveteur.html",**dico) else: return error() + +def search(texte): + sauveurs = lib.ex_sql(dbname,"SELECT * FROM sauveteur") + bateaux = lib.ex_sql(dbname,"SELECT * FROM bateau") + totals = sauveurs+bateaux + for i in totals: + i["score"] = 0 + for key in i.keys(): + if key!="score": + r = 1 + if key=="nom": + r = 3 + i["score"] += SequenceMatcher(None, texte, str(i[key])).ratio()*r + totals.sort(key=lambda x : x["score"]) + totals.reverse() + totals = totals[:8] + results = [] + for i in totals: + r = {} + if "ship_id" in i.keys(): + r["lien"] = "/bateaux/"+str(i["ship_id"]) + elif "personal_id" in i.keys(): + r["lien"] = "/sauveteurs/"+str(i["personal_id"]) + r["nom"] = i["nom"] + + results.append(r) + return render_template("searchresults.html",liste=results) diff --git a/templates/searchresults.html b/templates/searchresults.html new file mode 100644 index 0000000..178325b --- /dev/null +++ b/templates/searchresults.html @@ -0,0 +1,9 @@ +
    + + {% for result in liste %} + +
  • {{result.nom}}
  • + + {% endfor %} + +
From df6933959dc6e079a3a4b9d7ebcb6e99a2389a05 Mon Sep 17 00:00:00 2001 From: Jaenai Rugengande Ihimbazwe Date: Fri, 3 Dec 2021 03:32:10 +0100 Subject: [PATCH 3/5] =?UTF-8?q?Maj=20temp=20bateau,=20exped,=20sauv=C3=A9e?= =?UTF-8?q?s,=20stations.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/bateau.html | 62 +++++++++++++++++++++++++++++++++++++++ templates/expedition.html | 43 +++++++++++++++++++++++++++ templates/sauvees.html | 51 ++++++++++++++++++++++++++++++++ templates/station.html | 44 +++++++++++++++++++++++++++ 4 files changed, 200 insertions(+) create mode 100644 templates/bateau.html create mode 100644 templates/expedition.html create mode 100644 templates/sauvees.html create mode 100644 templates/station.html diff --git a/templates/bateau.html b/templates/bateau.html new file mode 100644 index 0000000..1069fbf --- /dev/null +++ b/templates/bateau.html @@ -0,0 +1,62 @@ + + + + + {{nom}} - Sauveuteurs du dunkerquois + + + + + +
+ Proposer une modification + + + + +

{{nom}}}

+
+

{{HistoireBateau}}

+

+

DateDate {{Annee}}
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Nom{{NomBateau}}
Constructeur{{nom}}
Dimensions{{Dimensions}}
Installation{{Date1}}
Condamnation{{Date2}}
Origine{{ville}}
+ + + + diff --git a/templates/expedition.html b/templates/expedition.html new file mode 100644 index 0000000..c992fc5 --- /dev/null +++ b/templates/expedition.html @@ -0,0 +1,43 @@ + + + + + + {{siecle}}- Sauveuteurs du dunkerquois + + + + +
+ Proposer une modification + +

{{siecle}}

+
+ + + + + + + + + + + +
Date{{Annee}}
{{Evenement}}{{Evenement}}
+ \ No newline at end of file diff --git a/templates/sauvees.html b/templates/sauvees.html new file mode 100644 index 0000000..951a3db --- /dev/null +++ b/templates/sauvees.html @@ -0,0 +1,51 @@ + + + + + + {{nom}}{{prenom}}- Sauveuteurs du dunkerquois + + + + +
+ Proposer une modification + +

{{nom}}}{{prenom}}

+
+

{{histoire}}

+

+ + + + + + + + + + + + + + + + + +
Nom{{nom}}
Prenom{{prenom}}
Date{{date}}
Place{{place}}
+ + + + \ No newline at end of file diff --git a/templates/station.html b/templates/station.html new file mode 100644 index 0000000..5e4f20b --- /dev/null +++ b/templates/station.html @@ -0,0 +1,44 @@ + + + + + + {{nom}} - Sauveuteurs du dunkerquois + + + +

+
+ Proposer une modification + +

{{nom}}

+
+ + + + + + + + + + + +
Date{{Annee}}
{{Evenement}}{{Evenement}}
+ \ No newline at end of file From dfbf62d651f618875f69eedcc46cda91dff16e4e Mon Sep 17 00:00:00 2001 From: Antoine Waehren Date: Fri, 3 Dec 2021 03:49:24 +0100 Subject: [PATCH 4/5] =?UTF-8?q?Finalisation=20de=20la=20page=20des=20r?= =?UTF-8?q?=C3=A9sultats=20de=20recherche.=20M=C3=A0j=20styles=20CSS.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/style.css | 4 ++++ templates/search.html | 23 ------------------- templates/searchresults.html | 38 ++++++++++++++++++++++++-------- templates/searchresults.html.old | 9 ++++++++ 4 files changed, 42 insertions(+), 32 deletions(-) delete mode 100644 templates/search.html create mode 100644 templates/searchresults.html.old diff --git a/static/style.css b/static/style.css index 84f2a2e..75b7dcc 100644 --- a/static/style.css +++ b/static/style.css @@ -45,6 +45,10 @@ table, tr, td { font-size: 30px; } +#searchresults { + width: 75%; +} + .searchbar { float: right; padding-right: 20px; diff --git a/templates/search.html b/templates/search.html deleted file mode 100644 index 3161654..0000000 --- a/templates/search.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - {{nom}} {{prenom}} - Sauveuteurs du dunkerquois - - - - - -
- - - - diff --git a/templates/searchresults.html b/templates/searchresults.html index 178325b..c0650b6 100644 --- a/templates/searchresults.html +++ b/templates/searchresults.html @@ -1,9 +1,29 @@ -
    - - {% for result in liste %} - -
  • {{result.nom}}
  • - - {% endfor %} - -
+ + + + {{nom}} {{prenom}} - Sauveuteurs du dunkerquois + + + + + +
+ +

Résultats de la recherche :

+
+ + {% for result in liste %} + + + + {% endfor %} +
{{result.nom}}
+
+ + diff --git a/templates/searchresults.html.old b/templates/searchresults.html.old new file mode 100644 index 0000000..178325b --- /dev/null +++ b/templates/searchresults.html.old @@ -0,0 +1,9 @@ +
    + + {% for result in liste %} + +
  • {{result.nom}}
  • + + {% endfor %} + +
From cd80455aefe2c0db3943a730edec0a17028f90d2 Mon Sep 17 00:00:00 2001 From: Antoine Waehren Date: Fri, 3 Dec 2021 03:51:37 +0100 Subject: [PATCH 5/5] Suppression du fichier searchresults de test. --- templates/searchresults.html.old | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 templates/searchresults.html.old diff --git a/templates/searchresults.html.old b/templates/searchresults.html.old deleted file mode 100644 index 178325b..0000000 --- a/templates/searchresults.html.old +++ /dev/null @@ -1,9 +0,0 @@ -
    - - {% for result in liste %} - -
  • {{result.nom}}
  • - - {% endfor %} - -