Agregar emisor UI

This commit is contained in:
Mauricio Baeza 2017-11-30 00:37:13 -06:00
parent cb18e3c3d2
commit b3c2e16841
7 changed files with 102 additions and 5 deletions

View File

@ -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'

View File

@ -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'

View File

@ -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))

View File

@ -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('/')

View File

@ -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

View File

@ -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() != '';},
}
},
]}, {}, ]
},
]
}

View File

@ -0,0 +1,39 @@
<%inherit file="base.html"/>
<%block name="media">
<script src="/static/js/ui/empresas.js" type="text/javascript" ></script>
</%block>
<%block name="content">
<div id="form_empresas"></div>
<script type="text/javascript" charset="utf-8">
function validate_nuevo_rfc(){
var form = this.getFormView();
if (!form.validate()) {
webix.message({ type:"error", text:"Valores inválidos" });
return
}
var values = form.getValues()
webix.ajax().post("/empresas", values, function(text, data, xhr) {
var values = data.json();
if (values.ok) {
} else {
webix.message({ type:"error", text: values.msg })
}
});
};
webix.ready(function(){
webix.ui(ui_empresas);
});
</script>
</%block>