From b3c2e168412e71b3ff4451eb7d158cf4e7d4b03c Mon Sep 17 00:00:00 2001 From: Mauricio Baeza Date: Thu, 30 Nov 2017 00:37:13 -0600 Subject: [PATCH] Agregar emisor UI --- source/app/conf.py.example | 3 ++- source/app/controllers/main.py | 16 ++++++++++++++ source/app/main.py | 3 ++- source/app/middleware.py | 9 ++++++-- source/app/settings.py | 2 +- source/static/js/ui/empresas.js | 35 +++++++++++++++++++++++++++++ source/templates/empresas.html | 39 +++++++++++++++++++++++++++++++++ 7 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 source/static/js/ui/empresas.js create mode 100644 source/templates/empresas.html diff --git a/source/app/conf.py.example b/source/app/conf.py.example index 2cdf172..8610043 100644 --- a/source/app/conf.py.example +++ b/source/app/conf.py.example @@ -1,7 +1,8 @@ #!/usr/bin/env python -DEBUG = True +DEBUG = False +MV = True #~ Establece una ruta accesible para el servidor web LOG_PATH = '/srv/empresa/logs/empresalibre.log' diff --git a/source/app/controllers/main.py b/source/app/controllers/main.py index ab7323a..eab4209 100644 --- a/source/app/controllers/main.py +++ b/source/app/controllers/main.py @@ -4,6 +4,22 @@ import falcon from middleware import get_template +class AppEmpresas(object): + template = 'empresas.html' + + def __init__(self, db): + self._db = db + + @falcon.after(get_template) + def on_get(self, req, resp): + resp.status = falcon.HTTP_200 + + def on_post(self, req, resp): + values = req.params + req.context['result'] = self._db.empresas(values) + resp.status = falcon.HTTP_200 + + class AppLogin(object): template = 'login.html' diff --git a/source/app/main.py b/source/app/main.py index 2db8add..e30da00 100644 --- a/source/app/main.py +++ b/source/app/main.py @@ -12,7 +12,7 @@ from middleware import ( handle_404 ) from models.db import StorageEngine -from controllers.main import ( +from controllers.main import (AppEmpresas, AppLogin, AppLogout, AppAdmin, AppEmisor, AppConfig, AppMain, AppValues, AppPartners, AppProducts, AppInvoices, AppFolios, AppDocumentos, AppFiles, AppPreInvoices, AppCuentasBanco, @@ -32,6 +32,7 @@ api = falcon.API(middleware=[ api.req_options.auto_parse_form_urlencoded = True api.add_sink(handle_404, '') +api.add_route('/empresas', AppEmpresas(db)) api.add_route('/', AppLogin(db)) api.add_route('/logout', AppLogout(db)) api.add_route('/admin', AppAdmin(db)) diff --git a/source/app/middleware.py b/source/app/middleware.py index fc2d00f..ac2e2d7 100644 --- a/source/app/middleware.py +++ b/source/app/middleware.py @@ -3,7 +3,7 @@ import falcon from controllers import util from models import main -from settings import PATH_STATIC +from settings import MV, PATH_STATIC def handle_404(req, resp): @@ -34,7 +34,12 @@ class AuthMiddleware(object): def process_resource(self, req, resp, resource, params): id_session = req.cookies.get('beaker.session.id', '') - if not id_session and req.path != '/': + if req.path == '/empresas': + if MV: + pass + else: + raise falcon.HTTPTemporaryRedirect('/') + elif not id_session and req.path != '/': raise falcon.HTTPTemporaryRedirect('/') diff --git a/source/app/settings.py b/source/app/settings.py index 89029af..f11028c 100644 --- a/source/app/settings.py +++ b/source/app/settings.py @@ -7,7 +7,7 @@ from mako.lookup import TemplateLookup from logbook import Logger, StreamHandler, RotatingFileHandler logbook.set_datetime_format('local') -from conf import DEBUG, LOG_PATH +from conf import DEBUG, MV, LOG_PATH DEBUG = DEBUG diff --git a/source/static/js/ui/empresas.js b/source/static/js/ui/empresas.js new file mode 100644 index 0000000..750febc --- /dev/null +++ b/source/static/js/ui/empresas.js @@ -0,0 +1,35 @@ + +var msg_rfc = 'El RFC es requerido' + +var form_controls_empresa = [ + {view: 'text', label: 'RFC', id: 'txt_alta_rfc', name: 'alta_rfc', + labelPosition: 'top', required: true, invalidMessage: msg_rfc}, + {margin: 10, cols:[{}, {view: 'button', value: 'Agregar RFC', + click: 'validate_nuevo_rfc', hotkey: 'enter'}, {}]} +] + + +var msg_header = 'Bienvenido a Empresa Libre' + +var ui_empresas = { + rows: [ + {maxHeight: 50}, + {view: 'template', template: msg_header, maxHeight: 50, css: 'login_header'}, + {maxHeight: 50}, + {cols: [{}, {type: 'space', padding: 5, + rows: [ + {view: 'template', template: 'Alta de nuevo emisor', type: 'header'}, + { + container: 'form_empresas', + view: 'form', + id: 'form_empresas', + width: 400, + elements: form_controls_empresa, + rules:{ + alta_rfc:function(value){ return value.trim() != '';}, + } + }, + ]}, {}, ] + }, + ] +} diff --git a/source/templates/empresas.html b/source/templates/empresas.html new file mode 100644 index 0000000..a557531 --- /dev/null +++ b/source/templates/empresas.html @@ -0,0 +1,39 @@ +<%inherit file="base.html"/> + +<%block name="media"> + + + +<%block name="content"> + +
+ + + +