From dfaaeec975060f3ef07b7515651244ac5fbb098b Mon Sep 17 00:00:00 2001 From: jgenero Date: Fri, 21 Oct 2022 14:35:42 +0200 Subject: [PATCH] change acte url in routes + templates --- app/routes.py | 22 +++++++++++++++++++--- app/templates/prince_corpus.html | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/routes.py b/app/routes.py index 64c4034..f38bfc3 100644 --- a/app/routes.py +++ b/app/routes.py @@ -53,11 +53,15 @@ def prince_corpus(house=None, prince=None): Acte.id_acte == acte)] prince_acte.append(info[0]) prince_acte = sorted(prince_acte) - return render_template("prince_corpus.html", houseS=house, duke_name=prince_name, lst_id=prince_acte) + print(prince_acte) + + return render_template("prince_corpus.html", houseS=house, duke_name=prince_name, + lst_id=prince_acte) -@main.route("/actes///") # don't put a slash at the end +@main.route("/acte//") # don't put a slash at the end def acte(house=None, prince=None, acte_id=None): """acte route""" + print(prince) q_prod = Involved_in.select().where( (Involved_in.involved_in_prince == prince) &(Involved_in.invol_in_interv == 1)) @@ -79,6 +83,19 @@ def acte(house=None, prince=None, acte_id=None): state = [t.state_label for t in State.select().where( State.id_state == acte_state_id)] + + # if the acte if in another house's folder, + # change according to the begining of filename + # (i. e. the house abreviation) + print(acte_id) + dict_house = {'brb': 'Bourbon', 'bry': 'Berry', 'anj': 'Anjou'} + pattern_house = re.compile(r'([a-z]{3})_[a-z]+_[ivx]+_\d+(_\d+_\d+)?[a-z]') + name_house = re.search(pattern_house, acte_id) + house = dict_house[name_house.group(1)] + print(house) + + + source_doc = etree.parse( os.path.join(APPPATH, "static", "xml", house, acte_id + '.xml')) # remove namespace : @@ -91,7 +108,6 @@ def acte(house=None, prince=None, acte_id=None): xslt_doc = etree.parse(os.path.join(APPPATH, "static", "xsl", "actes_princiers.xsl")) xslt_transformer = etree.XSLT(xslt_doc) output_doc = xslt_transformer(source_doc) - print(output_doc) return render_template("acte.html", house=house, prince=prince, infos=q_acte, place=place[0], doc=doc[0][0], arch=inst[0], diplo=diplo_t[0].replace("_", " "), state=state[0], diff --git a/app/templates/prince_corpus.html b/app/templates/prince_corpus.html index 18163ab..3285686 100644 --- a/app/templates/prince_corpus.html +++ b/app/templates/prince_corpus.html @@ -3,7 +3,7 @@

Actes de {{duke_name[0][0]}}

{% for id in lst_id %} -
  • Acte du {{id[1]}}
  • +
  • Acte du {{id[1]}}
  • {% endfor %}
    {% endblock %} \ No newline at end of file