Ejemplo n.º 1
0
    def delete(self, id):
        agro_response = AgroResponse()
        agricultor = AgricultorService()

        retorno = agricultor.deletar(id)
        if retorno:
            return agro_response.status_200(retorno)
Ejemplo n.º 2
0
    def delete(self, id):
        agro_response = AgroResponse()
        cliente = ClienteService()

        retorno = cliente.deletar(id)
        if retorno:
            return agro_response.status_200(retorno)
Ejemplo n.º 3
0
    def delete(self, id):
        agro_response = AgroResponse()
        pedido = PedidoService()

        retorno = pedido.deletar(id)
        if retorno:
            return agro_response.status_200("Pedido deletado com sucesso")
Ejemplo n.º 4
0
    def delete(self, id):
        agro_response = AgroResponse()
        categoria = CategoriaService()

        retorno = categoria.deletar(id)
        if retorno:
            return agro_response.status_200(retorno)
Ejemplo n.º 5
0
    def delete(self, id):
        agro_response = AgroResponse()
        endereco = EnderecoService()

        retorno = endereco.deletar(id)
        if retorno:
            return agro_response.status_200(retorno)
Ejemplo n.º 6
0
    def get(self):
        agro_response = AgroResponse()
        endereco = EnderecoService()

        retorno = endereco.listar()
        if retorno:
            return agro_response.status_200(retorno)
        return agro_response.status_400("Não foi possível", "encontrar")
Ejemplo n.º 7
0
    def put(self, current_user):
        agro_response = AgroResponse()
        cliente = ClienteService()
        dados = json.loads(request.data)

        retorno = cliente.atualizar(current_user.id, dados)
        if retorno:
            return agro_response.status_200(retorno)
Ejemplo n.º 8
0
    def get(self):
        agro_response = AgroResponse()
        cliente = ClienteService()

        retorno = cliente.listar()
        if retorno:
            return agro_response.status_200(retorno)
        return agro_response.status_400('deu', 'ruim')
Ejemplo n.º 9
0
    def delete(self, id):
        agro_response = AgroResponse()
        item_venda = ItemVendaService()

        retorno = item_venda.deletar(id)
        if retorno:
            return agro_response.status_200(retorno)
        return agro_response.status_400('deu', 'ruim')
Ejemplo n.º 10
0
    def get(self):
        agro_response = AgroResponse()
        pedido = PedidoService()

        retorno = pedido.listar()
        if retorno:
            return agro_response.status_200(retorno)
        return agro_response.status_400("Não, encontrado")
Ejemplo n.º 11
0
    def delete(self, id):
        agro_response = AgroResponse()
        forma_pagamento = FormaPagamentoService()

        retorno = forma_pagamento.deletar(id)
        if retorno:
            return agro_response.status_200(
                "Forma de Pagamento deletada com sucesso!")
Ejemplo n.º 12
0
    def get(self):
        agro_response = AgroResponse()
        forma_pagamento = FormaPagamentoService()

        retorno = forma_pagamento.listar()
        if retorno:
            return agro_response.status_200(retorno)
        return agro_response.status_400('Não foi possivel', 'pegar')
Ejemplo n.º 13
0
    def get(self):
        agro_response = AgroResponse()
        categoria = CategoriaService()

        retorno = categoria.listar()
        if retorno:
            return agro_response.status_200(retorno)
        return agro_response.status_400("Não foi possível", "encontrar")
Ejemplo n.º 14
0
    def get(self):
        agro_response = AgroResponse()
        item_venda = ItemVendaService()

        retorno = item_venda.listar()
        if retorno:
            return agro_response.status_200(retorno)
        return agro_response.status_400('deu', 'ruim')
Ejemplo n.º 15
0
    def put(self, id):
        agro_response = AgroResponse()
        agricultor = AgricultorService()
        dados = json.loads(request.data)

        retorno = agricultor.atualizar(id, dados)
        if retorno:
            return agro_response.status_200(retorno)
Ejemplo n.º 16
0
    def get(self):
        agro_response = AgroResponse()
        agricultor = AgricultorService()

        retorno = agricultor.listar()
        if retorno:
            return agro_response.status_200(retorno)
        return agro_response.status_400('deu', 'ruim')
Ejemplo n.º 17
0
    def put(self):
        agro_response = AgroResponse()
        pedido = PedidoService()
        dados = json.loads(request.data)
        retorno = pedido.atualizar(dados)

        if retorno:
            return agro_response.status_200(retorno)
        return agro_response.status_400('deu', 'ruim')
Ejemplo n.º 18
0
    def post(self):
        agro_response = AgroResponse()
        forma_pagamento = FormaPagamentoService()
        dados = json.loads(request.data)

        retorno = forma_pagamento.criar(dados)
        if retorno:
            return agro_response.status_200('Forma de pagamento criada!')
        return agro_response.status_400('Não foi possível', 'criar')
Ejemplo n.º 19
0
    def put(self):
        agro_response = AgroResponse()
        categoria = CategoriaService()
        dados = json.loads(request.data)
        retorno = categoria.atualizar(dados)

        if retorno:
            return agro_response.status_200(retorno)
        return agro_response.status_400('deu', 'ruim')
Ejemplo n.º 20
0
    def put(self):
        agro_response = AgroResponse()
        item_venda = ItemVendaService()
        dados = json.loads(request.data)
        retorno = item_venda.atualizar(dados)

        if retorno:
            return agro_response.status_200(retorno)
        return agro_response.status_400('deu', 'ruim')
Ejemplo n.º 21
0
    def post(self):
        agro_response = AgroResponse()
        categoria = CategoriaService()
        dados = json.loads(request.data)

        retorno = categoria.criar(dados)
        if retorno:
            return agro_response.status_200(retorno)
        return agro_response.status_400("Falha na criação", "criação falhou")
Ejemplo n.º 22
0
    def post(self):
        agro_response = AgroResponse()
        endereco = EnderecoService()
        dados = json.loads(request.data)

        retorno = endereco.criar(dados)
        if retorno:
            return agro_response.status_200("Endereço criado")
        return agro_response.status_400("Falha na criação", "criação falhou")
Ejemplo n.º 23
0
    def put(self):
        agro_response = AgroResponse()
        forma_pagamento = FormaPagamentoService()
        dados = json.loads(request.data)
        retorno = forma_pagamento.atualizar(dados)

        if retorno:
            return agro_response.status_200(retorno)
        return agro_response.status_400('deu', 'ruim')
Ejemplo n.º 24
0
    def post(self):
        agro_response = AgroResponse()
        login = LoginService()
        dados = json.loads(request.data)

        retorno = login.logar(dados)
        if retorno:
            return agro_response.status_200(retorno)
        return agro_response.status_200(retorno)
Ejemplo n.º 25
0
    def post(self, current_user):
        agro_response = AgroResponse()
        pedido = PedidoService()
        dados = json.loads(request.data)

        retorno = pedido.criar(dados, current_user)
        if retorno:
            return agro_response.status_200(retorno)
        return agro_response.status_400("Não, criado")
Ejemplo n.º 26
0
    def post(self):
        agro_response = AgroResponse()
        agricultor = AgricultorService()
        dados = json.loads(request.data)

        retorno = agricultor.criar(dados)
        if retorno:
            return agro_response.status_200(
                'Um e-mail de confirmação foi enviado pra você')
        return agro_response.status_400('deu', 'ruim')
Ejemplo n.º 27
0
 def default_error_handler(e: Exception):
     agro_response = AgroResponse()
     exc_type, exc_value, exc_traceback = sys.exc_info()
     mensagem = 'Erro interno'
     dados_tecnicos = {
         'arquivo': exc_traceback.tb_frame.f_code.co_filename,
         'linha': exc_traceback.tb_lineno,
         'nome': exc_traceback.tb_frame.f_code.co_name,
         'tipo': get_type_or_class_name(exc_type),
         'mensagem': str(exc_value),
         'traceback': traceback.format_exc()
     }
     detalhe = str(exc_value)
     return agro_response.status_500(mensagem, detalhe, dados_tecnicos)
Ejemplo n.º 28
0
    def get(self, token):
        agro_response = AgroResponse()
        usuario = Usuario()
        resposta = None
        email = usuario.confirmacao_token(token)
        usuario = Usuario.query.filter_by(email=email).first()
        if not email:
            return agro_response.status_200('Link inválido ou expirado!')

        if usuario.confirmado:
            return agro_response.status_200(
                'Conta já confirmada. Faça o login!')

        if usuario.email == email:
            usuario.confirmado = True
            db.session.add(usuario)
            db.session.commit()
            resposta = 'Você confirmou sua conta! Obrigado!'
        return agro_response.status_200(resposta)
Ejemplo n.º 29
0
 def get(self):
     agro_response = AgroResponse()
     return agro_response.status_200('0.0.1')
Ejemplo n.º 30
0
 def page_not_found_error(error):
     agro_response = AgroResponse()
     mensagem = 'Erro de parâmetro(s) inválido(s).'
     detalhe = [str(error)]
     return agro_response.status_400(mensagem, detalhe)