From 23d7bc0f7a0a0dd9ceeab41e79420d03f962e43d Mon Sep 17 00:00:00 2001 From: coolneng Date: Wed, 25 Nov 2020 18:21:54 +0100 Subject: [PATCH] Add symptoms attribute and boolean/string parsing --- database/crud.py | 17 +++++++++++++++++ database/models.py | 7 ++++--- 2 files changed, 21 insertions(+), 3 deletions(-) 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)