diff --git a/database/crud.py b/database/crud.py index f3dc9fe..e75877b 100644 --- a/database/crud.py +++ b/database/crud.py @@ -56,3 +56,20 @@ def verify_code(id, code) -> bool: if valid_code: return True return False + + +def parse_boolean_string(value) -> bool: + """ + Converts string response to a boolean + """ + mapping = {r"[S-s][i-í]": True, r"[N-n]o": False} + return mapping[value] + + +def boolean_to_string(value) -> str: + """ + Converts boolean to string + """ + if value: + return "Sí" + return "No" diff --git a/database/models.py b/database/models.py index 27a2ea5..c89e005 100644 --- a/database/models.py +++ b/database/models.py @@ -1,5 +1,5 @@ from sqlalchemy import Column -from sqlalchemy.types import Date, Integer, String, Text +from sqlalchemy.types import Boolean, Date, Integer, String, Text from database import Base @@ -15,8 +15,9 @@ class User(Base): numero_de_documento = Column(String, nullable=False, unique=True) centro_academico = Column(String, nullable=False) correo_institucional = Column(String, nullable=False, unique=True) - tipo_alojamiento = Column(String) - tipo_caso = Column(String) + tipo_alojamiento = Column(Integer) + tipo_caso = Column(Integer) + sintomas = Column(Boolean) comienzo_aislamiento = Column(Date) fin_aislamiento = Column(Date) observaciones = Column(Text)