routes.py + template prince corpus : resolve pb in sorting acte by adding YYYY-MM-DD data to list

main
Jean-Damien 3 years ago
parent 38b57fd1af
commit 99209df196

@ -54,24 +54,27 @@ def prince_corpus(house=None, prince=None):
&(Involved_in.invol_in_interv == 1))] &(Involved_in.invol_in_interv == 1))]
prince_acte = [] prince_acte = []
for acte in actes: 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( t.diplo_type_acte, t.state_doc) for t in Acte.select(
).where(Acte.id_acte == acte)] ).where(Acte.id_acte == acte)]
place = [t.placename for t in Production_place.select().where( 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_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 = [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 : # avoid TypeError: 'tuple' object does not support item assignment :
infos_lst = list(info[0]) infos_lst = list(info[0])
infos_lst[3] = place[0] infos_lst[4] = place[0]
infos_lst[4] = diplo_t[0].replace("_", " ") infos_lst[5] = diplo_t[0].replace("_", " ")
infos_lst[5] = state[0] infos_lst[6] = state[0]
prince_acte.append(infos_lst) prince_acte.append(infos_lst)
prince_acte = sorted(prince_acte) prince_acte = sorted(prince_acte)
# print(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, return render_template("prince_corpus.html", houseS=house, duke_name=prince_name,
lst_id=prince_acte) lst_id=prince_acte)

@ -13,16 +13,16 @@
{% for id in lst_id %} {% for id in lst_id %}
<div class="entry-princier"> <div class="entry-princier">
<div class="title-princier"> <div class="title-princier">
<h3>{{id[0]}}</h3> <h3>{{id[1]}}</h3>
</div> </div>
<div class="pboly"> <div class="pboly">
<p class="chrono-p font-weight-bold"><a href="{{url_for('main.acte', prince=duke_name[0][1], acte_id=id[1])}}">{{id[2]}}.</a></p> <p class="chrono-p font-weight-bold"><a href="{{url_for('main.acte', prince=duke_name[0][1], acte_id=id[2])}}">{{id[3]}}.</a></p>
<p style="margin-bottom: 5%"> <p style="margin-bottom: 5%">
{% if id[3] != 'NS' %} {% if id[4] != 'NS' %}
<span class="badge badge-pill badge" style="background-color: #284AA7; color: white; font-size: small;">{{id[3]}}</span> <span class="badge badge-pill badge" style="background-color: #284AA7; color: white; font-size: small;">{{id[4]}}</span>
{% endif %} {% endif %}
<span class="badge badge-pill badge" style="background-color: #A7288A; color: white; font-size: small;">{{id[5]}}</span> <span class="badge badge-pill badge" style="background-color: #A7288A; color: white; font-size: small;">{{id[6]}}</span>
<span class="badge badge-pill badge" style="background-color: #A78528; color: white; font-size: small;">{{id[4]}}</span> <span class="badge badge-pill badge" style="background-color: #A78528; color: white; font-size: small;">{{id[5]}}</span>
</p> </p>
</div> </div>
</div> </div>

Loading…
Cancel
Save