From 99209df196d852d724c22deb60b5a7ef209ba31e Mon Sep 17 00:00:00 2001 From: Jean-Damien Date: Thu, 22 Dec 2022 17:41:37 +0100 Subject: [PATCH] routes.py + template prince corpus : resolve pb in sorting acte by adding YYYY-MM-DD data to list --- app/routes.py | 17 ++++++++++------- app/templates/prince_corpus.html | 12 ++++++------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/routes.py b/app/routes.py index faa8f33..083dd55 100644 --- a/app/routes.py +++ b/app/routes.py @@ -54,24 +54,27 @@ def prince_corpus(house=None, prince=None): &(Involved_in.invol_in_interv == 1))] prince_acte = [] for acte in actes: - info = [(t.date, t.filename, t.analysis, t.prod_place_acte, + info = [(t.date_time, t.date, t.filename, t.analysis, t.prod_place_acte, t.diplo_type_acte, t.state_doc) for t in Acte.select( ).where(Acte.id_acte == acte)] place = [t.placename for t in Production_place.select().where( - Production_place.id_place == info[0][3])] + Production_place.id_place == info[0][4])] diplo_t = [t.diplo_label for t in Diplo_type.select().where( - Diplo_type.id_diplo_type == info[0][4])] + Diplo_type.id_diplo_type == info[0][5])] state = [t.state_label for t in State.select().where( - State.id_state == info[0][5])] + State.id_state == info[0][6])] # avoid TypeError: 'tuple' object does not support item assignment : infos_lst = list(info[0]) - infos_lst[3] = place[0] - infos_lst[4] = diplo_t[0].replace("_", " ") - infos_lst[5] = state[0] + infos_lst[4] = place[0] + infos_lst[5] = diplo_t[0].replace("_", " ") + infos_lst[6] = state[0] prince_acte.append(infos_lst) prince_acte = sorted(prince_acte) # print(prince_acte) + + for item in prince_acte: + print("\n\n", item) return render_template("prince_corpus.html", houseS=house, duke_name=prince_name, lst_id=prince_acte) diff --git a/app/templates/prince_corpus.html b/app/templates/prince_corpus.html index afd0381..aa82911 100644 --- a/app/templates/prince_corpus.html +++ b/app/templates/prince_corpus.html @@ -13,16 +13,16 @@ {% for id in lst_id %}
-

{{id[0]}}

+

{{id[1]}}

-

{{id[2]}}.

+

{{id[3]}}.

- {% if id[3] != 'NS' %} - {{id[3]}} + {% if id[4] != 'NS' %} + {{id[4]}} {% endif %} - {{id[5]}} - {{id[4]}} + {{id[6]}} + {{id[5]}}