-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from ricval/blueprint-bancos
Blueprint bancos
- Loading branch information
Showing
15 changed files
with
388 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" | ||
Bancos, formularios | ||
""" | ||
|
||
from flask_wtf import FlaskForm | ||
from wtforms import StringField, SubmitField | ||
from wtforms.validators import DataRequired, Length, Optional | ||
|
||
|
||
class BancoForm(FlaskForm): | ||
"""Formulario Banco""" | ||
|
||
nombre = StringField("Nombre", validators=[DataRequired(), Length(max=64)]) | ||
guardar = SubmitField("Guardar") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
Bancos, modelos | ||
""" | ||
|
||
from datetime import datetime | ||
from typing import List, Optional | ||
|
||
from sqlalchemy import Boolean, DateTime, Enum, ForeignKey, JSON, Integer, String, Text, Uuid | ||
from sqlalchemy.orm import Mapped, mapped_column, relationship | ||
from sqlalchemy.sql.functions import now | ||
|
||
from lib.universal_mixin import UniversalMixin | ||
from orion.extensions import database | ||
|
||
|
||
class Banco(database.Model, UniversalMixin): | ||
"""Banco""" | ||
|
||
# Nombre de la tabla | ||
__tablename__ = "bancos" | ||
|
||
# Clave primaria | ||
id: Mapped[int] = mapped_column(primary_key=True) | ||
|
||
# Columnas | ||
nombre: Mapped[str] = mapped_column(String(64), unique=True) | ||
|
||
# Hijos | ||
# TODO: Conectar hijos | ||
# pensiones_alimenticias = db.relationship("PersonaPensionAlimenticia", back_populates="banco") | ||
|
||
def __repr__(self): | ||
"""Representación""" | ||
return f"<Banco {self.id}>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{% extends 'layouts/app.jinja2' %} | ||
{% import 'macros/detail.jinja2' as detail %} | ||
{% import 'macros/modals.jinja2' as modals %} | ||
{% import 'macros/topbar.jinja2' as topbar %} | ||
|
||
{% block title %}Banco{% endblock %} | ||
|
||
{% block topbar_actions %} | ||
{% call topbar.page_buttons('Banco') %} | ||
{{ topbar.button_previous('Bancos', url_for('bancos.list_active')) }} | ||
{% if current_user.can_edit('BANCOS') %} | ||
{{ topbar.button_edit('Editar', url_for('bancos.edit', banco_id=banco.id)) }} | ||
{% endif %} | ||
{% if current_user.can_admin('BANCOS') %} | ||
{% if banco.estatus == 'A' %}{{ topbar.button_delete('Eliminar', url_for('bancos.delete', banco_id=banco.id)) }}{% endif %} | ||
{% if banco.estatus == 'B' %}{{ topbar.button_recover('Recuperar', url_for('bancos.recover', banco_id=banco.id)) }}{% endif %} | ||
{% endif %} | ||
{% endcall %} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
{% call detail.card(estatus=banco.estatus) %} | ||
{{ detail.label_value_big('Nombre', banco.nombre) }} | ||
{% endcall %} | ||
{% endblock %} | ||
|
||
{% block custom_javascript %} | ||
{% if current_user.can_admin('BANCOS') %} | ||
{% if banco.estatus == 'A' %}{{ modals.custom_javascript_delete('Eliminar', '¿Eliminar banco ' + banco.nombre + '?') }}{% endif %} | ||
{% if banco.estatus == 'B' %}{{ modals.custom_javascript_recover('Recuperar', '¿Recuperar banco ' + banco.nombre + '?') }}{% endif %} | ||
{% endif %} | ||
{{ detail.moment_js(moment) }} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{% extends 'layouts/app.jinja2' %} | ||
{% import 'macros/form.jinja2' as f with context %} | ||
{% import 'macros/topbar.jinja2' as topbar %} | ||
|
||
{% block title %}Editar Banco {{ banco.nombre }}{% endblock %} | ||
|
||
{% block topbar_actions %} | ||
{{ topbar.page('Editar ' + banco.nombre) }} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
{% call f.card() %} | ||
{% set form_kwargs = {'banco_id': banco.id} %} | ||
{% call f.form_tag('bancos.edit', fid='banco_form', **form_kwargs) %} | ||
{% call f.form_group(form.nombre) %}{% endcall %} | ||
{% call f.form_group(form.guardar) %}{% endcall %} | ||
{% endcall %} | ||
{% endcall %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
{% extends 'layouts/app.jinja2' %} | ||
{% import 'macros/list.jinja2' as list %} | ||
{% import 'macros/topbar.jinja2' as topbar %} | ||
|
||
{% block title %}{{ titulo }}{% endblock %} | ||
|
||
{% block topbar_actions %} | ||
{% call topbar.page_buttons(titulo) %} | ||
{% if current_user.can_admin('BANCOS') %} | ||
{% if estatus == 'A' %}{{ topbar.button_list_inactive('Inactivos', url_for('bancos.list_inactive')) }}{% endif %} | ||
{% if estatus == 'B' %}{{ topbar.button_list_active('Activos', url_for('bancos.list_active')) }}{% endif %} | ||
{% endif %} | ||
{% if current_user.can_insert('BANCOS') %} | ||
{{ topbar.button_new('Nuevo Banco', url_for('bancos.new')) }} | ||
{% endif %} | ||
{% endcall %} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
{% call list.card() %} | ||
<!-- Filtros Bancos --> | ||
<div class="row"> | ||
<div class="col"> | ||
<form class="row g-1 mb-3" id="filtradorForm" onsubmit="filtrosBancos.buscar(); return false;"> | ||
<div class="col-6"> | ||
<div class="form-floating"> | ||
<input id="filtroNombre" type="text" class="form-control" aria-label="Nombre" style="text-transform: uppercase;"> | ||
<label for="filtroNombre">Nombre</label> | ||
</div> | ||
</div> | ||
<div class="col-6 text-end"> | ||
<button title="Buscar" class="btn btn-primary btn-lg" onclick="filtrosBancos.buscar(); return false;" id="button-buscar"><span class="iconify" data-icon="mdi:magnify"></span></button> | ||
<button title="Limpiar" class="btn btn-warning btn-lg" type="reset" onclick="filtrosBancos.limpiar();" id="button-limpiar"><span class="iconify" data-icon="mdi:broom"></span></button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
<!-- DataTable Bancos --> | ||
<table id="bancos_datatable" class="table {% if estatus == 'B'%}table-dark{% endif %} display nowrap" style="width:100%"> | ||
<thead> | ||
<tr> | ||
<th>Nombre</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> | ||
<script> | ||
// DataTable Bancos | ||
const constructorDataTable = new ConfigDataTable( '{{ csrf_token() }}' ); | ||
let configDataTable = constructorDataTable.config(); | ||
configDataTable['ajax']['url'] = '/bancos/datatable_json'; | ||
configDataTable['ajax']['data'] = {{ filtros }}; | ||
configDataTable['columns'] = [ | ||
{ data: 'detalle' } | ||
]; | ||
configDataTable['columnDefs'] = [ | ||
{ | ||
targets: 0, // detalle | ||
data: null, | ||
render: function(data, type, row, meta) { | ||
return '<a href="' + data.url + '">' + data.nombre + '</a>'; | ||
} | ||
} | ||
]; | ||
// Filtros Bancos | ||
const filtrosBancos = new FiltrosDataTable('#bancos_datatable', configDataTable); | ||
filtrosBancos.agregarInput('filtroNombre', 'nombre'); | ||
filtrosBancos.precargar(); | ||
</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{% extends 'layouts/app.jinja2' %} | ||
{% import 'macros/form.jinja2' as f with context %} | ||
{% import 'macros/topbar.jinja2' as topbar %} | ||
|
||
{% block title %}Nuevo Banco{% endblock %} | ||
|
||
{% block topbar_actions %} | ||
{{ topbar.page('Nuevo Banco') }} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
{% call f.card() %} | ||
{% call f.form_tag('bancos.new', fid='banco_form') %} | ||
{% call f.form_group(form.nombre) %}{% endcall %} | ||
{% call f.form_group(form.guardar) %}{% endcall %} | ||
{% endcall %} | ||
{% endcall %} | ||
{% endblock %} |
Oops, something went wrong.