本文整理汇总了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'])
示例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'])