Cargar logotipo del emisor
This commit is contained in:
parent
dca5a54668
commit
3d7fb900bf
|
@ -87,6 +87,22 @@ class AppValues(object):
|
|||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
||||
class AppFiles(object):
|
||||
|
||||
def __init__(self, db):
|
||||
self._db = db
|
||||
|
||||
def on_get(self, req, resp, table):
|
||||
values = req.params
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
def on_post(self, req, resp, table):
|
||||
session = req.env['beaker.session']
|
||||
file_object = req.get_param('upload')
|
||||
req.context['result'] = self._db.upload_file(session, table, file_object)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
||||
class AppConfig(object):
|
||||
|
||||
def __init__(self, db):
|
||||
|
|
|
@ -60,6 +60,12 @@ def save_temp(data, modo='wb'):
|
|||
return path
|
||||
|
||||
|
||||
def save_file(path, data, modo='wb'):
|
||||
with open(path, modo) as f:
|
||||
f.write(data)
|
||||
return
|
||||
|
||||
|
||||
def _join(*paths):
|
||||
return os.path.join(*paths)
|
||||
|
||||
|
@ -1081,6 +1087,18 @@ def get_date(value, next_day=False):
|
|||
return d
|
||||
|
||||
|
||||
def upload_file(rfc, opt, file_obj):
|
||||
if opt == 'emisorlogo':
|
||||
tmp = file_obj.filename.split('.')
|
||||
name = '{}.{}'.format(rfc.lower(), tmp[-1].lower())
|
||||
path = _join(PATH_MEDIA, 'logos', name)
|
||||
print (path)
|
||||
save_file(path, file_obj.file.read())
|
||||
return {'status': 'server', 'name': file_obj.filename}
|
||||
|
||||
return {'status': 'error'}
|
||||
|
||||
|
||||
def cancel_cfdi(uuid, pk12, rfc, auth):
|
||||
from .pac import Finkok as PAC
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ from models.db import StorageEngine
|
|||
from controllers.main import (
|
||||
AppLogin, AppLogout, AppAdmin, AppEmisor, AppConfig,
|
||||
AppMain, AppValues, AppPartners, AppProducts, AppInvoices, AppFolios,
|
||||
AppDocumentos
|
||||
AppDocumentos, AppFiles
|
||||
)
|
||||
from settings import DEBUG
|
||||
|
||||
|
@ -38,6 +38,7 @@ api.add_route('/emisor', AppEmisor(db))
|
|||
api.add_route('/folios', AppFolios(db))
|
||||
api.add_route('/main', AppMain(db))
|
||||
api.add_route('/values/{table}', AppValues(db))
|
||||
api.add_route('/files/{table}', AppFiles(db))
|
||||
api.add_route('/config', AppConfig(db))
|
||||
api.add_route('/doc/{type_doc}/{id_doc}', AppDocumentos(db))
|
||||
api.add_route('/partners', AppPartners(db))
|
||||
|
|
|
@ -14,6 +14,12 @@ class StorageEngine(object):
|
|||
def get_values(self, table, values=None):
|
||||
return getattr(self, '_get_{}'.format(table))(values)
|
||||
|
||||
def upload_file(self, session, table, file_obj):
|
||||
if not 'rfc' in session:
|
||||
return {'status': 'error'}
|
||||
|
||||
return main.upload_file(session['rfc'], table, file_obj)
|
||||
|
||||
def get_config(self, values):
|
||||
return main.Configuracion.get_(values)
|
||||
|
||||
|
|
|
@ -60,6 +60,10 @@ def desconectar():
|
|||
return
|
||||
|
||||
|
||||
def upload_file(rfc, opt, file_obj):
|
||||
return util.upload_file(rfc, opt, file_obj)
|
||||
|
||||
|
||||
class Configuracion(BaseModel):
|
||||
clave = TextField(unique=True)
|
||||
valor = TextField(default='')
|
||||
|
|
|
@ -18,6 +18,7 @@ var controllers = {
|
|||
$$('grid_folios').attachEvent('onItemClick', grid_folios_click)
|
||||
$$('cmd_probar_correo').attachEvent('onItemClick', cmd_probar_correo_click)
|
||||
$$('cmd_guardar_correo').attachEvent('onItemClick', cmd_guardar_correo_click)
|
||||
$$('emisor_logo').attachEvent('onItemClick', emisor_logo_click)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -586,3 +587,27 @@ function cmd_guardar_correo_click(){
|
|||
}
|
||||
|
||||
|
||||
function emisor_logo_click(id, e){
|
||||
|
||||
var w = webix.ui({
|
||||
view: 'window',
|
||||
id: 'win_emisor_logo',
|
||||
modal:true,
|
||||
position: 'center',
|
||||
head: 'Subir logotipo',
|
||||
body: {
|
||||
view: 'form',
|
||||
elements: body_win_emisor_logo,
|
||||
}
|
||||
})
|
||||
|
||||
w.show()
|
||||
|
||||
$$('up_emisor_logo').attachEvent('onUploadComplete', function(response){
|
||||
$$('emisor_logo').setValue(response.name)
|
||||
msg_sucess('Logotipo cargado correctamente')
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -394,7 +394,8 @@ var menu_user = {
|
|||
type: {
|
||||
subsign: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
var ui_admin = {
|
||||
rows: [
|
||||
|
@ -418,3 +419,16 @@ var ui_admin = {
|
|||
}
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
|
||||
var body_win_emisor_logo = [
|
||||
{view: 'uploader', id: 'up_emisor_logo', autosend: true, link: 'lst_logo',
|
||||
value: 'Seleccionar logotipo', upload: '/files/emisorlogo', width: 200,
|
||||
accept: "image/png, image/gif, image/jpeg"},
|
||||
{view: 'list', id: 'lst_logo', name: 'logo',
|
||||
type: 'uploader', autoheight:true, borderless: true},
|
||||
{},
|
||||
{cols: [{}, {view: 'button', label: 'Cerrar', autowidth: true,
|
||||
click:("$$('win_emisor_logo').close();")}, {}]}
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue