Exemplo n.º 1
0
Arquivo: departs.py Projeto: soven/GM
def depart_save():
    response = helper.get_response_data()
    content, err_response = validate.ajax_request(request.data, 'department')
    if err_response:
        response.update(err_response)
        return jsonify(response)
    data, error = Departments().save(content)
    if error:
        response.update(helper.get_response_error500())
        return jsonify(response)
    response['data'] = data
    return jsonify(response)
Exemplo n.º 2
0
Arquivo: staff.py Projeto: soven/GM
def staff_save():
    response = helper.get_response_data()
    content, err_response = validate.ajax_request(request.data, 'employee')
    if err_response:
        response.update(err_response)
        return jsonify(response)
    data, error = Employee().save(content)
    if error:
        response.update(helper.get_response_error500())
        return jsonify(response)
    response['data'] = data
    return jsonify(response)
Exemplo n.º 3
0
Arquivo: departs.py Projeto: soven/GM
def depart_delete():
    response = helper.get_response()
    content, err_response = validate.ajax_request(request.data, 'id')
    if err_response:
        response.update(err_response)
        return jsonify(response)
    data, error = Departments().delete(
        content['id'],
    )
    if error:
        response.update(helper.get_response_error500())
        return jsonify(response)
    return jsonify(response)
Exemplo n.º 4
0
Arquivo: posts.py Projeto: soven/GM
def post_get_one():
    response = helper.get_response_data()
    content, err_response = validate.ajax_request(request.data, 'id')
    if err_response:
        response.update(err_response)
        return jsonify(response)
    data, error = Posts().get_one(
        content['id'],
    )
    if error:
        response.update(helper.get_response_error500())
        return jsonify(response)
    response['data'] = data
    return jsonify(response)
Exemplo n.º 5
0
Arquivo: departs.py Projeto: soven/GM
def departs_get_all():
    response = helper.get_response_data([])
    content, err_response = validate.ajax_request(request.data, 'paginate')
    if err_response:
        response.update(err_response)
        return jsonify(response)
    data, error = Departments().get_all(
        content.get('search', {}),
        content.get('sort', []),
        content.get('page_size', 0),
        content.get('page_num', 1)
    )
    if error:
        response.update(helper.get_response_error500())
        return jsonify(response)
    response['data'] = {
        'objs': data[0],
        'total': data[1]
    }
    return jsonify(response)
Exemplo n.º 6
0
Arquivo: general.py Projeto: soven/GM
def object_get_all_short():
    response = helper.get_response_data([])
    content, err_response = validate.ajax_request(request.data, 'object_type')
    if err_response:
        response.update(err_response)
        return jsonify(response)
    object_type = content['type']
    if object_type == 'staff':
        Instance = Employee()
    elif object_type == 'departs':
        Instance = Departments()
    elif object_type == 'groups':
        Instance = Groups()
    elif object_type == 'posts':
        Instance = Posts()
    elif object_type == 'roles':
        Instance = Roles()
    data, error = Instance.get_all_short()
    if error:
        response.update(helper.get_response_error500())
        return jsonify(response)
    response['data'] = data
    return jsonify(response)