def post(self):
        try:
            data = get_json(request)

            database = get_database()
            resp = database.filtrar_estudantes(data)

        except Exception as e:
            resp = {'msg': str(e)}

            return resp, HTTP_STATUS_CODE['BAD_REQUEST']

        return resp, HTTP_STATUS_CODE['OK']
    def delete(self):
        try:
            data = get_json(request)
            estudante_id = get_from_request(data, 'id')

            database = get_database()
            resp = database.deletar_estudante(estudante_id)

        except Exception as e:
            resp = {'msg': str(e)}

            return resp, HTTP_STATUS_CODE['BAD_REQUEST']

        return resp, HTTP_STATUS_CODE['OK']
    def post(self):
        try:
            data = get_json(request)

            compara = get_from_request(data, 'compara')

            unicos = self.encontra_unicos(compara)

        except Exception as e:
            resp = {'error': str(e), 'status': HTTP_STATUS_CODE['BAD_REQUEST']}

            return resp

        resp = {'unicos': unicos, 'status': HTTP_STATUS_CODE['OK']}

        return resp
    def post(self):
        try:
            data = get_json(request)

            cpf = get_from_request(data, 'cpf')
            cpf = re.sub('[^0-9]', '', cpf)

        except Exception as e:
            resp = {'error': str(e), 'status': HTTP_STATUS_CODE['BAD_REQUEST']}

            return resp

        is_valid = self.valida_cpf(cpf)

        resp = {'is_valid': is_valid, 'status': HTTP_STATUS_CODE['OK']}

        return resp
Example #5
0
    def delete(self):
        try:
            data = get_json(request)
            sol_id = get_from_request(data, 'id')

            sol = MongoConnection.get_collection_solicitacao()

            resp = sol.deletar_solicitacao(sol_id)

        except Exception as e:
            resp = {'msg': str(e)}

            error_log('/solicitacao', 'DELETE', str(e))

            return resp, HTTP_STATUS_CODE['BAD_REQUEST']

        return resp, HTTP_STATUS_CODE['OK']
Example #6
0
    def post(self):
        try:
            data = get_json(request)

            renda = get_from_request(data, 'renda')

            data['credito'] = credito(renda)

            sol = MongoConnection.get_collection_solicitacao()

            document = sol.inserir_solicitacao(data)

        except Exception as e:
            resp = {'msg': str(e)}

            error_log('/solicitacao', 'POST', str(e))

            return resp, HTTP_STATUS_CODE['BAD_REQUEST']

        return document, HTTP_STATUS_CODE['OK']