当前位置: 首页>>代码示例>>Python>>正文


Python DeferredAward.claim方法代码示例

本文整理汇总了Python中badger.models.DeferredAward.claim方法的典型用法代码示例。如果您正苦于以下问题:Python DeferredAward.claim方法的具体用法?Python DeferredAward.claim怎么用?Python DeferredAward.claim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在badger.models.DeferredAward的用法示例。


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

示例1: test_claim_code_shows_awards_after_claim

# 需要导入模块: from badger.models import DeferredAward [as 别名]
# 或者: from badger.models.DeferredAward import claim [as 别名]
    def test_claim_code_shows_awards_after_claim(self):
        """Claim code URL should lead to award detail or list after claim"""
        user1 = self._get_user(username="creator",
                               email="[email protected]")
        user2 = self._get_user(username="awardee",
                               email="[email protected]")
        b1 = Badge.objects.create(creator=user1, unique=False,
                                  title="Badge for claim viewing")
        da = DeferredAward(badge=b1, creator=user1, reusable=True)
        da.save()

        url = reverse('badger.views.claim_deferred_award',
                      args=(da.claim_code,))

        # First claim leads to a single award detail page.
        award = da.claim(user2)
        r = self.client.get(url, follow=False)
        eq_(302, r.status_code)
        award_url = reverse('badger.views.award_detail',
                            args=(award.badge.slug, award.pk))
        ok_(award_url in r['Location'])

        # Second claim leads to a list of awards.
        award = da.claim(user2)
        r = self.client.get(url, follow=False)
        eq_(302, r.status_code)
        list_url = reverse('badger.views.awards_list',
                            args=(award.badge.slug,))
        ok_(list_url in r['Location'])
开发者ID:cheekybastard,项目名称:django-badger,代码行数:31,代码来源:test_views.py

示例2: test_claim_code_shows_awards_after_claim

# 需要导入模块: from badger.models import DeferredAward [as 别名]
# 或者: from badger.models.DeferredAward import claim [as 别名]
    def test_claim_code_shows_awards_after_claim(self):
        """Claim code URL should lead to award detail or list after claim"""
        user1 = self._get_user(username="creator",
                               email="[email protected]")
        user2 = self._get_user(username="awardee",
                               email="[email protected]")
        b1 = Badge.objects.create(creator=user1, unique=False,
                                  title="Badge for claim viewing")
        da = DeferredAward(badge=b1, creator=user1)
        da.save()

        url = da.get_claim_url()

        # Before claim, code URL leads to claim page. 
        r = self.client.get(url, follow=False)
        eq_(200, r.status_code)
        doc = pq(r.content)
        form = doc('form#claim_award')

        # After claim, code URL leads to a single award detail page.
        award = da.claim(user2)
        r = self.client.get(url, follow=False)
        eq_(302, r.status_code)
        award_url = reverse('badger.views.award_detail',
                            args=(award.badge.slug, award.pk))
        ok_(award_url in r['Location'])
开发者ID:askvictor,项目名称:django-badger,代码行数:28,代码来源:test_views.py


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