Skip to content

Commit

Permalink
Merge pull request #975 from ricval/Exhortos-Vistas
Browse files Browse the repository at this point in the history
Exhortos - vistas
  • Loading branch information
guivaloz authored May 2, 2024
2 parents d2fcf7a + 8a235f6 commit 2be5d79
Show file tree
Hide file tree
Showing 8 changed files with 431 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{% extends 'layouts/app.jinja2' %}
{% import 'macros/detail.jinja2' as detail %}
{% import 'macros/modals.jinja2' as modals %}
{% import 'macros/topbar.jinja2' as topbar %}

{% block title %}Exhorto{% endblock %}

{% block topbar_actions %}
{% call topbar.page_buttons('Exhorto ' + exh_exhorto.exhorto_origen_id) %}
{{ topbar.button_previous('Exhortos', url_for('exh_exhortos.list_active')) }}
{% endcall %}
{% endblock %}

{% block content %}
{% call detail.card(estatus=exh_exhorto.estatus) %}
{{ detail.label_value('ID', exh_exhorto.id) }}
{{ detail.label_value('UUID', exh_exhorto.exhorto_origen_id) }}
{% if municipio_destino %}
{% if current_user.can_view('MUNICIPIOS') %}
{{ detail.label_value('Municipio Destino', municipio_destino.nombre + ', ' + municipio_destino.estado.nombre, url_for('municipios.detail', municipio_id=municipio_destino.id)) }}
{% else %}
{{ detail.label_value('Municipio Destino', municipio_destino.nombre + ', ' + municipio_destino.estado.nombre) }}
{% endif %}
{% else %}
{{ detail.label_value('Municipio Destino', 'NO DEFINIDO') }}
{% endif %}
{{ detail.label_value('Materia', exh_exhorto.materia.nombre) }}
{% if current_user.can_view('MUNICIPIOS') %}
{{ detail.label_value('Municipio Origen', exh_exhorto.municipio_origen.nombre + ', ' + exh_exhorto.municipio_origen.estado.nombre, url_for('municipios.detail', municipio_id=exh_exhorto.municipio_origen_id)) }}
{% else %}
{{ detail.label_value('Municipio Origen', exh_exhorto.municipio_origen.nombre + ', ' + exh_exhorto.municipio_origen.estado.nombre) }}
{% endif %}
{{ detail.label_value('No. Expediente Origen', exh_exhorto.numero_expediente_origen) }}
{{ detail.label_value('No. Oficio Origen', exh_exhorto.numero_oficio_origen) }}
{{ detail.label_value('Tipo de juicio', exh_exhorto.tipo_juicio_asunto_delitos) }}
{{ detail.label_value('Juez Exhortante', exh_exhorto.juez_exhortante) }}
{{ detail.label_value('Fojas', exh_exhorto.fojas) }}
{{ detail.label_value('Días en responder', exh_exhorto.dias_responder) }}
{{ detail.label_value('Tipo de diligenciación', exh_exhorto.tipo_diligenciacion_nombre) }}
{{ detail.label_value('Fecha de origen', exh_exhorto.fecha_origen) }}
{{ detail.label_value('Observaciones', exh_exhorto.observaciones) }}
{% endcall %}
{# Listado de Partes #}
{% call detail.card("Partes")%}
<table id="exh_exhortos_partes_datatable" class="table display nowrap" style="width:100%">
<thead>
<tr>
<th>Nombre</th>
<th>Tipo</th>
</tr>
</thead>
</table>
{% endcall %}
{# Listado de Archivos #}
{% call detail.card("Archivos")%}
<table id="exh_exhortos_archivos_datatable" class="table display nowrap" style="width:100%">
<thead>
<tr>
<th>Nombre</th>
<th>Tipo</th>
<th>URL</th>
</tr>
</thead>
</table>
{% endcall %}
{% endblock %}

{% block custom_javascript %}
<script src="/static/js/datatables-constructor.js"></script>
<script src="/static/js/datatables-filtros.js"></script>
{# Tabla de Partes #}
<script>
const constructorDataTable = new ConfigDataTable( '{{ csrf_token() }}' );
</script>
<script>
// DataTable Partes
let configDTPartes = constructorDataTable.config();
configDTPartes['ajax']['url'] = '/exh_exhortos_partes/datatable_json';
configDTPartes['ajax']['data'] = {'estatus':'A', 'exh_exhorto_id':{{exh_exhorto.id}}};
configDTPartes['columns'] = [
{ data: 'nombre_completo' },
{ data: 'tipo_parte' },
];
// Filtros Exhortos Partes
const filtrosPartes = new FiltrosDataTable('#exh_exhortos_partes_datatable', configDTPartes);
filtrosPartes.precargar();
</script>
{# Tabla de Archivos #}
<script>
// DataTable Archivos
let configDTArchivos = constructorDataTable.config();
configDTArchivos['ajax']['url'] = '/exh_exhortos_archivos/datatable_json';
configDTArchivos['ajax']['data'] = {'estatus':'A', 'exh_exhorto_id':{{exh_exhorto.id}}};
configDTArchivos['columns'] = [
{ data: 'nombre_archivo' },
{ data: 'tipo_documento' },
{ data: 'url' },
];
configDTArchivos['columnDefs'] = [
{
targets: 2, // url
data: null,
render: function(data, type, row, meta) {
return '<a href="' + data + '" target="blank">Ver <span class="iconify" data-icon="mdi:open-in-new"></span></a>';
}
}
];
// Filtros Exhortos Archivos
const filtrosArchivos = new FiltrosDataTable('#exh_exhortos_archivos_datatable', configDTArchivos);
filtrosArchivos.precargar();
</script>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{% extends 'layouts/app.jinja2' %}
{% import 'macros/list.jinja2' as list %}
{% import 'macros/topbar.jinja2' as topbar %}

{% block title %}Exhortos{% endblock %}

{% block topbar_actions %}
{% call topbar.page_buttons(titulo) %}
{% if current_user.can_view('EXH EXHORTOS PARTES') %}
{{ topbar.button('Partes', url_for('exh_exhortos_partes.list_active'), "mdi:account-multiple") }}
{% endif %}
{% if current_user.can_view('EXH EXHORTOS ARCHIVOS') %}
{{ topbar.button('Archivos', url_for('exh_exhortos_archivos.list_active'), "mdi:file-document-multiple") }}
{% endif %}
{% endcall %}
{% endblock %}

{% block content %}
{% call list.card() %}
<table id="exh_exhortos_datatable" class="table display nowrap" style="width:100%">
<thead>
<tr>
<th>ID</th>
<th>UUID</th>
<th>Juzgado ID</th>
<th>Juzgado Nombre</th>
</tr>
</thead>
</table>
{% endcall %}
{% endblock %}

{% block custom_javascript %}
{{ list.config_datatable() }}
<script>
configDataTable['ajax']['url'] = '/exh_exhortos/datatable_json';
configDataTable['ajax']['data'] = {{ filtros }};
configDataTable['columns'] = [
{ data: 'detalle' },
{ data: 'UUID' },
{ data: 'juzgado_origen' },
{ data: 'juzgado_nombre' },
];
configDataTable['columnDefs'] = [
{
targets: 0, // detalle
data: null,
render: function(data, type, row, meta) {
return '<a href="' + data.url + '">' + data.id + '</a>';
}
}
];
$('#exh_exhortos_datatable').DataTable(configDataTable);
</script>
{% endblock %}
58 changes: 57 additions & 1 deletion plataforma_web/blueprints/exh_exhortos/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from plataforma_web.blueprints.permisos.models import Permiso
from plataforma_web.blueprints.usuarios.decorators import permission_required
from plataforma_web.blueprints.exh_exhortos.models import ExhExhorto
from plataforma_web.blueprints.municipios.models import Municipio

MODULO = "EXH EXHORTOS"

Expand All @@ -24,4 +25,59 @@
@login_required
@permission_required(MODULO, Permiso.VER)
def before_request():
"""Permiso por defecto"""
"""Permiso por defecto"""


@exh_exhortos.route('/exh_exhortos/datatable_json', methods=['GET', 'POST'])
def datatable_json():
"""DataTable JSON para listado de Exh Exhortos"""
# Tomar parámetros de Datatables
draw, start, rows_per_page = get_datatable_parameters()
# Consultar
consulta = ExhExhorto.query
if 'estatus' in request.form:
consulta = consulta.filter_by(estatus=request.form['estatus'])
else:
consulta = consulta.filter_by(estatus='A')
registros = consulta.order_by(ExhExhorto.id).offset(start).limit(rows_per_page).all()
total = consulta.count()
# Elaborar datos para DataTable
data = []
for resultado in registros:
data.append(
{
'detalle': {
'id': resultado.id,
'url': url_for('exh_exhortos.detail', exh_exhorto_id=resultado.id),
},
'UUID': resultado.exhorto_origen_id,
'juzgado_origen': resultado.juzgado_origen_id,
'juzgado_nombre': resultado.juzgado_origen_nombre,
}
)
# Entregar JSON
return output_datatable_json(draw, total, data)


@exh_exhortos.route('/exh_exhortos')
def list_active():
"""Listado de Exh Exhortos activos"""
return render_template(
'exh_exhortos/list.jinja2',
filtros=json.dumps({'estatus': 'A'}),
titulo='Exhortos',
estatus='A',
)


@exh_exhortos.route('/exh_exhortos/<int:exh_exhorto_id>')
def detail(exh_exhorto_id):
""" Detalle de un Exh Exhorto """
exh_exhorto = ExhExhorto.query.get_or_404(exh_exhorto_id)

# Localiza el municipio destino por su ID
municipio_destino = Municipio.query.filter_by(id=exh_exhorto.municipio_destino_id).filter_by(estatus='A').first()

# Renderiza la página de detalle
return render_template('exh_exhortos/detail.jinja2', exh_exhorto=exh_exhorto, municipio_destino=municipio_destino)

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{% extends 'layouts/app.jinja2' %}
{% import 'macros/list.jinja2' as list %}
{% import 'macros/topbar.jinja2' as topbar %}

{% block title %}Exhortos Archivos{% endblock %}

{% block topbar_actions %}
{% call topbar.page_buttons(titulo) %}
{% if current_user.can_view('EXH EXHORTOS') %}
{{ topbar.button('Exhortos', url_for('exh_exhortos.list_active'), 'mdi:email-fast') }}
{% endif %}
{% if current_user.can_view('EXH EXHORTOS PARTES') %}
{{ topbar.button('Partes', url_for('exh_exhortos_partes.list_active'), 'mdi:account-multiple') }}
{% endif %}
{% endcall %}
{% endblock %}

{% block content %}
{% call list.card() %}
<table id="exh_exhortos_archivos_datatable" class="table display nowrap" style="width:100%">
<thead>
<tr>
<th>Nombre</th>
<th>Tipo</th>
<th>URL</th>
</tr>
</thead>
</table>
{% endcall %}
{% endblock %}

{% block custom_javascript %}
{{ list.config_datatable() }}
<script>
configDataTable['ajax']['url'] = '/exh_exhortos_archivos/datatable_json';
configDataTable['ajax']['data'] = {{ filtros }};
configDataTable['columns'] = [
{ data: 'nombre_archivo' },
{ data: 'tipo_documento' },
{ data: 'url' },
];
configDataTable['columnDefs'] = [
{
targets: 2, // url
data: null,
render: function(data, type, row, meta) {
return '<a href="' + data + '" target="blank">Ver <span class="iconify" data-icon="mdi:open-in-new"></span></a>';
}
}
];
$('#exh_exhortos_archivos_datatable').DataTable(configDataTable);
</script>
{% endblock %}
50 changes: 49 additions & 1 deletion plataforma_web/blueprints/exh_exhortos_archivos/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,52 @@
@login_required
@permission_required(MODULO, Permiso.VER)
def before_request():
"""Permiso por defecto"""
"""Permiso por defecto"""

@exh_exhortos_archivos.route('/exh_exhortos_archivos/datatable_json', methods=['GET', 'POST'])
def datatable_json():
"""DataTable JSON para listado de Exh Exhortos Archivos"""
# Tomar parámetros de Datatables
draw, start, rows_per_page = get_datatable_parameters()
# Consultar
consulta = ExhExhortoArchivo.query
if 'estatus' in request.form:
consulta = consulta.filter_by(estatus=request.form['estatus'])
else:
consulta = consulta.filter_by(estatus='A')
if 'exh_exhorto_id' in request.form:
consulta = consulta.filter_by(exh_exhorto_id=request.form['exh_exhorto_id'])
registros = consulta.order_by(ExhExhortoArchivo.id).offset(start).limit(rows_per_page).all()
total = consulta.count()
# Elaborar datos para DataTable
data = []
for resultado in registros:
# Dar descripción al tipo de documento
tipo_documento = "NO DEFINIDO"
if resultado.tipo_documento == 1:
tipo_documento = "OFICIO"
elif resultado.tipo_documento == 2:
tipo_documento = "ACUERDO"
elif resultado.tipo_documento == 3:
tipo_documento = "ANEXO"
# Apilar resultados
data.append(
{
'nombre_archivo': resultado.nombre_archivo,
'tipo_documento': tipo_documento,
'url': resultado.url,
}
)
# Entregar JSON
return output_datatable_json(draw, total, data)


@exh_exhortos_archivos.route('/exh_exhortos_archivos')
def list_active():
"""Listado de Exh Exhortos Archivos activos"""
return render_template(
'exh_exhortos_archivos/list.jinja2',
filtros=json.dumps({'estatus': 'A'}),
titulo='Exhortos Archivos',
estatus='A',
)
5 changes: 5 additions & 0 deletions plataforma_web/blueprints/exh_exhortos_partes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class ExhExhortoParte(db.Model, UniversalMixin):
# Aquí se puede especificar el nombre del tipo de parte.
tipo_parte_nombre = db.Column(db.String(256))

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

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

0 comments on commit 2be5d79

Please sign in to comment.