• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.reverse函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中subdomains.utils.reverse函数的典型用法代码示例。如果您正苦于以下问题:Python reverse函数的具体用法?Python reverse怎么用?Python reverse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了reverse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_moderate_reject_url

    def test_moderate_reject_url(self):
        '''
        There is a url to moderate a message
        '''
        message = Message.objects.create(
            content='Content 1',
            author_name='Felipe',
            author_email="[email protected]",
            subject='Fiera es una perra feroz',
            public=False,
            writeitinstance=self.writeitinstance,
            persons=[self.person1],
            )
        message.recently_confirmated()
        url = reverse('reject_message', subdomain=message.writeitinstance.slug, kwargs={'pk': message.pk})
        self.client.login(username=self.writeitinstance.owner.username, password='admin')
        response = self.client.post(url)

        message_again = Message.objects.get(id=message.id)
        self.assertTrue(message_again.moderated)
        self.assertFalse(message.public)

        '''Redirecting'''
        allmessages_url = reverse('messages_per_writeitinstance', subdomain=self.writeitinstance.slug)
        self.assertRedirects(response, allmessages_url)
开发者ID:mysociety,项目名称:write-it,代码行数:25,代码来源:manually_create_answers_tests.py


示例2: test_url_update

    def test_url_update(self):
        url = reverse('mailit-template-update', subdomain=self.writeitinstance.slug)

        self.assertTrue(url)

        c = self.client
        c.login(username="fiera", password="feroz")

        data = {
            'subject_template': 'Hello there you have a new mail this is subject',
            'content_template': 'hello there this is the content and you got this message',
            'content_html_template': '<tag>hello there this is the content and you got this message</tag>',
        }

        response = c.post(url, data=data)
        url = reverse('writeitinstance_template_update', subdomain=self.writeitinstance.slug)
        self.assertRedirects(response, url)

        self.assertEquals(
            self.writeitinstance.mailit_template.subject_template,
            data['subject_template'],
            )
        self.assertEquals(
            self.writeitinstance.mailit_template.content_template,
            data['content_template'],
            )
开发者ID:KohoVolit,项目名称:write-it,代码行数:26,代码来源:plugin_test.py


示例3: test_wildcard_reverse

 def test_wildcard_reverse(self):
     # Falls through to settings.ROOT_URLCONF
     subdomain = 'wildcard'
     self.assertEqual(reverse('home', subdomain),
         'http://%s.%s/' % (subdomain, self.DOMAIN))
     self.assertEqual(reverse('view', subdomain),
         'http://%s.%s/view/' % (subdomain, self.DOMAIN))
开发者ID:trezorg,项目名称:django-subdomains,代码行数:7,代码来源:tests.py


示例4: test_there_is_an_endpoint

 def test_there_is_an_endpoint(self):
     """There is an endpoint to which posting updates an answer"""
     reverse(
         "update_answer",
         subdomain=self.message.writeitinstance.slug,
         kwargs={"message_pk": self.answer.message.pk, "pk": self.answer.pk},
     )
开发者ID:KohoVolit,项目名称:write-it,代码行数:7,代码来源:manually_create_answers_tests.py


示例5: send_moderation_mail

    def send_moderation_mail(self):
        plaintext = get_template('nuntium/mails/moderation_mail.txt')
        htmly = get_template('nuntium/mails/moderation_mail.html')
        current_site = Site.objects.get_current()
        current_domain = 'http://'+current_site.domain
        url_rejected = reverse('moderation_rejected', kwargs={
            'slug': self.moderation.key
            })

        url_accept = reverse('moderation_accept', kwargs={
            'slug': self.moderation.key
            })

        d = Context({
            'message': self,
            'url_rejected':url_rejected,
            'url_accept':url_accept
             })

        text_content = plaintext.render(d)
        html_content = htmly.render(d)
        from_email = self.writeitinstance.slug+"@"+settings.DEFAULT_FROM_DOMAIN


        msg = EmailMultiAlternatives(_('Moderation required for\
         a message in WriteIt'),
            text_content,#content
            from_email,#From
            [self.writeitinstance.owner.email]#To
            )
        msg.attach_alternative(html_content, "text/html")
        msg.send()
开发者ID:Hutspace,项目名称:write-it,代码行数:32,代码来源:models.py


示例6: get_absolute_url

 def get_absolute_url(self):
     if self.series:
         return reverse(
             'articles:article',
             args=[self.series.slug, self.slug], subdomain='articles')
     return reverse(
         'articles:article', args=[self.slug], subdomain='articles')
开发者ID:coolharsh55,项目名称:harshp.com,代码行数:7,代码来源:models.py


示例7: test_post_to_create_an_instance

    def test_post_to_create_an_instance(self):
        c = self.client
        c.login(username=self.user.username, password='admin')
        url = reverse('create_writeit_instance')

        response = c.post(url, data=self.data)
        instance = WriteItInstance.objects.get(slug='test-instance-slug', owner=self.user)
        self.assertRedirects(response, reverse('welcome', subdomain=instance.slug))
        self.assertTrue(instance.persons.all())
开发者ID:mysociety,项目名称:write-it,代码行数:9,代码来源:user_section_views_tests.py


示例8: list_all

def list_all(request):
    """Catch all view that combines results from units and challenges."""
    if not request.user.is_authenticated():
        return HttpResponse(status=401)

    group_id = request.GET.get('group', None)
    if group_id is None:
        return HttpResponse(status=400)

    group = get_object_or_404(Group, pk=int(group_id))

    login_base = reverse('app_login', subdomain='accounts',
            scheme=request.scheme)

    units = []
    # TODO: Actually make this list group dependant.
    for unit in LearningUnit.objects.all():
        activity = unit.get_next_activity_for_user(request.user)
        token = create_token(
            request.user.pk,
            group.pk,
            activity.app.pk).decode('utf-8')
        units.append({
            'id': unit.pk,
            'label': unit.label,
            'login': "%s?token=%s" % (login_base, token),
            'token': token})

    challenges = []
    # TODO: Actually make this list group dependant.
    for challenge in Challenge.objects.all():
        app = get_app_by_url(challenge.url)
        if app is not None:
            token = create_token(
                request.user.pk,
                group.pk,
                app.pk).decode('utf-8')
            login_url = "%s?token=%s" % (login_base, token)
        else:
            token = None
            login_url = None

        challenges.append({
            'id': challenge.pk,
            'label': challenge.label,
            'url': route_links_in_text(request, challenge.url, group),
            'login': login_url,
            'token': token,
            'details': "%s/?group=%s" % (
                reverse("collections_challenge_detail", args=(challenge.pk,),
                        subdomain="api",scheme=request.scheme),
                group_id),
            'body': route_links_in_text(request, challenge.body, group),
            })

    return JsonResponse({'items': {'units': units, 'challenges': challenges}})
开发者ID:PerceptumNL,项目名称:edubox-platform,代码行数:56,代码来源:views.py


示例9: test_there_is_an_endpoint

 def test_there_is_an_endpoint(self):
     '''There is an endpoint to which posting updates an answer'''
     reverse(
         'update_answer',
         subdomain=self.message.writeitinstance.slug,
         kwargs={
             'message_pk': self.answer.message.pk,
             'pk': self.answer.pk
             },
         )
开发者ID:mysociety,项目名称:write-it,代码行数:10,代码来源:manually_create_answers_tests.py


示例10: test_there_is_a_url_for_posting_new_webhooks

 def test_there_is_a_url_for_posting_new_webhooks(self):
     '''There is a url where we can post information for a new webhook'''
     url = reverse('writeitinstance_create_webhooks', subdomain=self.writeitinstance.slug)
     self.client.login(username=self.writeitinstance.owner.username, password='admin')
     data = {'url': 'http://new.answers.will.be.posted/here'}
     response = self.client.post(url, data=data)
     url_listing_webhooks = reverse('writeitinstance_webhooks', subdomain=self.writeitinstance.slug)
     self.assertRedirects(response, url_listing_webhooks)
     webhook = self.writeitinstance.answer_webhooks.first()
     self.assertEquals(webhook.url, data['url'])
开发者ID:patcon,项目名称:write-it,代码行数:10,代码来源:webhooks_maintainer_tests.py


示例11: test_post_to_create_an_instance

    def test_post_to_create_an_instance(self):
        your_instances_url = reverse('your-instances')
        c = Client()
        c.login(username=self.user.username, password='admin')
        url = reverse('create_writeit_instance')
        self.assertTrue(url)

        response = c.post(url, data=self.data)
        self.assertRedirects(response, your_instances_url)
        instance = WriteItInstance.objects.get(Q(name='instance'), Q(owner=self.user))
        self.assertTrue(instance.persons.all())
开发者ID:Hutspace,项目名称:write-it,代码行数:11,代码来源:user_section_views_tests.py


示例12: test_it_redirects_to_your_instances

    def test_it_redirects_to_your_instances(self):
        '''When get to create an instance it redirects to your instances'''
        url = reverse('create_writeit_instance')
        c = Client()

        response = c.get(url)
        c.login(username=self.user.username, password='admin')

        response = c.get(url)
        your_instances_url = reverse('your-instances')
        self.assertRedirects(response, your_instances_url)
开发者ID:Hutspace,项目名称:write-it,代码行数:11,代码来源:user_section_views_tests.py


示例13: test_go_straight_to_draft_given_person_id

    def test_go_straight_to_draft_given_person_id(self):
        url = reverse('write_message_step',
            subdomain=self.writeitinstance.slug,
            kwargs={'step': 'who'})
        url2 = reverse('write_message_step',
            subdomain=self.writeitinstance.slug,
            kwargs={'step': 'draft'})

        response = self.client.get(url, {'person_id': self.person1.popit_id})
        self.assertRedirects(response, url2)
        response = self.client.get(url2)
        self.assertEquals(response.context['message']['persons'][0].id, self.person1.id)
开发者ID:ciudadanointeligente,项目名称:write-it,代码行数:12,代码来源:message_creation_tests.py


示例14: test_insights_about_pulling_popit_even_if_everything_goes_ok

 def test_insights_about_pulling_popit_even_if_everything_goes_ok(self):
     '''Return some insights even if everything goes ok'''
     self.client.login(username="fieraferoz", password="feroz")
     url = reverse('relate-writeit-popit', subdomain=self.writeitinstance.slug)
     data = self.data
     response = self.client.post(url, data=data)
     expected_follow_url = reverse('relate-writeit-popit', subdomain=self.writeitinstance.slug)
     self.assertRedirects(response, expected_follow_url)
     response = self.client.get(expected_follow_url)
     messages = list(response.context['messages'])
     self.assertTrue(messages)
     self.assertEquals(messages[0].message, _("We are now getting the people from popit"))
开发者ID:schlos,项目名称:write-it,代码行数:12,代码来源:popit_instance_update_tests.py


示例15: test_post_to_url

    def test_post_to_url(self):
        '''When I post to the URL then it deletes the writeitinstance'''
        url = reverse('delete_an_instance', subdomain=self.writeitinstance.slug)
        request = self.factory.post(url)
        request.user = self.writeitinstance.owner
        response = WriteItDeleteView.as_view()(request)
        # Now it should be deleted
        self.assertFalse(WriteItInstance.objects.filter(id=self.writeitinstance.id))

        your_instances_url = reverse('your-instances')
        self.assertTrue(response)
        self.assertEquals(response.status_code, 302)
        self.assertEquals(response.url, your_instances_url)
开发者ID:KohoVolit,项目名称:write-it,代码行数:13,代码来源:delete_an_instance_tests.py


示例16: test_posting_to_that_url_rejects_the_message

    def test_posting_to_that_url_rejects_the_message(self):
        """When posting to reject a message it marks it private"""
        url = reverse("reject_message", subdomain=self.writeitinstance.slug, kwargs={"pk": self.message.pk})

        c = self.client
        c.login(username=self.writeitinstance.owner.username, password="admin")
        response = c.post(url)
        """It should redirect to the see all messages url"""
        allmessages_url = reverse("messages_per_writeitinstance", subdomain=self.writeitinstance.slug)
        self.assertRedirects(response, allmessages_url)
        message = Message.objects.get(pk=self.message.pk)
        self.assertFalse(message.public)
        self.assertTrue(message.moderated)
开发者ID:KohoVolit,项目名称:write-it,代码行数:13,代码来源:manually_create_answers_tests.py


示例17: test_posting_to_that_url_rejects_the_message

    def test_posting_to_that_url_rejects_the_message(self):
        '''When posting to reject a message it marks it private'''
        url = reverse('reject_message', subdomain=self.writeitinstance.slug, kwargs={'pk': self.message.pk})

        c = self.client
        c.login(username=self.writeitinstance.owner.username, password='admin')
        response = c.post(url)
        '''It should redirect to the see all messages url'''
        allmessages_url = reverse('messages_per_writeitinstance', subdomain=self.writeitinstance.slug)
        self.assertRedirects(response, allmessages_url)
        message = Message.objects.get(pk=self.message.pk)
        self.assertFalse(message.public)
        self.assertTrue(message.moderated)
开发者ID:mysociety,项目名称:write-it,代码行数:13,代码来源:manually_create_answers_tests.py


示例18: test_post_to_the_url

    def test_post_to_the_url(self):
        '''It should reject the get to that url'''
        self.client.login(username="fieraferoz", password="feroz")
        url = reverse('relate-writeit-popit', subdomain=self.writeitinstance.slug)
        response = self.client.post(url, data=self.data)
        self.assertEquals(response.status_code, 302)
        basic_update_url = reverse('relate-writeit-popit', subdomain=self.writeitinstance.slug)

        self.assertRedirects(response, basic_update_url)

        records = WriteitInstancePopitInstanceRecord.objects.filter(writeitinstance=self.writeitinstance)
        self.assertEquals(records.count(), 1)
        # this means that it has persons related to it
        self.assertTrue(self.writeitinstance.persons.all())
开发者ID:KohoVolit,项目名称:write-it,代码行数:14,代码来源:popit_instance_update_tests.py


示例19: test_set_max_recipients_to_1

 def test_set_max_recipients_to_1(self):
     url = reverse('writeitinstance_recipients_settings_update', subdomain=self.writeitinstance.slug)
     modified_data = {'maximum_recipients': 1}
     self.client.login(username=self.owner.username, password='admin')
     self.client.post(url, data=modified_data, follow=True)
     writeitinstance = WriteItInstance.objects.get(id=self.writeitinstance.id)
     self.assertEquals(writeitinstance.config.maximum_recipients, 1)
开发者ID:mysociety,项目名称:write-it,代码行数:7,代码来源:user_section_views_tests.py


示例20: test_rate_limit_cannot_be_negative

 def test_rate_limit_cannot_be_negative(self):
     url = reverse('writeitinstance_ratelimiter_update', subdomain=self.writeitinstance.slug)
     modified_data = {'rate_limiter': -1}
     self.client.login(username=self.owner.username, password='admin')
     response = self.client.post(url, data=modified_data, follow=True)
     self.assertTrue(response.context['form'].errors)
     self.assertTrue(response.context['form'].errors['rate_limiter'])
开发者ID:mysociety,项目名称:write-it,代码行数:7,代码来源:user_section_views_tests.py



注:本文中的subdomains.utils.reverse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sublime.active_window函数代码示例发布时间:2022-05-27
下一篇:
Python Locale._函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap