Skip to content

Commit

Permalink
Merge pull request #12 from guivaloz:guivaloz/exhortos-reestructura
Browse files Browse the repository at this point in the history
Se reestructoro la BD exhortos
  • Loading branch information
guivaloz authored May 8, 2024
2 parents 14174d9 + d8bd332 commit a44b61f
Show file tree
Hide file tree
Showing 20 changed files with 208 additions and 137 deletions.
2 changes: 2 additions & 0 deletions .vscode/fastapi-crud.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"\"\"\"",
"${1:Modulos} v4, CRUD (create, read, update, and delete)",
"\"\"\"",
"",
"from typing import Any",
"",
"from sqlalchemy.orm import Session",
Expand Down Expand Up @@ -45,6 +46,7 @@
"\"\"\"",
"${1:Modulos} v4, CRUD (create, read, update, and delete)",
"\"\"\"",
"",
"from typing import Any",
"",
"from sqlalchemy.orm import Session",
Expand Down
1 change: 1 addition & 0 deletions .vscode/fastapi-models.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"\"\"\"",
"${1:Modulos}, modelos",
"\"\"\"",
"",
"from collections import OrderedDict",
"",
"from sqlalchemy import Boolean, Column, Date, Enum, ForeignKey, Integer, String",
Expand Down
2 changes: 2 additions & 0 deletions .vscode/fastapi-paths.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"\"\"\"",
"${1:Modulos} v4, rutas (paths)",
"\"\"\"",
"",
"from typing import Annotated",
"",
"from fastapi import APIRouter, Depends, HTTPException, status",
Expand Down Expand Up @@ -63,6 +64,7 @@
"\"\"\"",
"${1:Modulos} v4, rutas (paths)",
"\"\"\"",
"",
"from typing import Annotated",
"",
"from fastapi import APIRouter, Depends, HTTPException, status",
Expand Down
10 changes: 4 additions & 6 deletions .vscode/fastapi-schemas.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"\"\"\"",
"${1:Modulos} v4, esquemas de pydantic",
"\"\"\"",
"from datetime import date",
"",
"from pydantic import BaseModel, ConfigDict",
"",
Expand All @@ -19,16 +18,15 @@
"\tid: int | None = None",
"\trelacion_id: int | None = None",
"\trelacion_nombre: str | None = None",
"\tfecha: date | None = None",
"\tclave: str | None = None",
"\tnombre: str | None = None",
"\tdescripcion: str | None = None",
"\tarchivo: str | None = None",
"\turl: str | None = None",
"\tmodel_config = ConfigDict(from_attributes=True)",
"",
"",
"class One${2:EsquemaOut}(${2:EsquemaOut}, OneBaseOut):",
"class One${2:EsquemaOut}(OneBaseOut):",
"\t\"\"\" Esquema para entregar un ${4:singular} \"\"\"",
"",
"\tdata: ${2:EsquemaOut} | None = None",
""
],
"description": "Contenido para schemas.py"
Expand Down
2 changes: 2 additions & 0 deletions carina/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .v4.distritos.paths import distritos
from .v4.entradas_salidas.paths import entradas_salidas
from .v4.estados.paths import estados
from .v4.exh_areas.paths import exh_areas
from .v4.exh_exhortos.paths import exh_exhortos
from .v4.exh_exhortos_archivos.paths import exh_exhortos_archivos
from .v4.exh_exhortos_partes.paths import exh_exhortos_partes
Expand Down Expand Up @@ -53,6 +54,7 @@ def create_app() -> FastAPI:
app.include_router(distritos)
app.include_router(entradas_salidas, include_in_schema=False)
app.include_router(estados)
app.include_router(exh_areas)
app.include_router(exh_exhortos)
app.include_router(exh_exhortos_archivos)
app.include_router(exh_exhortos_partes)
Expand Down
2 changes: 1 addition & 1 deletion carina/core/estados/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ class Estado(Base, UniversalMixin):

def __repr__(self):
"""Representación"""
return f"<Estado {self.id}>"
return f"<Estado {self.clave}>"
Empty file.
30 changes: 30 additions & 0 deletions carina/core/exh_areas/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Exh Areas, modelos
"""

from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import relationship

from lib.database import Base
from lib.universal_mixin import UniversalMixin


class ExhArea(Base, UniversalMixin):
"""ExhArea"""

# Nombre de la tabla
__tablename__ = "exh_areas"

# Clave primaria
id = Column(Integer, primary_key=True)

# Columnas
clave = Column(String(16), unique=True, nullable=False)
descripcion = Column(String(256), nullable=False)

# Hijos
exh_exhortos = relationship("ExhExhorto", back_populates="exh_area")

def __repr__(self):
"""Representación"""
return f"<ExhArea {self.clave}>"
101 changes: 25 additions & 76 deletions carina/core/exh_exhortos/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Exh Exhortos, modelos
"""

from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, func
from sqlalchemy import Column, DateTime, Enum, ForeignKey, Integer, String
from sqlalchemy.orm import relationship

from lib.database import Base
Expand All @@ -12,6 +12,16 @@
class ExhExhorto(Base, UniversalMixin):
"""ExhExhorto"""

ESTADOS = {
"PENDIENTE": "Pendiente",
"RECIBIDO": "Recibido",
}

REMITENTES = {
"INTERNO": "Interno",
"EXTERNO": "Externo",
}

# Nombre de la tabla
__tablename__ = "exh_exhortos"

Expand Down Expand Up @@ -64,7 +74,7 @@ class ExhExhorto(Base, UniversalMixin):
tipo_diligenciacion_nombre = Column(String(256))

# Fecha y hora en que el Poder Judicial exhortante registró que se envió el exhorto en su hora local. En caso de no enviar este dato, el Poder Judicial exhortado puede tomar su fecha hora local.
fecha_origen = Column(DateTime, server_default=func.now())
fecha_origen = Column(DateTime, nullable=False)

# Texto simple que contenga información extra o relevante sobre el exhorto.
observaciones = Column(String(1024))
Expand All @@ -75,80 +85,19 @@ class ExhExhorto(Base, UniversalMixin):
# ArchivoARecibir[] SI Colección de los datos referentes a los archivos que se van a recibir el Poder Judicial exhortado en el envío del Exhorto.
exh_exhortos_archivos = relationship("ExhExhortoArchivo", back_populates="exh_exhorto")

# Propiedades que se van a cargar despues
partes = []
archivos = []

@property
def exhortoOrigenId(self):
"""ID del exhorto de origen"""
return self.exhorto_origen_id

@property
def municipioDestinoId(self):
"""Clave INEGI del municipio de destino"""
return self.municipio_destino_id

@property
def materiaClave(self):
"""Clave de la materia"""
return self.materia.clave

@property
def estadoOrigenId(self):
"""Clave INEGI del estado de origen"""
return self.municipio_origen.estado.clave

@property
def municipioOrigenId(self):
"""Clave INEGI del municipio de origen"""
return self.municipio_origen.clave

@property
def juzgadoOrigenId(self):
"""ID del juzgado de origen"""
return self.juzgado_origen_id

@property
def juzgadoOrigenNombre(self):
"""Nombre del juzgado de origen"""
return self.juzgado_origen_nombre

@property
def numeroExpedienteOrigen(self):
"""Número de expediente de origen"""
return self.numero_expediente_origen

@property
def numeroOficioOrigen(self):
"""Número de oficio de origen"""
return self.numero_oficio_origen

@property
def tipoJuicioAsuntoDelitos(self):
"""Tipo de juicio"""
return self.tipo_juicio_asunto_delitos

@property
def juezExhortante(self):
"""Juez exhortante"""
return self.juez_exhortante

@property
def diasResponder(self):
"""Días para responder"""
return self.dias_responder

@property
def tipoDiligenciacionNombre(self):
"""Tipo de diligenciación"""
return self.tipo_diligenciacion_nombre

@property
def fechaOrigen(self):
"""Fecha de origen"""
return self.fecha_origen
# GUID/UUID... que sea único
folio_seguimiento = Column(String(64), nullable=False, unique=True)

# Área de recepción
exh_area_id = Column(Integer, ForeignKey("exh_areas.id"), index=True, nullable=False)
exh_area = relationship("ExhArea", back_populates="exh_exhortos")

# Estado de recepción del documento
estado = Column(Enum(*ESTADOS, name="exh_exhortos_estados", native_enum=False), nullable=True)

# Campo para saber si es un proceso interno o extorno
remitente = Column(Enum(*REMITENTES, name="exh_exhortos_remitentes", native_enum=False), nullable=True)

def __repr__(self):
"""Representación"""
return f"<ExhExhorto {self.exhorto_origen_id}>"
return f"<ExhExhorto {self.id}>"
30 changes: 8 additions & 22 deletions carina/core/exh_exhortos_archivos/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Exh Exhortos Archivos, modelos
"""

from sqlalchemy import Column, Enum, ForeignKey, Integer, String
from sqlalchemy import Column, DateTime, Enum, ForeignKey, Integer, String
from sqlalchemy.orm import relationship

from lib.database import Base
Expand Down Expand Up @@ -33,7 +33,7 @@ class ExhExhortoArchivo(Base, UniversalMixin):
# Hash SHA1 en hexadecimal que corresponde al archivo a recibir. Esto para comprobar la integridad del archivo.
hash_sha1 = Column(String(256))

# Hash SHA256 en hexadecimal que corresponde al archivo a recibir. Esto apra comprobar la integridad del archivo.
# Hash SHA256 en hexadecimal que corresponde al archivo a recibir. Esto para comprobar la integridad del archivo.
hash_sha256 = Column(String(256))

# Identificador del tipo de documento que representa el archivo:
Expand All @@ -45,28 +45,14 @@ class ExhExhortoArchivo(Base, UniversalMixin):
# URL del archivo en Google Storage
url = Column(String(512), nullable=False, default="", server_default="")

# Estado de la entrega del archivo
estado = Column(Enum(*ESTADOS, name="exh_exhortos_archivos_estados", native_enum=False), nullable=False)
# Estado de recepción del documento
estado = Column(Enum(*ESTADOS, name="exh_exhortos_archivos_estados", native_enum=False), nullable=True)

@property
def nombreArchivo(self):
"""Nombre del archivo"""
return self.nombre_archivo
# Tamaño del archivo recibido en bytes
tamano = Column(Integer, nullable=False)

@property
def hashSha1(self):
"""Hash SHA1"""
return self.hash_sha1

@property
def hashSha256(self):
"""Hash SHA256"""
return self.hash_sha256

@property
def tipoDocumento(self):
"""Tipo de documento"""
return self.tipo_documento
# Fecha y hora de recepción del documento
fecha_hora_recepcion = Column(DateTime, nullable=False)

def __repr__(self):
"""Representación"""
Expand Down
27 changes: 3 additions & 24 deletions carina/core/exh_exhortos_partes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,10 @@ class ExhExhortoParte(Base, UniversalMixin):
tipo_parte_nombre = Column(String(256))

@property
def apellidoPaterno(self):
"""Apellido paterno"""
return self.apellido_paterno
def nombre_completo(self):
"""Junta nombres, apellido_paterno y apellido materno"""
return self.nombre + " " + self.apellido_paterno + " " + self.apellido_materno

@property
def apellidoMaterno(self):
"""Apellido materno"""
return self.apellido_materno

@property
def esPersonaMoral(self):
"""Es persona moral"""
return self.es_persona_moral

@property
def tipoParte(self):
"""Tipo de parte"""
return self.tipo_parte

@property
def tipoParteNombre(self):
"""Nombre del tipo de parte"""
return self.tipo_parte_nombre

@property
def __repr__(self):
"""Representación"""
return f"<ExhExhortoParte {self.id}>"
2 changes: 1 addition & 1 deletion carina/core/municipios/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ class Municipio(Base, UniversalMixin):

def __repr__(self):
"""Representación"""
return f"<Municipio {self.id}>"
return f"<Municipio {self.estado.clave}{self.clave}>"
2 changes: 1 addition & 1 deletion carina/v4/autoridades/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
autoridades = APIRouter(prefix="/v4/autoridades", tags=["autoridades"])


@autoridades.get("/", response_model=CustomList[AutoridadOut])
@autoridades.get("", response_model=CustomList[AutoridadOut])
async def paginado_autoridades(
current_user: Annotated[UsuarioInDB, Depends(get_current_active_user)],
database: Annotated[Session, Depends(get_db)],
Expand Down
2 changes: 1 addition & 1 deletion carina/v4/distritos/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
distritos = APIRouter(prefix="/v4/distritos", tags=["distritos"])


@distritos.get("/", response_model=CustomList[DistritoOut])
@distritos.get("", response_model=CustomList[DistritoOut])
async def paginado_distritos(
current_user: Annotated[UsuarioInDB, Depends(get_current_active_user)],
database: Annotated[Session, Depends(get_db)],
Expand Down
Empty file added carina/v4/exh_areas/__init__.py
Empty file.
Loading

0 comments on commit a44b61f

Please sign in to comment.