當前位置: 首頁>>代碼示例>>Python>>正文


Python DeferredAward.get_claim_url方法代碼示例

本文整理匯總了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'])
開發者ID:askvictor,項目名稱:django-badger,代碼行數:28,代碼來源:test_views.py

示例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))
開發者ID:askvictor,項目名稱:django-badger,代碼行數:31,代碼來源:test_views.py

示例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))
開發者ID:askvictor,項目名稱:django-badger,代碼行數:34,代碼來源:test_views.py


注:本文中的badger.models.DeferredAward.get_claim_url方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。