本文整理匯總了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'])