Пример #1
0
def PutDevice(name):

    try:

        if request.is_json:

            content = request.json

            status = InventDB.putDevice(content, name)

            if status == 0:
                return Httpstatus.ok_server_put('ok')

            elif status == 1:

                return Httpstatus.not_found('not found')

            else:

                return Httpstatus.int_server('server error')

        else:
            return Httpstatus.bad_request('bad request')

    except Exception as e:
        print(e)
        return int_server('server error')
Пример #2
0
def putLugar(id):
    try:
        print(request.is_json)
        if request.is_json:

            content = request.json

            status = LugarDB.putLugar(id, content)

            if status == 0:
                return Httpstatus.ok_server_put('ok')

            elif status == 1:

                return Httpstatus.not_found('not found')

            else:

                return Httpstatus.int_server('server error')

        else:
            return Httpstatus.bad_request('bad request')

    except Exception as e:
        print(e)
        return Httpstatus.int_server('server error')
Пример #3
0
def putMove(id):
    try:
        print(request.is_json)
        if request.is_json:

            content = request.json
            print(content)

            status = TypemovesDB.putMove(id, content)

            if status == 0:
                return Httpstatus.ok_server_put('ok')

            elif status == 1:

                return Httpstatus.not_found('not found')

            else:

                return Httpstatus.int_server('server error')

        else:
            return Httpstatus.bad_request('bad request')

    except:
        print('error')
        return Httpstatus.int_server('server error')
Пример #4
0
def GetMovementsbysearch():

    try:
        #["movimiento","lugar","usuario","producto","fecha","modelo","marca","codigo","serie"]

        lista = []

        try:
            lista.append(request.args.get('IDmovimiento'))
            lista.append(request.args.get('IDtipomov'))
            lista.append(request.args.get('IDlugar'))
            lista.append(request.args.get('IDusuario'))
            lista.append(request.args.get('producto'))
            lista.append(request.args.get('fechamovimiento'))
            lista.append(request.args.get('modelo'))
            lista.append(request.args.get('marca'))
            lista.append(request.args.get('codigo'))
            lista.append(request.args.get('serie'))

            if request.args.get('fechamovimiento') != "null":
                datetime.datetime.strptime(request.args.get('fechamovimiento'),
                                           "%Y-%m-%d").date()

        except Exception as e:
            print(e)
            return Httpstatus.bad_request('bad_request')

        #movimiento = request.args.get('movimiento')
        if len(lista) != 10:
            return Httpstatus.bad_request('bad request')
        data = HistorialDB.getHistorialbysearch(lista)

        if data == 2:
            return Httpstatus.int_server('server error')
        elif data == 1:
            return Httpstatus.not_found('not found')

        return data, 200, {'ContentType': 'application/json'}

    except Exception as e:
        print(e)
        return Httpstatus.int_server('server error')
Пример #5
0
def Getdevicesbysearch():

    try:
        #["codigo","producto","fecha","modelo","marca","serie"]

        lista = []

        try:
            lista.append(request.args.get('codigo'))
            lista.append(request.args.get('producto'))
            lista.append(request.args.get('fecha'))
            lista.append(request.args.get('modelo'))
            lista.append(request.args.get('marca'))
            lista.append(request.args.get('serie'))

            if request.args.get('fecha') != "null":
                datetime.datetime.strptime(request.args.get('fecha'),
                                           "%Y-%m-%d").date()

        except Exception as e:
            print(e)
            return Httpstatus.bad_request('bad_request')

        #movimiento = request.args.get('movimiento')
        if len(lista) != 6:
            return Httpstatus.bad_request('bad request')
        data = InventDB.getDevicesbysearch(lista)

        if data == 2:
            return Httpstatus.int_server('server error')
        elif data == 1:
            return Httpstatus.not_found('not found')

        return data, 200, {'ContentType': 'application/json'}

    except Exception as e:
        print(e)
        return Httpstatus.int_server('server error')
Пример #6
0
def PostMove():
    try:

        if request.is_json:
            content = request.get_json()
            status = TypemovesDB.postMove(content)

            if status == 0:
                return Httpstatus.ok_server_post()
            else:
                return Httpstatus.int_server('server error')

        else:
            return Httpstatus.bad_request('bad request')

    except Exception as e:
        print(e)
        return Httpstatus.int_server('server error')
Пример #7
0
def searchmissing(id):
    try:

        if id is None:
            return Httpstatus.bad_request('bad request')

        data = HistorialDB.SearchMissingEntries(id)

        if data == 2:
            return Httpstatus.int_server('server error')
        elif data == 1:
            return Httpstatus.not_found('not found')

        return data, 200, {'ContentType': 'application/json'}

    except:
        print("error")
        return Httpstatus.int_server('server error')
Пример #8
0
def PostHistorial():

    try:
        print(request.is_json)
        if request.is_json:
            content = request.get_json()

            status = HistorialDB.postHistorial(content)

            if status == 0:
                return Httpstatus.ok_server_post()
            else:
                return Httpstatus.int_server('server error')

        else:
            return Httpstatus.bad_request('bad request')

    except:
        return Httpstatus.int_server('server error')
Пример #9
0
def PostLugar():
    try:

        if request.is_json:
            content = request.get_json()
            status = LugarDB.postLugar(content)

            if status == 0:
                return Httpstatus.ok_server_post()
            elif status == 2:
                return Httpstatus.int_server('server error')
            elif status == 1:
                return Httpstatus.conflict('Conflicto')

        else:
            return Httpstatus.bad_request('bad request')

    except Exception as e:
        print(e)
        return Httpstatus.int_server('server error')
Пример #10
0
def ValidateSame():

    try:
        print(request.is_json)
        if request.is_json:
            content = request.get_json()

            status = InventDB.ValidateSamePlaces(content)

            if status == 0:
                return Httpstatus.ok_server_post()
            elif status == 2:
                return Httpstatus.conflict('not the same')
            elif status == 1:
                return Httpstatus.not_found('not found')

            else:
                return Httpstatus.int_server('server error')

        else:
            return Httpstatus.bad_request('bad request')

    except:
        return Httpstatus.int_server('server error')
Пример #11
0
def PostDevice():

    try:
        print(request.is_json)
        if request.is_json:
            content = request.get_json()

            status = InventDB.postDevice(content)

            if status == 0:
                return Httpstatus.ok_server_post()
            elif status == 2:
                return Httpstatus.int_server('server error')
            elif status == 1:
                return Httpstatus.conflict('ya existente')

            else:
                return Httpstatus.int_server('server error')

        else:
            return Httpstatus.bad_request('bad request')

    except:
        return Httpstatus.int_server('server error')