ajout gestion des relations
This commit is contained in:
parent
73920ec7c8
commit
a389f59473
29 changed files with 752 additions and 640 deletions
27
choix_entite.py
Executable file
27
choix_entite.py
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Sat May 16 09:36:14 2020
|
||||
|
||||
@author: francois
|
||||
"""
|
||||
|
||||
|
||||
def choix_entite(nom, message):
|
||||
return {
|
||||
'type': 'list',
|
||||
'name': nom,
|
||||
'message': message,
|
||||
'choices': [
|
||||
'adresse',
|
||||
'association',
|
||||
'coordonnees',
|
||||
'cours',
|
||||
'etablissement',
|
||||
'evenement',
|
||||
'licence',
|
||||
'logo',
|
||||
'personne',
|
||||
'projet'
|
||||
]
|
||||
}
|
59
entites.py
59
entites.py
|
@ -6,20 +6,57 @@ Created on Sat May 9 09:53:25 2020
|
|||
@author: francois
|
||||
"""
|
||||
|
||||
from questionary import prompt
|
||||
import questionary as qq
|
||||
import choix_entite as ce
|
||||
import questions_entite as qe
|
||||
import questions_relations as qr
|
||||
import dataset
|
||||
import pprint
|
||||
|
||||
choix_entite = prompt(qe.choix_entite)
|
||||
reponses = prompt(qe.questions_entite[choix_entite['type']])
|
||||
|
||||
print("Choix:\n"+str(choix_entite)+"\nRéponse:\n"+str(reponses))
|
||||
def saisie_entite():
|
||||
choix_entite = qq.prompt(ce.choix_entite('entite', 'entite'))['entite']
|
||||
pp.pprint(choix_entite)
|
||||
reponses = qq.prompt(qe.questions_entite[choix_entite])
|
||||
pp.pprint(reponses)
|
||||
try:
|
||||
table = db[choix_entite]
|
||||
table.insert(reponses)
|
||||
except Exception as e:
|
||||
print("Erreur dans l'insertion:"+str(e))
|
||||
|
||||
psql_string = 'postgresql://etatdulibre:etatdulibre@172.19.0.2/etatdulibre'
|
||||
|
||||
try:
|
||||
db = dataset.connect(psql_string)
|
||||
table = db[choix_entite['type']]
|
||||
table.insert(reponses)
|
||||
except:
|
||||
pass
|
||||
def saisie_relation():
|
||||
reponses = qq.prompt(qr.questions_relations)
|
||||
pp.pprint("Réponse:\n"+str(reponses))
|
||||
try:
|
||||
table = db[reponses['entite1']+"_"+reponses['entite2']]
|
||||
nom1 = db[reponses['entite1']].columns[0]
|
||||
nom2 = db[reponses['entite2']].columns[0]
|
||||
reponses_insert = {nom1: reponses['id_entite1'],
|
||||
nom2: reponses['id_entite2'],
|
||||
'description': reponses['description']}
|
||||
table.insert(reponses_insert)
|
||||
except Exception as e:
|
||||
print("Erreur dans l'insertion:"+str(e))
|
||||
|
||||
|
||||
psql_string = 'postgresql://etatdulibre:etatdulibre@172.20.0.2/etatdulibre'
|
||||
db = dataset.connect(psql_string)
|
||||
pp = pprint.PrettyPrinter(indent=4)
|
||||
|
||||
quitter = 0
|
||||
while quitter == 0:
|
||||
m0 = qq.select(
|
||||
"Entité ou relation?",
|
||||
choices=[
|
||||
'entite',
|
||||
'relation',
|
||||
'quitter'
|
||||
]).ask()
|
||||
if m0 == 'entite':
|
||||
saisie_entite()
|
||||
elif m0 == 'relation':
|
||||
saisie_relation()
|
||||
else:
|
||||
quitter = 1
|
||||
|
|
File diff suppressed because it is too large
Load diff
2
makefile
2
makefile
|
@ -10,7 +10,7 @@ run:
|
|||
clean:
|
||||
-docker stop etatdulibre pgadminlibre
|
||||
-docker container rm etatdulibre pgadminlibre
|
||||
-docker image rm etatdulibre
|
||||
-docker image rm etatdulibre pgadminlibre
|
||||
-docker network rm librenet
|
||||
-docker volume rm el_pgdata
|
||||
|
||||
|
|
|
@ -6,26 +6,6 @@ Created on Sat May 9 23:18:09 2020
|
|||
@author: francois
|
||||
"""
|
||||
|
||||
choix_entite = [
|
||||
{
|
||||
'type': 'list',
|
||||
'name': 'type',
|
||||
'message': 'entite',
|
||||
'choices': [
|
||||
'adresse',
|
||||
'association',
|
||||
'coordonnees',
|
||||
'cours',
|
||||
'etablissement',
|
||||
'evenement',
|
||||
'licence',
|
||||
'logo',
|
||||
'personne',
|
||||
'projet'
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
questions_entite = {
|
||||
'adresse': [
|
||||
{
|
||||
|
@ -88,7 +68,7 @@ questions_entite = {
|
|||
]
|
||||
},
|
||||
{
|
||||
'type': 'editor',
|
||||
'type': 'text',
|
||||
'name': 'description',
|
||||
'message': 'description'
|
||||
},
|
||||
|
@ -133,7 +113,7 @@ questions_entite = {
|
|||
'message': 'nom'
|
||||
},
|
||||
{
|
||||
'type': 'editor',
|
||||
'type': 'text',
|
||||
'name': 'description',
|
||||
'message': 'description'
|
||||
}
|
||||
|
@ -178,7 +158,7 @@ questions_entite = {
|
|||
'message': 'premiere_date'
|
||||
},
|
||||
{
|
||||
'type': 'editor',
|
||||
'type': 'text',
|
||||
'name': 'description',
|
||||
'message': 'description'
|
||||
}
|
||||
|
@ -221,7 +201,7 @@ questions_entite = {
|
|||
'message': 'nom'
|
||||
},
|
||||
{
|
||||
'type': 'editor',
|
||||
'type': 'text',
|
||||
'name': 'description',
|
||||
'message': 'description'
|
||||
}
|
||||
|
|
29
questions_relations.py
Executable file
29
questions_relations.py
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Sat May 16 09:06:41 2020
|
||||
|
||||
@author: francois
|
||||
"""
|
||||
|
||||
import choix_entite as ce
|
||||
|
||||
questions_relations = [
|
||||
ce.choix_entite('entite1', 'entite1'),
|
||||
{
|
||||
'type': 'input',
|
||||
'name': 'id_entite1',
|
||||
'message': 'id_entite1'
|
||||
},
|
||||
ce.choix_entite('entite2', 'entite2'),
|
||||
{
|
||||
'type': 'input',
|
||||
'name': 'id_entite2',
|
||||
'message': 'id_entite2'
|
||||
},
|
||||
{
|
||||
'type': 'input',
|
||||
'name': 'description',
|
||||
'message': 'description'
|
||||
}
|
||||
]
|
|
@ -14,7 +14,7 @@ CREATE TABLE adresse (
|
|||
date_saisie date NOT NULL
|
||||
);
|
||||
CREATE SEQUENCE adresse_serial_seq START 1 INCREMENT 1 ;
|
||||
ALTER TABLE adresse ALTER COLUMN serial SET NOT NULL;
|
||||
ALTER TABLE adresse ALTER COLUMN serial SET NOT 0;
|
||||
ALTER TABLE adresse ALTER COLUMN serial SET DEFAULT nextval('adresse_serial_seq');
|
||||
|
||||
--
|
||||
|
|
|
@ -15,7 +15,7 @@ CREATE TABLE association (
|
|||
date_fermeture date
|
||||
);
|
||||
CREATE SEQUENCE association_assoc_id_seq START 1 INCREMENT 1 ;
|
||||
ALTER TABLE association ALTER COLUMN assoc_id SET NOT NULL;
|
||||
ALTER TABLE association ALTER COLUMN assoc_id SET NOT 0;
|
||||
ALTER TABLE association ALTER COLUMN assoc_id SET DEFAULT nextval('association_assoc_id_seq');
|
||||
|
||||
--
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
CREATE TABLE association_adresse (
|
||||
assoc_id integer NOT NULL ,
|
||||
adresse_id integer NOT NULL
|
||||
adresse_id integer NOT NULL ,
|
||||
description character varying NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
CREATE TABLE association_coordonnees (
|
||||
assoc_id integer NOT NULL ,
|
||||
coord_id integer NOT NULL
|
||||
coord_id integer NOT NULL ,
|
||||
description character varying NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
CREATE TABLE association_logo (
|
||||
assoc_id integer NOT NULL ,
|
||||
logo_id integer NOT NULL
|
||||
logo_id integer NOT NULL ,
|
||||
description character varying NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
|
|
|
@ -10,7 +10,7 @@ CREATE TABLE coordonnees (
|
|||
coord_contenu character varying
|
||||
);
|
||||
CREATE SEQUENCE coordonnees_coord_id_seq START 1 INCREMENT 1 ;
|
||||
ALTER TABLE coordonnees ALTER COLUMN coord_id SET NOT NULL;
|
||||
ALTER TABLE coordonnees ALTER COLUMN coord_id SET NOT 0;
|
||||
ALTER TABLE coordonnees ALTER COLUMN coord_id SET DEFAULT nextval('coordonnees_coord_id_seq');
|
||||
|
||||
--
|
||||
|
|
|
@ -11,7 +11,7 @@ CREATE TABLE cours (
|
|||
description character varying
|
||||
);
|
||||
CREATE SEQUENCE cours_cours_id_seq START 1 INCREMENT 1 ;
|
||||
ALTER TABLE cours ALTER COLUMN cours_id SET NOT NULL;
|
||||
ALTER TABLE cours ALTER COLUMN cours_id SET NOT 0;
|
||||
ALTER TABLE cours ALTER COLUMN cours_id SET DEFAULT nextval('cours_cours_id_seq');
|
||||
|
||||
--
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
CREATE TABLE cours_coordonnees (
|
||||
cours_id integer NOT NULL ,
|
||||
coord_id integer NOT NULL
|
||||
coord_id integer NOT NULL ,
|
||||
description character varying NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
CREATE TABLE cours_etablissement (
|
||||
cours_id integer NOT NULL ,
|
||||
etabl_id integer NOT NULL
|
||||
etabl_id integer NOT NULL ,
|
||||
description character varying NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
|
|
|
@ -9,7 +9,7 @@ CREATE TABLE etablissement (
|
|||
nom character varying
|
||||
);
|
||||
CREATE SEQUENCE etablissement_etabl_id_seq START 1 INCREMENT 1 ;
|
||||
ALTER TABLE etablissement ALTER COLUMN etabl_id SET NOT NULL;
|
||||
ALTER TABLE etablissement ALTER COLUMN etabl_id SET NOT 0;
|
||||
ALTER TABLE etablissement ALTER COLUMN etabl_id SET DEFAULT nextval('etablissement_etabl_id_seq');
|
||||
|
||||
--
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
CREATE TABLE etablissement_adresse (
|
||||
etabl_id integer NOT NULL ,
|
||||
adresse_id integer NOT NULL
|
||||
adresse_id integer NOT NULL ,
|
||||
description character varying NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
CREATE TABLE etablissement_coordonnees (
|
||||
etabl_id integer NOT NULL ,
|
||||
coord_id integer NOT NULL
|
||||
coord_id integer NOT NULL ,
|
||||
description character varying NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
|
|
|
@ -15,7 +15,7 @@ CREATE TABLE evenement (
|
|||
description character varying
|
||||
);
|
||||
CREATE SEQUENCE evenement_event_id_seq START 1 INCREMENT 1 ;
|
||||
ALTER TABLE evenement ALTER COLUMN event_id SET NOT NULL;
|
||||
ALTER TABLE evenement ALTER COLUMN event_id SET NOT 0;
|
||||
ALTER TABLE evenement ALTER COLUMN event_id SET DEFAULT nextval('evenement_event_id_seq');
|
||||
|
||||
--
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
CREATE TABLE evenement_association (
|
||||
event_id integer NOT NULL ,
|
||||
assoc_id integer NOT NULL
|
||||
assoc_id integer NOT NULL ,
|
||||
description character varying NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
CREATE TABLE evenement_etablissement (
|
||||
event_id integer NOT NULL ,
|
||||
etabl_id integer NOT NULL
|
||||
etabl_id integer NOT NULL ,
|
||||
description character varying NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
|
|
|
@ -10,7 +10,7 @@ CREATE TABLE licence (
|
|||
sigle character varying
|
||||
);
|
||||
CREATE SEQUENCE licence_licence_id_seq START 1 INCREMENT 1 ;
|
||||
ALTER TABLE licence ALTER COLUMN licence_id SET NOT NULL;
|
||||
ALTER TABLE licence ALTER COLUMN licence_id SET NOT 0;
|
||||
ALTER TABLE licence ALTER COLUMN licence_id SET DEFAULT nextval('licence_licence_id_seq');
|
||||
|
||||
--
|
||||
|
|
|
@ -9,7 +9,7 @@ CREATE TABLE logo (
|
|||
logo_url character varying
|
||||
);
|
||||
CREATE SEQUENCE logo_logo_id_seq START 1 INCREMENT 1 ;
|
||||
ALTER TABLE logo ALTER COLUMN logo_id SET NOT NULL;
|
||||
ALTER TABLE logo ALTER COLUMN logo_id SET NOT 0;
|
||||
ALTER TABLE logo ALTER COLUMN logo_id SET DEFAULT nextval('logo_logo_id_seq');
|
||||
|
||||
--
|
||||
|
|
|
@ -10,7 +10,7 @@ CREATE TABLE personne (
|
|||
prenom character varying
|
||||
);
|
||||
CREATE SEQUENCE personne_pers_id_seq START 1 INCREMENT 1 ;
|
||||
ALTER TABLE personne ALTER COLUMN pers_id SET NOT NULL;
|
||||
ALTER TABLE personne ALTER COLUMN pers_id SET NOT 0;
|
||||
ALTER TABLE personne ALTER COLUMN pers_id SET DEFAULT nextval('personne_pers_id_seq');
|
||||
|
||||
--
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
CREATE TABLE personne_coordonnees (
|
||||
coord_id integer NOT NULL ,
|
||||
pers_id integer NOT NULL
|
||||
pers_id integer NOT NULL ,
|
||||
description character varying NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
|
|
|
@ -10,7 +10,7 @@ CREATE TABLE projet (
|
|||
description character varying
|
||||
);
|
||||
CREATE SEQUENCE projet_projet_id_seq START 1 INCREMENT 1 ;
|
||||
ALTER TABLE projet ALTER COLUMN projet_id SET NOT NULL;
|
||||
ALTER TABLE projet ALTER COLUMN projet_id SET NOT 0;
|
||||
ALTER TABLE projet ALTER COLUMN projet_id SET DEFAULT nextval('projet_projet_id_seq');
|
||||
|
||||
--
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
CREATE TABLE projet_association (
|
||||
projet_id integer NOT NULL ,
|
||||
assoc_id integer NOT NULL
|
||||
assoc_id integer NOT NULL ,
|
||||
description character varying NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
CREATE TABLE projet_coordonnees (
|
||||
projet_id integer NOT NULL ,
|
||||
coord_id integer NOT NULL
|
||||
coord_id integer NOT NULL ,
|
||||
description character varying NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
CREATE TABLE projet_licence (
|
||||
projet_id integer NOT NULL ,
|
||||
licence_id integer NOT NULL
|
||||
licence_id integer NOT NULL ,
|
||||
description character varying NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
|
|
Loading…
Reference in a new issue