You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.9 KiB
Python

import os
import re
import typing as t
import peewee
from flask import Blueprint, abort, render_template, request, send_from_directory
from playhouse.flask_utils import PaginatedQuery
from .app import APPPATH
from .modeles import Institution, State, House, Intervention_type, Production_place, Diplo_type, Document, Acte, Individual, Involved_in
RESULT_PAR_PAGES = 5
main = Blueprint("main", __name__, url_prefix="/")
@main.route("/")
def home():
"""home route"""
return render_template("home.html")
@main.route("/about/")
def about():
"""home route"""
return render_template("about.html")
@main.route("/actes/")
def corpora_all():
"""copora all route"""
return render_template("corpora_all.html")
@main.route("/actes/<house>") # dont put a slash at the end
def actes(house):
"""actes route"""
house_q = [t.id_house for t in House.select().where(
House.house_label == house)]
prince_q = [(t.name_indiv, t.id_indiv) for t in Individual.select().where(
(Individual.role_indiv == "prince")
&(Individual.house_indiv == house_q[0]))]
return render_template("corpus.html", house=house, princes=prince_q)
@main.route("/actes/<house>/<prince>") # don't put a slash at the end
def prince_corpus(house=None, prince=None):
"""copora prince route"""
prince_name = [[t.name_indiv, t.id_indiv] for t in Individual.select().where(
Individual.id_indiv == prince)]
actes=[t.involved_in_acte for t in Involved_in.select().where(
(Involved_in.involved_in_prince == prince)
&(Involved_in.invol_in_interv == 1))]
prince_acte = []
for acte in actes:
info = [(t.filename, t.date) for t in Acte.select().where(
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)
@main.route("/actes/<house>/<prince>/<acte_id>") # don't put a slash at the end
def acte(house=None, prince=None, acte_id=None):
"""acte route"""
q_prod = Involved_in.select().where(
(Involved_in.involved_in_prince == prince)
&(Involved_in.invol_in_interv == 1))
q_acte = Acte.select().where(Acte.filename == acte_id)
return render_template("acte.html", house=house, prince=prince, infos=q_acte)
@main.route("/contact")
def contact() -> t.Text:
"""Displays the Contact page"""
return render_template("contact.html", title="Contact")
@main.route("/termsofservice")
def terms() -> t.Text:
"""Displaysthe T&C page."""
return render_template("terms.html", title="Mentions légales")
@main.route("/privacy")
def privacy() -> t.Text:
"""Displays the privacy policy page."""
return render_template("privacy.html", title="Politique de confidentialité")