Skip to content

Commit

Permalink
Merge pull request #6 from guivaloz:guivaloz/recibir-exhortos
Browse files Browse the repository at this point in the history
Guivaloz/recibir-exhortos
  • Loading branch information
guivaloz authored Apr 23, 2024
2 parents 0ae830b + ec71d97 commit 46bb7aa
Show file tree
Hide file tree
Showing 10 changed files with 245 additions and 0 deletions.
99 changes: 99 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,102 @@ Cuando NO se encuentra un registro el **status code** es **200** pero el **succe
### Respuesta fallida por ruta incorrecta

Cuando la ruta NO existe, simplemente ocurre un **status code** con error **404**.

## Configure Poetry

Por defecto, con **poetry** el entorno se guarda en un directorio en `~/.cache/pypoetry/virtualenvs`

Modifique para que el entorno se guarde en el mismo directorio que el proyecto

```bash
poetry config --list
poetry config virtualenvs.in-project true
```

Verifique que este en True

```bash
poetry config virtualenvs.in-project
```

## Instalacion

Instale el entorno virtual con **Python 3.11** y los paquetes necesarios

```bash
python3.11 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install wheel
poetry install
```

## Configuracion

Crear un archivo `.env` con las variables de entorno

```ini
# Base de datos
DB_HOST=127.0.0.1
DB_PORT=5432
DB_NAME=pjecz_plataforma_web
DB_USER=adminpjeczplataformaweb
DB_PASS=XXXXXXXXXXXXXXXX

# Origins
ORIGINS=http://localhost:3000

# Salt sirve para cifrar el ID con HashID, debe ser igual en la API
SALT=XXXXXXXXXXXXXXXX
```

Crear un archivo `.bashrc`

```bash
if [ -f ~/.bashrc ]
then
. ~/.bashrc
fi

if command -v figlet &> /dev/null
then
figlet Carina API key
else
echo "== Carina API key"
fi
echo

if [ -f .env ]
then
echo "-- Variables de entorno"
export $(grep -v '^#' .env | xargs)
# source .env && export $(sed '/^#/d' .env | cut -d= -f1)
echo " DB_HOST: ${DB_HOST}"
echo " DB_PORT: ${DB_PORT}"
echo " DB_NAME: ${DB_NAME}"
echo " DB_USER: ${DB_USER}"
echo " DB_PASS: ${DB_PASS}"
echo " ORIGINS: ${ORIGINS}"
echo " SALT: ${SALT}"
echo
export PGHOST=$DB_HOST
export PGPORT=$DB_PORT
export PGDATABASE=$DB_NAME
export PGUSER=$DB_USER
export PGPASSWORD=$DB_PASS
fi
```

## Arrancar

Ejecute el `.bashrc` para entrar al entorno virtual y cargar las variables de entorno

```bash
. .bashrc
```

Para arrancar el servidor ejecute

```bash
arrancar
```
Empty file added carina/core/estados/__init__.py
Empty file.
30 changes: 30 additions & 0 deletions carina/core/estados/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Estados, modelos
"""

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

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


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

# Nombre de la tabla
__tablename__ = "estados"

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

# Columnas
clave = Column(String(2), nullable=False, unique=True)
nombre = Column(String(256), nullable=False)

# Hijos
municipios = relationship("Municipio", back_populates="estado")

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

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

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


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

# Nombre de la tabla
__tablename__ = "exhortos"

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

# UUID identificador con el que el PJ exhortante identifica el exhorto que envía
exhorto_origen_id = Column(String(64), nullable=False, unique=True)

# Identificador INEGI del Municipio del Estado del PJ exhortado al que se quiere enviar el Exhorto
municipio_destino_id = Column(Integer, ForeignKey("municipios.id"), index=True, nullable=False)
municipio_destino = relationship("Municipio", back_populates="exhortos_destinos")

# Clave de la materia (el que se obtuvo en la consulta de materias del PJ exhortado) al que el Exhorto hace referencia
materia_id = Column(Integer, ForeignKey("materias.id"), index=True, nullable=False)
materia = relationship("Materia", back_populates="exhortos")

# Identificador INEGI del Estado de origen del Municipio donde se ubica el Juzgado del PJ exhortante
# estado_origen_id = Column(Integer, ForeignKey("estados.id"), index=True, nullable=False)
# estado_origen = relationship("Estado", back_populates="exhortos")

# Identificador INEGI del Municipio donde está localizado el Juzgado del PJ exhortante
municipio_origen_id = Column(Integer, ForeignKey("municipios.id"), index=True, nullable=False)
municipio_origen = relationship("Municipio", back_populates="exhortos_origenes")

# Identificador propio del Juzgado/Área que envía el Exhorto
juzgado_origen_id = Column(String(64))

# Nombre del Juzgado/Área que envía el Exhorto
juzgado_origen_nombre = Column(String(256), nullable=False)

# El número de expediente (o carpeta procesal, carpeta...) que tiene el asunto en el Juzgado de Origen
# numeroExpedienteOrigen string SI
numero_expediente_origen = Column(String(256), nullable=False)

# numeroOficioOrigen string NO
# tipoJuicioAsuntoDelitos string SI
# juezExhortante string NO
# partes PersonaParte[] NO
# fojas int SI
# diasResponder int SI
# tipoDiligenciacionNombre string NO
# fechaOrigen datetime NO
# observaciones string NO
# archivos ArchivoARecibir[] SI

@property
def estadoOrigenId(self):
"""ID del estado de origen"""
return self.municipio_origen.estado_id

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

@property
def municipioOrigenId(self):
"""ID del municipio de origen"""
return self.municipio_origen_id

def __repr__(self):
"""Representación"""
return f"<Exhorto {self.id}>"
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions carina/core/materias/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class Materia(Base, UniversalMixin):
nombre = Column(String(64), unique=True, nullable=False)
descripcion = Column(String(1024), nullable=False)

# Hijos
exhortos = relationship("Exhorto", back_populates="materia")

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

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

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


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

# Nombre de la tabla
__tablename__ = "municipios"

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

# Clave foránea
estado_id = Column(Integer, ForeignKey("estados.id"), index=True, nullable=False)
estado = relationship("Estado", back_populates="municipios")

# Columnas
clave = Column(String(3), nullable=False)
nombre = Column(String(256), nullable=False)

# Hijos
exhortos_destinos = relationship("Exhorto", back_populates="municipio_destino")
exhortos_origenes = relationship("Exhorto", back_populates="municipio_origen")

def __repr__(self):
"""Representación"""
return f"<Municipio {self.id}>"

0 comments on commit 46bb7aa

Please sign in to comment.