本文整理汇总了Python中badger.models.DeferredAward.get_claim_url方法的典型用法代码示例。如果您正苦于以下问题:Python DeferredAward.get_claim_url方法的具体用法?Python DeferredAward.get_claim_url怎么用?Python DeferredAward.get_claim_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类badger.models.DeferredAward
的用法示例。
在下文中一共展示了DeferredAward.get_claim_url方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_claim_code_shows_awards_after_claim
# 需要导入模块: from badger.models import DeferredAward [as 别名]
# 或者: from badger.models.DeferredAward import get_claim_url [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'])
示例2: test_grant_deferred_award
# 需要导入模块: from badger.models import DeferredAward [as 别名]
# 或者: from badger.models.DeferredAward import get_claim_url [as 别名]
def test_grant_deferred_award(self):
"""Deferred award for a badge can be granted to an email address."""
deferred_email = "[email protected]"
user1 = self._get_user(username="creator", email="[email protected]")
b1 = Badge.objects.create(creator=user1, title="Badge to defer")
da = DeferredAward(badge=b1, creator=user1, email='[email protected]')
da.save()
url = da.get_claim_url()
self.client.login(username="creator", password="trustno1")
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
doc = pq(r.content)
form = doc('form#grant_award')
eq_(1, form.length)
eq_(1, form.find('*[name=email]').length)
eq_(1, form.find('input.submit,button.submit').length)
r = self.client.post(url, dict(
is_grant=1, email=deferred_email,
), follow=False)
user2 = self._get_user(username="awardee", email=deferred_email)
self.client.login(username="awardee", password="trustno1")
r = self.client.get(reverse('badger.views.detail',
args=(b1.slug,)), follow=True)
ok_(b1.is_awarded_to(user2))
示例3: test_deferred_award_immediate_claim
# 需要导入模块: from badger.models import DeferredAward [as 别名]
# 或者: from badger.models.DeferredAward import get_claim_url [as 别名]
def test_deferred_award_immediate_claim(self):
"""Ensure that a deferred award can be immediately claimed rather than
viewing detail"""
deferred_email = "[email protected]"
user1 = self._get_user(username="creator", email="[email protected]")
b1 = Badge.objects.create(creator=user1, title="Badge to defer")
da = DeferredAward(badge=b1, creator=user1)
da.save()
url = da.get_claim_url()
# Just viewing the claim URL shouldn't require login.
r = self.client.get(url, follow=False)
eq_(200, r.status_code)
# But, attempting to claim the award should require login
r = self.client.post(reverse('badger.views.claim_deferred_award'), dict(
code=da.claim_code,
), follow=False)
eq_(302, r.status_code)
ok_('login' in r['Location'])
# So, try logging in and fetch the immediate-claim URL
user2 = self._get_user(username="awardee", email=deferred_email)
self.client.login(username="awardee", password="trustno1")
r = self.client.post(reverse('badger.views.claim_deferred_award'), dict(
code=da.claim_code,
), follow=False)
eq_(302, r.status_code)
ok_('awards' in r['Location'])
ok_(b1.is_awarded_to(user2))