Clean branch for users
This commit is contained in:
parent
91cfbb0508
commit
f99adaf109
|
@ -725,3 +725,9 @@ class AppUsers(object):
|
|||
user = req.env['beaker.session']['userobj']
|
||||
req.context['result'] = self._db.users_get(values, user)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
def on_post(self, req, resp):
|
||||
values = req.params
|
||||
user = req.env['beaker.session']['userobj']
|
||||
req.context['result'] = self._db.users_post(values, user)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
|
|
@ -496,6 +496,9 @@ class StorageEngine(object):
|
|||
def users_get(self, filters, user):
|
||||
return main.Usuarios.get_data(filters, user)
|
||||
|
||||
def users_post(self, args, user):
|
||||
return main.Usuarios.post(args, user)
|
||||
|
||||
# Companies only in MV
|
||||
def _get_empresas(self, values):
|
||||
return main.companies_get()
|
||||
|
|
|
@ -3560,6 +3560,25 @@ class Usuarios(BaseModel):
|
|||
method = f"_get_{filters['opt']}"
|
||||
return getattr(cls, method)(cls, filters, user)
|
||||
|
||||
@classmethod
|
||||
def _set_branch_null(cls, args, user):
|
||||
id = args['id']
|
||||
values = {'sucursal': None}
|
||||
where = (Usuarios.id == id)
|
||||
q = (Usuarios
|
||||
.update(**values)
|
||||
.where(where)
|
||||
)
|
||||
result = bool(q.execute())
|
||||
response = {'ok': result}
|
||||
return response
|
||||
|
||||
@classmethod
|
||||
def post(cls, values, user):
|
||||
opt = values['opt']
|
||||
args = utils.loads(values['values'])
|
||||
return getattr(cls, f'_{opt}')(args, user)
|
||||
|
||||
@classmethod
|
||||
def add(cls, values):
|
||||
values['contraseña'] = values.pop('contra')
|
||||
|
|
|
@ -2057,6 +2057,33 @@ function grid_usuarios_click(id, e, node){
|
|||
}
|
||||
|
||||
|
||||
function set_user_branch(id, state){
|
||||
if(state){
|
||||
msg_ok('Show')
|
||||
}else{
|
||||
var args = {
|
||||
opt: 'set_branch_null',
|
||||
values: {id: id}
|
||||
}
|
||||
webix.ajax().post('/users', args, {
|
||||
error:function(text, data, XmlHttpRequest){
|
||||
msg = 'Ocurrio un error, consulta a soporte técnico'
|
||||
msg_error(msg)
|
||||
},
|
||||
success:function(text, data, XmlHttpRequest){
|
||||
var values = data.json()
|
||||
if(values.ok){
|
||||
msg_ok('Asignación a Sucursal eliminada correctamente')
|
||||
}else{
|
||||
msg_error(values.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function grid_usuarios_on_check(row, column, state){
|
||||
|
||||
var values = {
|
||||
|
@ -2064,6 +2091,13 @@ function grid_usuarios_on_check(row, column, state){
|
|||
field: column,
|
||||
value: state,
|
||||
}
|
||||
|
||||
|
||||
if(column='in_branch'){
|
||||
set_user_branch(row, state)
|
||||
return
|
||||
}
|
||||
|
||||
webix.ajax().get('/values/usuarioupdate', values, {
|
||||
error: function(text, data, xhr) {
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue