models.py
1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from sqlalchemy import Column, INTEGER, VARCHAR, ForeignKey, DATE
from sqlalchemy.orm import relationship
from database import ModelBase
from utils.models import Nacionalidad
class Sexo(ModelBase):
__tablename__ = 'tb_sexo'
id = Column('idSexo', INTEGER(), primary_key=True, nullable=False)
nombre = Column('Descripcion', VARCHAR(length=17), nullable=False)
abreviacion = Column('Mnemo', VARCHAR(length=1))
def __str__(self):
return f"{self.nombre}"
def __repr__(self):
return f"<Sexo: {self}>"
class Persona(ModelBase):
__tablename__ = 'tb_personas'
id = Column('idPersona', INTEGER(), primary_key=True, nullable=False)
apellido = Column('Apellido', VARCHAR(length=100), nullable=False)
nombres = Column('Nombres', VARCHAR(length=100), nullable=False)
cuil = Column('CUIL', VARCHAR(length=20))
documento = Column('Documento', INTEGER(), nullable=False)
fecha_nacimiento = Column('FechaNacimiento', DATE(), nullable=False)
domicilio = Column('Domicilio', VARCHAR(length=100))
codigo_postal = Column('CodPostal', VARCHAR(length=20))
telefono = Column('Telefono', VARCHAR(length=30))
email = Column('Email', VARCHAR(length=50))
es_discapacitado = Column('EsDiscapacitado', VARCHAR(length=1), nullable=False)
vive = Column('Vive', VARCHAR(length=1))
# Relaciones.
sexo_id = Column('Sexo', INTEGER(), ForeignKey('tb_sexo.idSexo'), nullable=False)
sexo = relationship('Sexo')
nacionalidad_id = Column('Nacionalidad', INTEGER(), ForeignKey('tb_Nacionalidad.idNacionalidad'))
nacionalidad = relationship(Nacionalidad)
# TODO: Agregar TipoDocumento, LocalidadNac
def __str__(self):
return f"{self.apellido}, {self.nombres}"
def __repr__(self):
return f"<Persona {self}>"