+ table intervention_type

main
jgenero 3 years ago
parent 77301a1329
commit d76ce8e913

@ -9,8 +9,8 @@ from lxml import etree
from tqdm import tqdm
from app.app import APPPATH, db
from app.data_actes import diplomatic_type, institution, state, houses
from app.modeles import Institution, State, House, Production_place, Diplo_type, Document, Acte, Individual, Produced_by, Signed_by
from app.data_actes import diplomatic_type, institution, state, houses, interventions
from app.modeles import Institution, State, House, Intervention_type, Production_place, Diplo_type, Document, Acte, Individual, Produced_by
db_cli = AppGroup("db")
@ -50,6 +50,11 @@ def _create_house(data_lst: list)-> None:
for data in tqdm(data_lst, desc="Populating House..."):
House.create(**data)
def _create_interv_type(data_lst: list)-> None:
"""create state table"""
for data in tqdm(data_lst, desc="Populating Intervention_type..."):
Intervention_type.create(**data)
def _create_diplo_type(data_lst: list)-> None:
"""create diplo type table"""
for data in tqdm(data_lst, desc="Populating Diplo_type..."):
@ -171,6 +176,7 @@ def _create_produced_by(xml_file: str, folder: str):
for acte in os.listdir(folder):
acte_q = [t.id_acte for t in Acte.select().where(
Acte.numb_acte == acte.replace(".xml", ""))]
# print("----")
# print(acte, "==", acte_q[0])
soup = make_soup(os.path.join(folder, acte))
princes = soup.sourceDesc.find_all("listPerson", {"type": "prince"})
@ -205,10 +211,10 @@ def _create_signed_by(xml_file: str, folder: str):
sign_q = [t.id_indiv for t in Individual.select().where(
Individual.name_indiv == signator)]
# print(signator, "==", sign_q)
sign_actes.append({"produced_by_acte": acte_q[0],
"produced_by_prince": sign_q[0]})
sign_actes.append({"signed_by_acte": acte_q[0],
"signed_by_prince": sign_q[0]})
for data in tqdm(sign_actes, desc="Populating Signed_by..."):
Produced_by.create(**data)
Signed_by.create(**data)
@db_cli.command()
@ -220,15 +226,16 @@ def init() -> None:
"Bourbon", "Brb_5_Charles_Ier")
print("Dropping existing DB...")
db.drop_tables([Institution, State, House, Production_place,
Diplo_type, Document, Acte, Individual,
Produced_by, Signed_by])
db.drop_tables([Institution, State, House, Intervention_type,
Production_place, Diplo_type, Document, Acte, Individual,
Produced_by])
print("Re-creating schema...")
db.create_tables([Institution, State, House, Production_place,
Diplo_type, Document, Acte, Individual, Produced_by, Signed_by])
db.create_tables([Institution, State, House, Intervention_type,
Production_place, Diplo_type, Document, Acte, Individual, Produced_by])
_create_institution(institution)
_create_state(state)
_create_house(houses)
_create_interv_type(interventions)
_create_diplo_type(diplomatic_type)
_create_produc_place(xml, xml_folder)
_create_doc(xml, xml_folder)
@ -241,4 +248,3 @@ def init() -> None:
print("!! name " + name + " not found in /app/static/csv/actors.csv")
_create_indiv(actors)
_create_produced_by(xml, xml_folder)
_create_signed_by(xml, xml_folder)

@ -2,5 +2,6 @@ from .diplo_type_data import diplomatic_type
from .institution_data import institution
from .state_data import state
from .house_data import houses
from .intervention_data import interventions
__all__ = ["diplomatic_type", "institution", "state", "houses"]
__all__ = ["diplomatic_type", "institution", "state", "houses", "interventions"]

@ -0,0 +1,5 @@
interventions = [
{"interv_label": "producer"},
{"interv_label": "signatory"},
{"interv_label": "witness"},
]

@ -1,3 +1,3 @@
from .data import Institution, State, House, Production_place, Diplo_type, Document, Acte, Individual, Produced_by, Signed_by
from .data import Institution, State, House, Intervention_type, Production_place, Diplo_type, Document, Acte, Individual, Produced_by
__all__ = ["Institution", "State", "House", "Production_place", "Diplo_type", "Document", "Acte", "Individual", "Produced_by", "Signed_by"]
__all__ = ["Institution", "State", "House", "Intervention_type", "Production_place", "Diplo_type", "Document", "Acte", "Individual", "Produced_by"]

@ -54,6 +54,14 @@ class House(BaseModel):
database = db
db_table = 'House'
class Intervention_type(BaseModel):
id_house = peewee.AutoField()
interv_label = peewee.TextField()
class Meta:
database = db
db_table = 'Intervention_type'
class Production_place(BaseModel):
id_place = peewee.AutoField()
placename = peewee.TextField()

@ -7,7 +7,7 @@ from flask import Blueprint, abort, render_template, request, send_from_director
from playhouse.flask_utils import PaginatedQuery
from .app import APPPATH
from .modeles import Institution, State, House, Production_place, Diplo_type, Document, Acte, Individual, Produced_by
from .modeles import Institution, State, House, Intervention_type, Production_place, Diplo_type, Document, Acte, Individual, Produced_by
RESULT_PAR_PAGES = 5

Loading…
Cancel
Save