Python django.urls.reverse_lazy() Examples

The following are 30 code examples of django.urls.reverse_lazy(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.urls , or try the search function .
Example #1
Source File: views.py    From django-classified with MIT License 7 votes vote down vote up
def get(self, request):
        area_slug = request.GET.get('area_slug')
        if area_slug:
            area = get_object_or_404(Area, slug=area_slug)
            area.set_for_request(request)
        else:
            Area.delete_for_request(request)

        next_url = self.request.GET.get('next') or reverse_lazy('django_classified:index')

        return redirect(next_url) 
Example #2
Source File: compras.py    From djangoSIGE with MIT License 7 votes vote down vote up
def get(self, request, instance, redirect_url, *args, **kwargs):
        itens_compra = instance.itens_compra.all()
        pagamentos = instance.parcela_pagamento.all()

        instance.pk = None
        instance.id = None
        instance.status = '0'
        instance.save()

        for item in itens_compra:
            item.pk = None
            item.id = None
            item.save()
            instance.itens_compra.add(item)

        for pagamento in pagamentos:
            pagamento.pk = None
            pagamento.id = None
            pagamento.save()
            instance.parcela_pagamento.add(pagamento)

        return redirect(reverse_lazy(redirect_url, kwargs={'pk': instance.id})) 
Example #3
Source File: tests.py    From longclaw with MIT License 6 votes vote down vote up
def test_post_checkout(self):
        """
        Test correctly posting to the checkout view
        """
        country = CountryFactory()
        request = RequestFactory().post(
            reverse_lazy('longclaw_checkout_view'),
            {
                'shipping-name': 'bob',
                'shipping-line_1': 'blah blah',
                'shipping-postcode': 'ytxx 23x',
                'shipping-city': 'London',
                'shipping-country': country.pk,
                'email': 'test@test.com'
            }
        )
        request.session = {}
        bid = basket_id(request)
        BasketItemFactory(basket_id=bid)
        response = CheckoutView.as_view()(request)
        self.assertEqual(response.status_code, 302) 
Example #4
Source File: compras.py    From djangoSIGE with MIT License 5 votes vote down vote up
def edit_url(self):
        return reverse_lazy('compras:editarorcamentocompraview', kwargs={'pk': self.id}) 
Example #5
Source File: lancamento.py    From djangoSIGE with MIT License 5 votes vote down vote up
def get_context_data(self, **kwargs):
        context = super(SaidaListView, self).get_context_data(**kwargs)
        context['title_complete'] = 'PAGAMENTOS'
        context['add_url'] = reverse_lazy('financeiro:addpagamentoview')
        return context 
Example #6
Source File: nota_fiscal.py    From djangoSIGE with MIT License 5 votes vote down vote up
def view_context(self, context):
        context[
            'title_complete'] = 'NOTAS FISCAIS DE FORNECEDORES (ENTRADA DE MATERIAL)'
        context['add_url'] = reverse_lazy('fiscal:addnotafiscalentradaview')
        context['importar_nota_url'] = reverse_lazy(
            'fiscal:importarnotafiscalentrada')
        context['entrada'] = True
        return context 
Example #7
Source File: nota_fiscal.py    From djangoSIGE with MIT License 5 votes vote down vote up
def view_context(self, context):
        context['title_complete'] = 'EDITAR NOTA FISCAL DE SAÍDA ' + \
            str(self.object.serie) + '/' + str(self.object.n_nf_saida)
        context['return_url'] = reverse_lazy('fiscal:listanotafiscalsaidaview')
        context['saida'] = True
        return context 
Example #8
Source File: nota_fiscal.py    From djangoSIGE with MIT License 5 votes vote down vote up
def view_context(self, context):
        context['title_complete'] = 'GERAR NOTA FISCAL'
        context['return_url'] = reverse_lazy('fiscal:listanotafiscalsaidaview')
        context['saida'] = True
        return context 
Example #9
Source File: tributos.py    From djangoSIGE with MIT License 5 votes vote down vote up
def get_context_data(self, **kwargs):
        context = super(AdicionarGrupoFiscalView,
                        self).get_context_data(**kwargs)
        context['title_complete'] = 'ADICIONAR GRUPO FISCAL'
        context['return_url'] = reverse_lazy('fiscal:listagrupofiscalview')
        return context 
Example #10
Source File: lancamento.py    From djangoSIGE with MIT License 5 votes vote down vote up
def get_edit_url(self):
        if self.status == '0':
            return reverse_lazy('financeiro:editarpagamentoview', kwargs={'pk': self.id})
        else:
            return reverse_lazy('financeiro:editarcontapagarview', kwargs={'pk': self.id}) 
Example #11
Source File: lancamento.py    From djangoSIGE with MIT License 5 votes vote down vote up
def get(self, request, *args, **kwargs):
        pedido_id = kwargs.get('pk', None)
        pedido = PedidoCompra.objects.get(id=pedido_id)
        pagamentos = pedido.parcela_pagamento.all()
        n_parcelas = pagamentos.count()

        for pagamento in pagamentos:
            saida = Saida()
            saida.fornecedor = pedido.fornecedor
            saida.status = '1'
            saida.data_vencimento = pagamento.vencimento
            saida.descricao = 'Parcela {0}/{1} - Pedido de compra nº{2}'.format(
                str(pagamento.indice_parcela), str(n_parcelas), str(pedido.id))
            saida.valor_total = pagamento.valor_parcela
            saida.valor_liquido = pagamento.valor_parcela
            saida.save()
            mvmt = None
            created = None
            if pagamento.vencimento:
                mvmt, created = MovimentoCaixa.objects.get_or_create(
                    data_movimento=pagamento.vencimento)

            if mvmt:
                if created:
                    self.atualizar_saldos(mvmt)

                self.adicionar_novo_movimento_caixa(
                    lancamento=saida, novo_movimento=mvmt)
                mvmt.save()
                saida.movimento_caixa = mvmt
                saida.save()

        pedido.status = '1'
        pedido.save()

        messages.success(
            request, "<b>Pedido de compra {0} </b>realizado com sucesso.".format(str(pedido.id)))

        return redirect(reverse_lazy('compras:listapedidocompraview')) 
Example #12
Source File: lancamento.py    From djangoSIGE with MIT License 5 votes vote down vote up
def post(self, request, *args, **kwargs):
        conta_id = request.POST['contaId']
        data = {}

        # Tipo conta: 0 = Receber, 1 = Pagar
        if request.POST['tipoConta'] == '0':
            obj = Entrada.objects.get(id=conta_id)
            data['url'] = reverse_lazy(
                'financeiro:editarrecebimentoview', kwargs={'pk': obj.id})
            obj.status = '0'
            obj.data_pagamento = datetime.strptime(
                request.POST['dataPagamento'], '%d/%m/%Y').strftime('%Y-%m-%d')
            obj.save()
            if obj.movimentar_caixa:
                self.atualizar_movimento_caixa(obj)
        elif request.POST['tipoConta'] == '1':
            obj = Saida.objects.get(id=conta_id)
            data['url'] = reverse_lazy(
                'financeiro:editarpagamentoview', kwargs={'pk': obj.id})
            obj.status = '0'
            obj.data_pagamento = datetime.strptime(
                request.POST['dataPagamento'], '%d/%m/%Y').strftime('%Y-%m-%d')
            obj.save()
            if obj.movimentar_caixa:
                self.atualizar_movimento_caixa(obj)

        return JsonResponse(data) 
Example #13
Source File: tributos.py    From djangoSIGE with MIT License 5 votes vote down vote up
def get_context_data(self, **kwargs):
        context = super(GrupoFiscalListView, self).get_context_data(**kwargs)
        context['title_complete'] = 'GRUPOS FISCAIS CADASTRADOS'
        context['add_url'] = reverse_lazy('fiscal:addgrupofiscalview')
        return context 
Example #14
Source File: lancamento.py    From djangoSIGE with MIT License 5 votes vote down vote up
def get_context_data(self, **kwargs):
        context = super(AdicionarSaidaView, self).get_context_data(**kwargs)
        context['title_complete'] = 'ADICIONAR PAGAMENTO'
        context['return_url'] = reverse_lazy('financeiro:listapagamentosview')
        return context 
Example #15
Source File: lancamento.py    From djangoSIGE with MIT License 5 votes vote down vote up
def get_context_data(self, **kwargs):
        context = super(AdicionarEntradaView, self).get_context_data(**kwargs)
        context['title_complete'] = 'ADICIONAR RECEBIMENTO'
        context['return_url'] = reverse_lazy(
            'financeiro:listarecebimentosview')
        return context 
Example #16
Source File: lancamento.py    From djangoSIGE with MIT License 5 votes vote down vote up
def get_context_data(self, **kwargs):
        context = super(AdicionarContaPagarView,
                        self).get_context_data(**kwargs)
        context['title_complete'] = 'ADICIONAR CONTA A PAGAR'
        context['return_url'] = reverse_lazy('financeiro:listacontapagarview')
        return context 
Example #17
Source File: compras.py    From djangoSIGE with MIT License 5 votes vote down vote up
def edit_url(self):
        return reverse_lazy('compras:editarpedidocompraview', kwargs={'pk': self.id}) 
Example #18
Source File: movimento.py    From djangoSIGE with MIT License 5 votes vote down vote up
def get_edit_url(self):
        return reverse_lazy('estoque:detalhartransferenciaestoqueview', kwargs={'pk': self.id}) 
Example #19
Source File: lancamento.py    From djangoSIGE with MIT License 5 votes vote down vote up
def get_context_data(self, **kwargs):
        context = super(EditarContaPagarView, self).get_context_data(**kwargs)
        context['return_url'] = reverse_lazy('financeiro:listacontapagarview')
        return context 
Example #20
Source File: compras.py    From djangoSIGE with MIT License 5 votes vote down vote up
def get(self, request, *args, **kwargs):
        compra_id = kwargs.get('pk', None)
        instance = OrcamentoCompra.objects.get(id=compra_id)
        instance.status = '2'
        instance.save()
        return redirect(reverse_lazy('compras:editarorcamentocompraview', kwargs={'pk': instance.id})) 
Example #21
Source File: compras.py    From djangoSIGE with MIT License 5 votes vote down vote up
def get(self, request, *args, **kwargs):
        orcamento_id = kwargs.get('pk', None)
        orcamento = OrcamentoCompra.objects.get(id=orcamento_id)
        itens_compra = orcamento.itens_compra.all()
        pagamentos = orcamento.parcela_pagamento.all()
        novo_pedido = PedidoCompra()

        for field in orcamento._meta.fields:
            setattr(novo_pedido, field.name, getattr(orcamento, field.name))

        novo_pedido.compra_ptr = None
        novo_pedido.pk = None
        novo_pedido.id = None
        novo_pedido.status = '0'
        orcamento.status = '1'  # Baixado
        orcamento.save()
        novo_pedido.orcamento = orcamento
        novo_pedido.save()

        for item in itens_compra:
            item.pk = None
            item.id = None
            item.save()
            novo_pedido.itens_compra.add(item)

        for pagamento in pagamentos:
            pagamento.pk = None
            pagamento.id = None
            pagamento.save()
            novo_pedido.parcela_pagamento.add(pagamento)

        return redirect(reverse_lazy('compras:editarpedidocompraview', kwargs={'pk': novo_pedido.id})) 
Example #22
Source File: compras.py    From djangoSIGE with MIT License 5 votes vote down vote up
def view_context(self, context):
        context['title_complete'] = 'EDITAR PEDIDO DE COMPRA N°' + \
            str(self.object.id)
        context['return_url'] = reverse_lazy('compras:listapedidocompraview')
        return context 
Example #23
Source File: compras.py    From djangoSIGE with MIT License 5 votes vote down vote up
def view_context(self, context):
        context['title_complete'] = 'EDITAR ORÇAMENTO DE COMPRA N°' + \
            str(self.object.id)
        context['return_url'] = reverse_lazy(
            'compras:listaorcamentocompraview')
        return context 
Example #24
Source File: compras.py    From djangoSIGE with MIT License 5 votes vote down vote up
def view_context(self, context):
        context['title_complete'] = 'PEDIDOS DE COMPRA COM ENTREGA DIA ' + \
            datetime.now().date().strftime('%d/%m/%Y')
        context['add_url'] = reverse_lazy('compras:addpedidocompraview')
        return context 
Example #25
Source File: compras.py    From djangoSIGE with MIT License 5 votes vote down vote up
def view_context(self, context):
        context['title_complete'] = 'PEDIDOS DE COMPRA'
        context['add_url'] = reverse_lazy('compras:addpedidocompraview')
        return context 
Example #26
Source File: compras.py    From djangoSIGE with MIT License 5 votes vote down vote up
def view_context(self, context):
        context['title_complete'] = 'ORÇAMENTOS DE COMPRA COM VENCIMENTO DIA ' + \
            datetime.now().date().strftime('%d/%m/%Y')
        context['add_url'] = reverse_lazy('compras:addorcamentocompraview')
        return context 
Example #27
Source File: compras.py    From djangoSIGE with MIT License 5 votes vote down vote up
def view_context(self, context):
        context['title_complete'] = 'ORÇAMENTOS DE COMPRA VENCIDOS'
        context['add_url'] = reverse_lazy('compras:addorcamentocompraview')
        return context 
Example #28
Source File: compras.py    From djangoSIGE with MIT License 5 votes vote down vote up
def view_context(self, context):
        context['title_complete'] = 'ORÇAMENTOS DE COMPRA'
        context['add_url'] = reverse_lazy('compras:addorcamentocompraview')
        return context 
Example #29
Source File: compras.py    From djangoSIGE with MIT License 5 votes vote down vote up
def view_context(self, context):
        context['title_complete'] = 'ADICIONAR PEDIDO DE COMPRA'
        context['return_url'] = reverse_lazy('compras:listapedidocompraview')
        return context 
Example #30
Source File: views.py    From djangoSIGE with MIT License 5 votes vote down vote up
def post(self, request, *args, **kwargs):
        user = User.objects.get(pk=self.kwargs['pk'])
        if not user.is_superuser:
            user.user_permissions.clear()
            for nova_permissao_codename in request.POST.getlist('select_permissoes'):
                nova_permissao = Permission.objects.get(
                    codename=nova_permissao_codename)
                user.user_permissions.add(nova_permissao)
        messages.success(
            self.request, 'Permissões do usuário <b>{0}</b> atualizadas com sucesso.'.format(user.username))
        return redirect(reverse_lazy('login:usuariodetailview', kwargs={'pk': self.kwargs['pk']}))