Example #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')
Example #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')
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')
Example #4
0
def GetDevicemarca(name):
    try:
        data = InventDB.getDevicesbymarca(name)

        if data == 1:
            return Httpstatus.not_found('not found')

        if data == 2:
            return Httpstatus.int_server('server error')

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

    except:
        print("error")
        return Httpstatus.int_server('server error')
Example #5
0
def GetReport(name):
    try:
        data = ReportDB.getReportsbycode(name)

        if data == 1:
            return Httpstatus.not_found('not found')

        if data == 2:
            return Httpstatus.int_server('server error')

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

    except:
        print("error")
        return Httpstatus.int_server('server error')
Example #6
0
def GetLugar(name):
    try:
        data = LugarDB.getLugar(name)

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

    return 'postuser'
Example #7
0
def GetMovementsbyId(id):

    try:

        data = HistorialDB.getHistorialbyID(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')
Example #8
0
def GetDevicebyname():
    try:

        name = request.args.get('nombre')
        data = InventDB.getDevicesbyname(name)

        if data == 1:
            return Httpstatus.not_found('not found')

        if data == 2:
            return Httpstatus.int_server('server error')

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

    except:
        print("error")
        return Httpstatus.int_server('server error')
Example #9
0
def GetReportbyname():
    try:

        name = request.args.get('producto')
        data = ReportDB.getReportsbyname(name)

        if data == 1:
            return Httpstatus.not_found('not found')

        if data == 2:
            return Httpstatus.int_server('server error')

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

    except:
        print("error")
        return Httpstatus.int_server('server error')
Example #10
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')
Example #11
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')
Example #12
0
def deldevice(id):
    try:

        status = InventDB.delDevice(id)

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

        elif status == 1:

            return Httpstatus.not_found('not found')

        elif status == 2:

            return Httpstatus.int_server('server error')

        else:
            return Httpstatus.conflict('Conflicto al borrar')

    except:
        return Httpstatus.int_server('server error')
Example #13
0
def delhistorial(id):
    try:

        status = HistorialDB.delhistorialByID(id)

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

        elif status == 1:

            return Httpstatus.not_found('not found')

        elif status == 2:

            return Httpstatus.int_server('server error')

        else:
            return Httpstatus.conflict('Conflicto al borrar')

    except:
        return Httpstatus.int_server('server error')
Example #14
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')
Example #15
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')