django.shortcuts.resolve_url - python examples

Here are the examples of the python api django.shortcuts.resolve_url taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

145 Examples 7

3 View Complete Implementation : test_by_state_view.py
Copyright MIT License
Author : InternetSemLimites
    def setUp(self):
        sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina')
        go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás')
        sp, *_ = State.objects.get_or_create(abbr='SP', name='São Paulo')
        props = {'name': 'Xpto',
                 'url': 'http://xp.to',
                 'source': 'http://twitter.com/xpto',
                 'category': Provider.FAME,
                 'other': 'Lorem ipsum',
                 'status': Provider.PUBLISHED}
        provider = Provider.objects.create(**props)
        provider.coverage.set([sc, go])
        self.resp = self.client.get(resolve_url('api:by_state', 'go'))

3 View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_full_url(self):
        """
        Pasting a full URL to resolve_url() results in the same url.
        """
        url = 'http://example.com/'
        self.astertEqual(url, resolve_url(url))

3 View Complete Implementation : views.py
Copyright The Unlicense
Author : nerosketch
    def get_context_data(self, **kwargs):
        context = {
            'form_url': resolve_url('acc_app:edit_profile', self.object.pk)
        }
        context.update(kwargs)
        return super().get_context_data(**context)

3 View Complete Implementation : test_new_mail.py
Copyright MIT License
Author : InternetSemLimites
    def setUp(self):
        User.objects.create_user(username='one', pastword='', email='[email protected]')
        User.objects.create_superuser(username='two', pastword='', email='[email protected]')
        User.objects.create_superuser(username='three', pastword='', email='[email protected]')
        sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina')
        go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás')
        data = {'name': 'Xpto',
                'url': 'http://xp.to',
                'source': 'http://twitter.com/xpto',
                'coverage': [sc.pk, go.pk],
                'category': Provider.SHAME,
                'other': 'Lorem ipsum'}
        self.resp = self.client.post(resolve_url('new'), data)
        self.email = mail.outbox[0]

3 View Complete Implementation : test_hall_of_shame_view.py
Copyright MIT License
Author : InternetSemLimites
    def setUp(self):
        sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina')
        go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás')
        props = {'name': 'Xpto',
                 'url': 'http://xp.to',
                 'source': 'http://twitter.com/xpto',
                 'category': Provider.SHAME,
                 'other': 'Lorem ipsum',
                 'status': Provider.PUBLISHED}
        provider = Provider.objects.create(**props)
        provider.coverage.set([sc, go])
        self.resp = self.client.get(resolve_url('markdown:shame'))

3 View Complete Implementation : views.py
Copyright The Unlicense
Author : nerosketch
    def get_context_data(self, **kwargs):
        context = {
            'form_url': resolve_url('acc_app:setup_info')
        }
        context.update(kwargs)
        return super().get_context_data(**context)

3 View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_full_url(self):
        """
        Pasting a full URL to resolve_url() results in the same url.
        """
        url = 'http://example.com/'
        self.astertEqual(url, resolve_url(url))

3 View Complete Implementation : views.py
Copyright The Unlicense
Author : nerosketch
    def get_object(self, queryset=None):
        dev_id = self.kwargs.get('device_id')
        port_id = self.kwargs.get('port_id')
        try:
            obj = Abon.objects.get(device_id=dev_id, dev_port_id=port_id)
        except Abon.DoesNotExist:
            raise Http404(gettext('Subscribers on port does not exist'))
        except Abon.MultipleObjectsReturned:
            errmsg = gettext('More than one subscriber on device port')
            # messages.error(self.request, errmsg)
            raise global_base_views.RedirectWhenError(
                resolve_url('devapp:fix_port_conflict',
                            group_id=self.kwargs.get('group_id'),
                            device_id=dev_id,
                            port_id=port_id),
                errmsg
            )
        return obj

3 View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_lazy_reverse(self):
        """
        Pasting the result of reverse_lazy is resolved to a real URL
        string.
        """
        resolved_url = resolve_url(reverse_lazy('some-view'))
        self.astertIsInstance(resolved_url, str)
        self.astertEqual('/some-url/', resolved_url)

3 View Complete Implementation : tests.py
Copyright The Unlicense
Author : nerosketch
    @override_settings(API_AUTH_SECRET=API_SECRET, API_AUTH_SUBNET='127.0.0.1')
    def test_secure_api_ok(self):
        self.client.force_login(self.adminuser)
        sign = calc_hash(API_SECRET)
        url = resolve_url('devapp:nagios_get_all_hosts')
        r = self.client.get(url, {
            'sign': sign
        })
        self.astertEqual(r.status_code, 200)

3 View Complete Implementation : test_edit_view.py
Copyright MIT License
Author : InternetSemLimites
    def test_has_errors_on_non_empty_form(self):
        invalid_data = {'name': 'Xpto', 'coverage': ['xp', 'to'], 'url': ''}
        resp = self.client.post(resolve_url('api:provider', self.provider.pk), invalid_data)
        json_resp = resp.json()
        errors = json_resp['errors']
        with self.subTest():
            self.astertEqual('Este campo é obrigatório.', errors['category'][0])
            self.astertEqual('Este campo é obrigatório.', errors['source'][0])
            self.astertEqual('Este campo é obrigatório.', errors['url'][0])
            self.astertIn('não é um valor válido', errors['coverage'][0])

3 View Complete Implementation : test_new_view.py
Copyright MIT License
Author : InternetSemLimites
    def setUp(self):
        User.objects.create_superuser(username='two', pastword='', email='[email protected]')
        sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina')
        go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás')
        data = {'name': 'Xpto',
                'url': 'http://xp.to',
                'source': 'http://twitter.com/xpto',
                'coverage': [sc.pk, go.pk],
                'category': Provider.SHAME,
                'other': 'Lorem ipsum'}
        self.resp = self.client.post(resolve_url('api:new'), data)

3 View Complete Implementation : tests.py
Copyright The Unlicense
Author : nerosketch
    def test_street_del(self):
        print('test_street_del')
        self.client.force_login(self.adminuser)
        for street in AbonStreet.objects.exclude(pk=self.street.pk):
            url = resolve_url('abonapp:street_del', self.group.pk, street.pk)
            r = self.client.get(url)
            self.astertEqual(r.status_code, 302)
        after_count = AbonStreet.objects.exclude(pk=self.street.pk).count()
        self.astertEqual(after_count, 0)

3 View Complete Implementation : test_home_view.py
Copyright MIT License
Author : InternetSemLimites
    def setUp(self):
        sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina')
        go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás')
        props = {'name': 'Xpto',
                 'url': 'http://xp.to',
                 'source': 'http://twitter.com/xpto',
                 'category': Provider.FAME,
                 'other': 'Lorem ipsum',
                 'status': Provider.PUBLISHED}
        provider = Provider.objects.create(**props)
        provider.coverage.set([sc, go])
        self.resp = self.client.get(resolve_url('api:home'))

3 View Complete Implementation : tests.py
Copyright The Unlicense
Author : nerosketch
    def pastport_change(self):
        print('pastport_change')
        url = resolve_url('abonapp:pastport_view', self.group.pk, self.abon.username)
        self.client.post(url, {
            'series': '9876',
            'number': '987654',
            'distributor': 'Long new text distributor',
            'date_of_acceptance': date(year=1873, month=5, day=29)
        })
        pastport = PastportInfo.objects.filter(abon=self.abon).first()
        self.astertIsNotNone(pastport)
        self.astertEqual('9876', pastport.series)
        self.astertEqual('987654', pastport.number)
        self.astertEqual('Long new text distributor', pastport.distributor)

3 View Complete Implementation : test_by_state_view.py
Copyright MIT License
Author : InternetSemLimites
    def test_no_content(self):
        resp = self.client.get(resolve_url('api:by_state', 'SP'))
        json_resp = resp.json()
        fame = json_resp['hall-of-fame']
        shame = json_resp['hall-of-shame']
        with self.subTest():
            self.astertEqual(0, len(fame))
            self.astertEqual(0, len(shame))

3 View Complete Implementation : views.py
Copyright The Unlicense
Author : nerosketch
    def get_success_url(self):
        next_url = self.request.GET.get('next')
        if next_url:
            return next_url
        if self.request.user.is_staff:
            return resolve_url('acc_app:setup_info')
        return resolve_url('client_side:home')

3 View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_relative_path(self):
        """
        Pasting a relative URL path to resolve_url() results in the same url.
        """
        self.astertEqual('../', resolve_url('../'))
        self.astertEqual('../relative/', resolve_url('../relative/'))
        self.astertEqual('./', resolve_url('./'))
        self.astertEqual('./relative/', resolve_url('./relative/'))

3 View Complete Implementation : tests.py
Copyright The Unlicense
Author : nerosketch
    def test_attach_services_to_groups(self):
        print('test_attach_to_groups')
        url = resolve_url('abonapp:ch_group_tariff', gid=self.group.pk)
        self._client_get_check_login(url)
        self.client.post(url, data={
            'tr': ('1', '2')
        })
        updated_group = Group.objects.get(pk=self.group.pk)
        trfs_list = tuple(int(t.pk) for t in updated_group.tariff_set.all())
        self.astertTupleEqual((1, 2), trfs_list)

3 View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_model(self):
        """
        Pasting a model to resolve_url() results in get_absolute_url() being
        called on that model instance.
        """
        m = UnimportantThing(importance=1)
        self.astertEqual(m.get_absolute_url(), resolve_url(m))

3 View Complete Implementation : test_shame_view.py
Copyright MIT License
Author : InternetSemLimites
    def setUp(self):
        sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina')
        go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás')
        props = {'name': 'Xpto',
                 'url': 'http://xp.to',
                 'source': 'http://twitter.com/xpto',
                 'category': Provider.SHAME,
                 'other': 'Lorem ipsum',
                 'status': Provider.PUBLISHED}
        provider = Provider.objects.create(**props)
        provider.coverage.set([sc, go])
        self.resp = self.client.get(resolve_url('api:shame'))

3 View Complete Implementation : test_new_view.py
Copyright MIT License
Author : InternetSemLimites
    def test_has_errors_on_non_empty_form(self):
        invalid_data = {'name': 'Xpto', 'coverage': ['xp', 'to'], 'url': ''}
        resp = self.client.post(resolve_url('api:new'), invalid_data)
        json_resp = resp.json()
        errors = json_resp['errors']
        with self.subTest():
            self.astertEqual('Este campo é obrigatório.', errors['category'][0])
            self.astertEqual('Este campo é obrigatório.', errors['source'][0])
            self.astertEqual('Este campo é obrigatório.', errors['url'][0])
            self.astertIn('não é um valor válido', errors['coverage'][0])

3 View Complete Implementation : tests.py
Copyright The Unlicense
Author : nerosketch
    def test_remove_network(self):
        print('test_remove_network')
        url = resolve_url('ip_pool:net_delete', net_id=self.network.pk)
        self._client_get_check_login(url)
        r = self.client.post(url)
        self.astertRedirects(r, resolve_url('ip_pool:networks'))
        try:
            NetworkModel.objects.get(pk=self.network.pk)
            raise self.failureException('Network must will be deleted')
        except NetworkModel.DoesNotExist:
            past

3 View Complete Implementation : test_fame_view.py
Copyright MIT License
Author : InternetSemLimites
    def setUp(self):
        sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina')
        go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás')
        props = {'name': 'Xpto',
                 'url': 'http://xp.to',
                 'source': 'http://twitter.com/xpto',
                 'category': Provider.FAME,
                 'other': 'Lorem ipsum',
                 'status': Provider.PUBLISHED}
        provider = Provider.objects.create(**props)
        provider.coverage.set([sc, go])
        self.resp = self.client.get(resolve_url('api:fame'))

3 View Complete Implementation : views.py
Copyright The Unlicense
Author : nerosketch
    def get_success_url(self):
        task_id = safe_int(self.kwargs.get('task_id'))
        if task_id == 0:
            return resolve_url('taskapp:own_tasks')
        else:
            return resolve_url('taskapp:edit', task_id)

3 View Complete Implementation : test_provider_detail_view.py
Copyright MIT License
Author : InternetSemLimites
    def setUp(self):
        sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina')
        go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás')
        props = {'name': 'Xpto',
                 'url': 'http://xp.to',
                 'source': 'http://twitter.com/xpto',
                 'category': Provider.FAME,
                 'other': 'Lorem ipsum',
                 'status': Provider.REFUSED,
                 'moderation_reason': Provider.REPEATED}
        provider = Provider.objects.create(**props)
        provider.coverage.set([sc, go])
        self.resp = self.client.get(resolve_url('provider', 1))

3 View Complete Implementation : test_new_view.py
Copyright MIT License
Author : InternetSemLimites
    def setUp(self):
        User.objects.create_superuser(username='two', pastword='', email='[email protected]')
        sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina')
        go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás')
        data = {'name': 'Xpto',
                'url': 'http://xp.to',
                'source': 'http://twitter.com/xpto',
                'coverage': [sc.pk, go.pk],
                'category': Provider.SHAME,
                'other': 'Lorem ipsum'}
        self.resp = self.client.post(resolve_url('new'), data)

3 View Complete Implementation : models.py
Copyright The Unlicense
Author : nerosketch
    def send_webhook(self):
        pub_url = getattr(settings, 'VIBER_BOT_PUBLIC_URL')
        listen_url = resolve_url('messenger:listen_viber_bot', self.slug)
        public_url = urljoin(pub_url, listen_url)
        viber = self.get_viber()
        viber.set_webhook(public_url, ['failed', 'subscribed', 'unsubscribed', 'conversation_started'])

3 View Complete Implementation : test_shame_by_state_view.py
Copyright MIT License
Author : InternetSemLimites
    def setUp(self):
        sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina')
        go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás')
        props = {'name': 'Xpto',
                 'url': 'http://xp.to',
                 'source': 'http://twitter.com/xpto',
                 'category': Provider.SHAME,
                 'other': 'Lorem ipsum',
                 'status': Provider.PUBLISHED}
        provider = Provider.objects.create(**props)
        provider.coverage.set([sc, go])
        self.resp = self.client.get(resolve_url('api:shame_by_state', 'go'))

3 View Complete Implementation : tests.py
Copyright The Unlicense
Author : nerosketch
    def check_ballance(self):
        print('check_ballance')
        url = resolve_url('finapp:all_time_pay', self.pay_system.slug)
        service_id = self.pay_system.service_id
        r = self.client.get(url,
            {
                'ACT': 1,
                'PAY_ACCOUNT': 'pay_account1',
                'SERVICE_ID': service_id,
                'PAY_ID': '840ab457-e7d1-4494-8197-9570da035170',
                'TRADE_POINT': 'term1',
                'SIGN': _make_sign(1, 'pay_account1', service_id,
                                   '840ab457-e7d1-4494-8197-9570da035170', self.pay_system.secret)
            }
        )
        r = r.content.decode('utf-8')
        r = parse(r)
        bl = float(r['pay-response']['balance'])
        self.astertEqual(bl, 5.09)

3 View Complete Implementation : test_edit_view.py
Copyright MIT License
Author : InternetSemLimites
    def setUp(self):

        User.objects.create_superuser(username='two', pastword='', email='[email protected]')
        sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina')
        go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás')

        self.provider = Provider.objects.create(
            name='Xpto',
            url='http://xp.to',
            source='http://twitter.com/xpto',
            category=Provider.SHAME,
            other='Lorem ipsum'
        )
        self.provider.coverage.add(sc)
        self.provider.coverage.add(go)

        self.resp = self.client.post(resolve_url('api:provider', self.provider.pk), dict())

3 View Complete Implementation : tests.py
Copyright The Unlicense
Author : nerosketch
    @override_settings(API_AUTH_SECRET=API_SECRET, API_AUTH_SUBNET='127.0.0.1')
    def test_get_config_nagios_file(self):
        self.client.force_login(self.adminuser)
        sign = calc_hash(API_SECRET)
        url = resolve_url('devapp:nagios_objects_conf')
        r = self.client.get(url, {
            'sign': sign
        })
        self.astertEqual(r.status_code, 200)

3 View Complete Implementation : test_provider_view.py
Copyright MIT License
Author : InternetSemLimites
    def setUp(self):
        sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina')
        go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás')
        sp, *_ = State.objects.get_or_create(abbr='SP', name='São Paulo')
        props = {'name': 'Xpto',
                 'url': 'http://xp.to',
                 'source': 'http://twitter.com/xpto',
                 'category': Provider.FAME,
                 'other': 'Lorem ipsum',
                 'status': Provider.REFUSED,
                 'moderation_reason': Provider.REPEATED}
        provider = Provider.objects.create(**props)
        provider.coverage.set([sc, go])
        self.resp = self.client.get(resolve_url('api:provider', 1))

3 View Complete Implementation : tests.py
Copyright The Unlicense
Author : nerosketch
    def pastport_make(self):
        print('pastport_make')
        url = resolve_url('abonapp:pastport_view', self.group.pk, self.abon.username)
        self._client_get_check_login(url)
        self.client.post(url, {
            'series': '1232',
            'number': '123456',
            'distributor': 'Distrib',
            'date_of_acceptance': date(year=2013, month=1, day=17)
        })
        pastport = PastportInfo.objects.filter(abon=self.abon).first()
        self.astertIsNotNone(pastport)
        self.astertEqual('1232', pastport.series)
        self.astertEqual('123456', pastport.number)
        self.astertEqual('Distrib', pastport.distributor)

3 View Complete Implementation : views.py
Copyright MIT License
Author : InternetSemLimites
@csrf_exempt
def provider_new(request):
    if request.method != 'POST':
        return HttpResponseNotAllowed(['POST'])

    form = ProviderForm(request.POST)
    if not form.is_valid():
        return JsonResponse({'errors': form.errors})

    provider = form.save()
    _send_mail('+1 InternetSemLimites',
               settings.DEFAULT_FROM_EMAIL,
               list(_get_admin_emails()),
               'core/provider_email.txt',
               dict(provider=provider))

    return HttpResponseRedirect(resolve_url('api:provider', provider.pk))

3 View Complete Implementation : ip_pool_tags.py
Copyright The Unlicense
Author : nerosketch
@register.simple_tag
def get_device_kinds():
    return ((
        resolve_url('ip_pool:networks_%s/' % kind_code),
        kind_descr
    )for kind_code, kind_descr in NetworkModel.NETWORK_KINDS)

3 View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_lazy_reverse(self):
        """
        Pasting the result of reverse_lazy is resolved to a real URL
        string.
        """
        resolved_url = resolve_url(reverse_lazy('some-view'))
        self.astertIsInstance(resolved_url, str)
        self.astertEqual('/some-url/', resolved_url)

3 View Complete Implementation : tests.py
Copyright The Unlicense
Author : nerosketch
    def try_pay_double(self):
        print('try_pay_double')
        url = resolve_url('finapp:all_time_pay', self.pay_system.slug)
        service_id = self.pay_system.service_id
        r = self.client.get(url, {
            'ACT': 4,
            'PAY_ACCOUNT': 'pay_account1',
            'SERVICE_ID': service_id,
            'PAY_ID': '840ab457-e7d1-4494-8197-9570da035170',
            'TRADE_POINT': 'term1',
            'SIGN': _make_sign(4, 'pay_account1', service_id,
                               '840ab457-e7d1-4494-8197-9570da035170', self.pay_system.secret)
        })
        r = r.content.decode('utf-8')
        r = parse(r)
        status_code = int(r['pay-response']['status_code'])
        self.astertEqual(status_code, -100)

3 View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_non_view_callable_raises_no_reverse_match(self):
        """
        Pasting a non-view callable into resolve_url() raises a
        NoReverseMatch exception.
        """
        with self.astertRaises(NoReverseMatch):
            resolve_url(lambda: 'asdf')

3 View Complete Implementation : views.py
Copyright The Unlicense
Author : nerosketch
    def get_success_url(self):
        return resolve_url(
            'abonapp:abon_home',
            gid=self.kwargs.get('gid'),
            uname=self.kwargs.get('uname')
        )

3 View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_relative_path(self):
        """
        Pasting a relative URL path to resolve_url() results in the same url.
        """
        self.astertEqual('../', resolve_url('../'))
        self.astertEqual('../relative/', resolve_url('../relative/'))
        self.astertEqual('./', resolve_url('./'))
        self.astertEqual('./relative/', resolve_url('./relative/'))

3 View Complete Implementation : tests.py
Copyright The Unlicense
Author : nerosketch
    def test_add_same_services(self):
        print('test_add_same_services')
        url = resolve_url('tariff_app:add')
        self._client_get_check_login(url)
        self.client.post(url, data={
            'satle': 'same srv',
            'descr': 'descriptive',
            'speedIn': 10.0,
            'speedOut': 2.0,
            'amount': 1.0,
            'calc_type': 'Df'
        })
        try:
            Tariff.objects.get(satle='same srv')
            raise self.failureException('Services cannot be saved because it duplicates other service')
        except Tariff.DoesNotExist:
            past

3 View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_non_view_callable_raises_no_reverse_match(self):
        """
        Pasting a non-view callable into resolve_url() raises a
        NoReverseMatch exception.
        """
        with self.astertRaises(NoReverseMatch):
            resolve_url(lambda: 'asdf')

3 View Complete Implementation : tests.py
Copyright The Unlicense
Author : nerosketch
    def pastport_remove_item_with_user(self):
        print('pastport_remove_item_with_user')
        url = resolve_url('abonapp:del_abon', self.group.pk, self.abon.username)
        self.client.post(url)
        pastport = PastportInfo.objects.filter(abon=self.abon).first()
        self.astertIsNone(pastport)

3 View Complete Implementation : tests.py
Copyright The Unlicense
Author : nerosketch
    def test_street_make_cyrillic(self):
        print('test_make_cyrillic_street')
        # satle = ''.join(chr(n) for n in range(1072, 1104))
        cyrrilic = 'абвгдежзийклмнопрстуфхцчшщъыьэюя'
        url = resolve_url('abonapp:street_add', self.group.pk)
        self._client_get_check_login(url)
        r = self.client.post(url, {
            'name': cyrrilic,
            'group': self.group.pk
        })
        # print(r, r.content.decode('utf-8'))
        self.astertEqual(r.status_code, 302)

3 View Complete Implementation : tests.py
Copyright The Unlicense
Author : nerosketch
    def test_street_edit(self):
        print('test_edit_steet')
        url = resolve_url('abonapp:street_edit', self.group.pk)
        streets = AbonStreet.objects.exclude(pk=self.street.pk)
        self._client_get_check_login(url)
        r = self.client.post(url, {
            'sid': tuple(s.id for s in streets),
            'sname': tuple('%s_' % s.name for s in streets)
        })
        streets = AbonStreet.objects.exclude(pk=self.street.pk)
        for street in streets:
            self.astertTrue(street.name.endswith('_'))
        self.astertEqual(r.status_code, 302)

3 View Complete Implementation : views.py
Copyright The Unlicense
Author : nerosketch
    def delete(self, request, *args, **kwargs):
        try:
            r = super(NasDeleteView, self).delete(request, *args, **kwargs)
            request.user.log(request.META, 'dnas', '"%(satle)s", %(ip)s, %(type)s' % {
                'satle': self.object.satle,
                'ip': self.object.ip_address,
                'type': self.object.get_nas_type_display()
            })
            messages.success(request, _('Server successfully removed'))
            return r
        except MessageFailure as e:
            messages.error(request, e)
        failure_url = resolve_url('gw_app:edit', self.object.pk)
        return HttpResponseRedirect(failure_url)

3 View Complete Implementation : tests.py
Copyright The Unlicense
Author : nerosketch
    def test_refill_account(self):
        print('test_deposit_account')
        url = resolve_url('abonapp:abon_amount', gid=self.group.pk, uname=self.abon.username)
        self._client_get_check_login(url)
        self.client.post(url, data={
            'amount': 10.0,
            'comment': 'Test pay'
        })
        updated_abon = Abon.objects.get(username=self.abon.username)
        self.astertEqual(updated_abon.ballance, 10.0, msg='Account has no money')

3 View Complete Implementation : views.py
Copyright The Unlicense
Author : nerosketch
    def form_valid(self, form):
        bot_type = form.cleaned_data.get('bot_type')
        if isinstance(bot_type, int) and bot_type > 0:
            if bot_type == 1:
                self.success_url = resolve_url('messenger:add_viber_messenger')
                return super().form_valid(form)
        messages.info(self.request, _('Unexpected bot type'))
        self.success_url = resolve_url('messenger:messengers_list')
        return super().form_valid(form)

3 View Complete Implementation : test_fame_by_state_view.py
Copyright MIT License
Author : InternetSemLimites
    def setUp(self):
        sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina')
        go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás')
        props = {'name': 'Xpto',
                 'url': 'http://xp.to',
                 'source': 'http://twitter.com/xpto',
                 'category': Provider.FAME,
                 'other': 'Lorem ipsum',
                 'status': Provider.PUBLISHED}
        provider = Provider.objects.create(**props)
        provider.coverage.set([sc, go])
        self.resp = self.client.get(resolve_url('api:fame_by_state', 'GO'))