forked from ScoDoc/ScoDoc
Modifie menu saisie civilité état civil. Modifie contraintes INE/NIP en base.
This commit is contained in:
parent
90b4b4b5d6
commit
194e58419e
@ -70,7 +70,11 @@ class ScoDocModel:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def convert_dict_fields(cls, args: dict) -> dict:
|
def convert_dict_fields(cls, args: dict) -> dict:
|
||||||
"Convert fields in the given dict. No side effect."
|
"""Convert fields in the given dict. No side effect.
|
||||||
|
By default, do nothing, but is overloaded by some subclasses.
|
||||||
|
args: dict with args in application.
|
||||||
|
returns: dict to store in model's db.
|
||||||
|
"""
|
||||||
# virtual, by default, do nothing
|
# virtual, by default, do nothing
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
@ -49,10 +49,10 @@ class Identite(db.Model, models.ScoDocModel):
|
|||||||
"optionnel (si present, affiché à la place du nom)"
|
"optionnel (si present, affiché à la place du nom)"
|
||||||
civilite = db.Column(db.String(1), nullable=False)
|
civilite = db.Column(db.String(1), nullable=False)
|
||||||
|
|
||||||
# données d'état-civil. Si présent remplace les données d'usage dans les documents
|
# données d'état-civil. Si présent (non null) remplace les données d'usage dans les documents
|
||||||
# officiels (bulletins, PV): voir nomprenom_etat_civil()
|
# officiels (bulletins, PV): voir nomprenom_etat_civil()
|
||||||
civilite_etat_civil = db.Column(db.String(1), nullable=False, server_default="X")
|
civilite_etat_civil = db.Column(db.String(1), nullable=True)
|
||||||
prenom_etat_civil = db.Column(db.Text(), nullable=False, server_default="")
|
prenom_etat_civil = db.Column(db.Text(), nullable=True)
|
||||||
|
|
||||||
date_naissance = db.Column(db.Date)
|
date_naissance = db.Column(db.Date)
|
||||||
lieu_naissance = db.Column(db.Text())
|
lieu_naissance = db.Column(db.Text())
|
||||||
@ -313,6 +313,8 @@ class Identite(db.Model, models.ScoDocModel):
|
|||||||
def convert_dict_fields(cls, args: dict) -> dict:
|
def convert_dict_fields(cls, args: dict) -> dict:
|
||||||
"""Convert fields in the given dict. No other side effect.
|
"""Convert fields in the given dict. No other side effect.
|
||||||
If required dept_id is not specified, set it to the current dept.
|
If required dept_id is not specified, set it to the current dept.
|
||||||
|
args: dict with args in application.
|
||||||
|
returns: dict to store in model's db.
|
||||||
"""
|
"""
|
||||||
fs_uppercase = {"nom", "prenom", "prenom_etat_civil"}
|
fs_uppercase = {"nom", "prenom", "prenom_etat_civil"}
|
||||||
fs_empty_stored_as_nulls = {
|
fs_empty_stored_as_nulls = {
|
||||||
@ -698,7 +700,6 @@ def input_civilite(s: str) -> str:
|
|||||||
Raises ScoValueError if conversion fails.
|
Raises ScoValueError if conversion fails.
|
||||||
"""
|
"""
|
||||||
if not isinstance(s, str):
|
if not isinstance(s, str):
|
||||||
breakpoint()
|
|
||||||
raise ScoValueError("valeur invalide pour la civilité (chaine attendue)")
|
raise ScoValueError("valeur invalide pour la civilité (chaine attendue)")
|
||||||
s = s.upper().strip()
|
s = s.upper().strip()
|
||||||
if s in ("M", "M.", "MR", "H"):
|
if s in ("M", "M.", "MR", "H"):
|
||||||
@ -837,7 +838,10 @@ class Admission(db.Model, models.ScoDocModel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def convert_dict_fields(cls, args: dict) -> dict:
|
def convert_dict_fields(cls, args: dict) -> dict:
|
||||||
"Convert fields in the given dict. No other side effect"
|
"""Convert fields in the given dict. No other side effect.
|
||||||
|
args: dict with args in application.
|
||||||
|
returns: dict to store in model's db.
|
||||||
|
"""
|
||||||
fs_uppercase = {"bac", "specialite"}
|
fs_uppercase = {"bac", "specialite"}
|
||||||
args_dict = {}
|
args_dict = {}
|
||||||
for key, value in args.items():
|
for key, value in args.items():
|
||||||
|
@ -62,8 +62,10 @@ def format_etud_ident(etud):
|
|||||||
else:
|
else:
|
||||||
etud["prenom_etat_civil"] = ""
|
etud["prenom_etat_civil"] = ""
|
||||||
etud["civilite_str"] = format_civilite(etud["civilite"])
|
etud["civilite_str"] = format_civilite(etud["civilite"])
|
||||||
etud["civilite_etat_civil_str"] = format_civilite(
|
etud["civilite_etat_civil_str"] = (
|
||||||
etud.get("civilite_etat_civil", "X")
|
format_civilite(etud["civilite_etat_civil"])
|
||||||
|
if etud["civilite_etat_civil"]
|
||||||
|
else ""
|
||||||
)
|
)
|
||||||
# Nom à afficher:
|
# Nom à afficher:
|
||||||
if etud["nom_usuel"]:
|
if etud["nom_usuel"]:
|
||||||
@ -141,8 +143,8 @@ def format_civilite(civilite):
|
|||||||
"F": "Mme",
|
"F": "Mme",
|
||||||
"X": "",
|
"X": "",
|
||||||
}[civilite]
|
}[civilite]
|
||||||
except KeyError:
|
except KeyError as exc:
|
||||||
raise ScoValueError("valeur invalide pour la civilité: %s" % civilite)
|
raise ScoValueError(f"valeur invalide pour la civilité: {civilite}") from exc
|
||||||
|
|
||||||
|
|
||||||
def format_etat_civil(etud: dict):
|
def format_etat_civil(etud: dict):
|
||||||
@ -256,7 +258,11 @@ def identite_list(cnx, *a, **kw):
|
|||||||
else:
|
else:
|
||||||
o["annee_naissance"] = o["date_naissance"]
|
o["annee_naissance"] = o["date_naissance"]
|
||||||
o["civilite_str"] = format_civilite(o["civilite"])
|
o["civilite_str"] = format_civilite(o["civilite"])
|
||||||
o["civilite_etat_civil_str"] = format_civilite(o["civilite_etat_civil"])
|
o["civilite_etat_civil_str"] = (
|
||||||
|
format_civilite(o["civilite_etat_civil"])
|
||||||
|
if o["civilite_etat_civil"]
|
||||||
|
else ""
|
||||||
|
)
|
||||||
return objs
|
return objs
|
||||||
|
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ def _normalize_apo_fields(infolist):
|
|||||||
recode les champs: paiementinscription (-> booleen), datefinalisationinscription (date)
|
recode les champs: paiementinscription (-> booleen), datefinalisationinscription (date)
|
||||||
ajoute le champs 'paiementinscription_str' : 'ok', 'Non' ou '?'
|
ajoute le champs 'paiementinscription_str' : 'ok', 'Non' ou '?'
|
||||||
ajoute les champs 'etape' (= None) et 'prenom' ('') s'ils ne sont pas présents.
|
ajoute les champs 'etape' (= None) et 'prenom' ('') s'ils ne sont pas présents.
|
||||||
ajoute le champ 'civilite_etat_civil' (='X'), et 'prenom_etat_civil' (='') si non présent.
|
ajoute le champ 'civilite_etat_civil' (=''), et 'prenom_etat_civil' (='') si non présent.
|
||||||
"""
|
"""
|
||||||
for infos in infolist:
|
for infos in infolist:
|
||||||
if "paiementinscription" in infos:
|
if "paiementinscription" in infos:
|
||||||
@ -522,10 +522,7 @@ def _normalize_apo_fields(infolist):
|
|||||||
infos["prenom"] = ""
|
infos["prenom"] = ""
|
||||||
|
|
||||||
if "civilite_etat_civil" not in infos:
|
if "civilite_etat_civil" not in infos:
|
||||||
infos["civilite_etat_civil"] = "X"
|
infos["civilite_etat_civil"] = ""
|
||||||
|
|
||||||
if "civilite_etat_civil" not in infos:
|
|
||||||
infos["civilite_etat_civil"] = "X"
|
|
||||||
|
|
||||||
if "prenom_etat_civil" not in infos:
|
if "prenom_etat_civil" not in infos:
|
||||||
infos["prenom_etat_civil"] = ""
|
infos["prenom_etat_civil"] = ""
|
||||||
|
@ -582,10 +582,8 @@ def etud_info(etudid=None, fmt="xml"):
|
|||||||
"date_naissance_iso",
|
"date_naissance_iso",
|
||||||
):
|
):
|
||||||
d[a] = etud[a] # ne pas quoter car ElementTree.tostring quote déjà
|
d[a] = etud[a] # ne pas quoter car ElementTree.tostring quote déjà
|
||||||
d["civilite"] = etud["civilite_str"] # exception: ne sort pas la civilite brute
|
d["civilite"] = etud["civilite_str"] # exception: ne sort pas les civilités brutes
|
||||||
d["civilite_etat_civil"] = etud[
|
d["civilite_etat_civil"] = etud["civilite_etat_civil_str"]
|
||||||
"civilite_etat_civil_str"
|
|
||||||
] # exception: ne sort pas la civilite brute
|
|
||||||
d["sexe"] = d["civilite"] # backward compat pour anciens clients
|
d["sexe"] = d["civilite"] # backward compat pour anciens clients
|
||||||
d["photo_url"] = sco_photos.etud_photo_url(etud)
|
d["photo_url"] = sco_photos.etud_photo_url(etud)
|
||||||
|
|
||||||
@ -1472,8 +1470,8 @@ def _etudident_create_or_edit_form(edit):
|
|||||||
"civilite_etat_civil",
|
"civilite_etat_civil",
|
||||||
{
|
{
|
||||||
"input_type": "menu",
|
"input_type": "menu",
|
||||||
"labels": ["Homme", "Femme", "Autre/neutre"],
|
"labels": ["(identique à civilité)", "Homme", "Femme", "Autre/neutre"],
|
||||||
"allowed_values": ["M", "F", "X"],
|
"allowed_values": ["", "M", "F", "X"],
|
||||||
"title": "Civilité (état-civil)",
|
"title": "Civilité (état-civil)",
|
||||||
"explanation": "Si précisé: remplace la civilité d'usage dans les documents officiels",
|
"explanation": "Si précisé: remplace la civilité d'usage dans les documents officiels",
|
||||||
},
|
},
|
||||||
|
@ -65,6 +65,30 @@ def upgrade():
|
|||||||
)
|
)
|
||||||
batch_op.drop_constraint("identite_dept_id_code_ine_key", type_="unique")
|
batch_op.drop_constraint("identite_dept_id_code_ine_key", type_="unique")
|
||||||
batch_op.drop_constraint("identite_dept_id_code_nip_key", type_="unique")
|
batch_op.drop_constraint("identite_dept_id_code_nip_key", type_="unique")
|
||||||
|
batch_op.create_index(
|
||||||
|
"unique_dept_ine_except_null",
|
||||||
|
["dept_id", "code_ine"],
|
||||||
|
unique=True,
|
||||||
|
postgresql_where=sa.text("code_ine IS NOT NULL"),
|
||||||
|
)
|
||||||
|
batch_op.create_index(
|
||||||
|
"unique_dept_nip_except_null",
|
||||||
|
["dept_id", "code_nip"],
|
||||||
|
unique=True,
|
||||||
|
postgresql_where=sa.text("code_nip IS NOT NULL"),
|
||||||
|
)
|
||||||
|
batch_op.alter_column(
|
||||||
|
"civilite_etat_civil",
|
||||||
|
existing_type=sa.VARCHAR(length=1),
|
||||||
|
nullable=True,
|
||||||
|
existing_server_default=sa.text("'X'::character varying"),
|
||||||
|
)
|
||||||
|
batch_op.alter_column(
|
||||||
|
"prenom_etat_civil",
|
||||||
|
existing_type=sa.TEXT(),
|
||||||
|
nullable=True,
|
||||||
|
existing_server_default=sa.text("''::text"),
|
||||||
|
)
|
||||||
|
|
||||||
with op.batch_alter_table("adresse", schema=None) as batch_op:
|
with op.batch_alter_table("adresse", schema=None) as batch_op:
|
||||||
batch_op.alter_column("etudid", existing_type=sa.Integer(), nullable=False)
|
batch_op.alter_column("etudid", existing_type=sa.Integer(), nullable=False)
|
||||||
@ -108,6 +132,26 @@ def downgrade():
|
|||||||
batch_op.alter_column("boursier", existing_type=sa.BOOLEAN(), nullable=True)
|
batch_op.alter_column("boursier", existing_type=sa.BOOLEAN(), nullable=True)
|
||||||
batch_op.alter_column("dept_id", existing_type=sa.Integer(), nullable=True)
|
batch_op.alter_column("dept_id", existing_type=sa.Integer(), nullable=True)
|
||||||
batch_op.drop_column("admission_id")
|
batch_op.drop_column("admission_id")
|
||||||
|
batch_op.drop_index(
|
||||||
|
"unique_dept_nip_except_null",
|
||||||
|
postgresql_where=sa.text("code_nip IS NOT NULL"),
|
||||||
|
)
|
||||||
|
batch_op.drop_index(
|
||||||
|
"unique_dept_ine_except_null",
|
||||||
|
postgresql_where=sa.text("code_ine IS NOT NULL"),
|
||||||
|
)
|
||||||
|
batch_op.alter_column(
|
||||||
|
"prenom_etat_civil",
|
||||||
|
existing_type=sa.TEXT(),
|
||||||
|
nullable=False,
|
||||||
|
existing_server_default=sa.text("''::text"),
|
||||||
|
)
|
||||||
|
batch_op.alter_column(
|
||||||
|
"civilite_etat_civil",
|
||||||
|
existing_type=sa.VARCHAR(length=1),
|
||||||
|
nullable=False,
|
||||||
|
existing_server_default=sa.text("'X'::character varying"),
|
||||||
|
)
|
||||||
|
|
||||||
with op.batch_alter_table("admissions", schema=None) as batch_op:
|
with op.batch_alter_table("admissions", schema=None) as batch_op:
|
||||||
# batch_op.add_column(
|
# batch_op.add_column(
|
||||||
|
Loading…
Reference in New Issue
Block a user