def test_videos_to_deactivate(self):
        tier1 = self.create_tier(slug='tier1', video_limit=None)
        tier2 = self.create_tier(slug='tier2', video_limit=100)
        tier3 = self.create_tier(slug='tier3', video_limit=2)
        tier4 = self.create_tier(slug='tier4', video_limit=1)
        video1 = self.create_video(name='video1')
        video2 = self.create_video(name='video2')

        self.assertEqual(videos_to_deactivate(tier1), [])
        self.assertEqual(videos_to_deactivate(tier2), [])
        self.assertEqual(videos_to_deactivate(tier3), [])
        self.assertEqual(videos_to_deactivate(tier4), [video1])
Пример #2
0
    def test_videos_to_deactivate(self):
        tier1 = self.create_tier(slug='tier1', video_limit=None)
        tier2 = self.create_tier(slug='tier2', video_limit=100)
        tier3 = self.create_tier(slug='tier3', video_limit=2)
        tier4 = self.create_tier(slug='tier4', video_limit=1)
        video1 = self.create_video(name='video1')
        video2 = self.create_video(name='video2')

        self.assertEqual(videos_to_deactivate(tier1), [])
        self.assertEqual(videos_to_deactivate(tier2), [])
        self.assertEqual(videos_to_deactivate(tier3), [])
        self.assertEqual(videos_to_deactivate(tier4), [video1])
Пример #3
0
 def get_context_data(self, **kwargs):
     context = super(DowngradeConfirmationView,
                     self).get_context_data(**kwargs)
     tier_info = SiteTierInfo.objects.get_current()
     slug = self.request.GET.get('tier', '')
     try:
         tier = tier_info.available_tiers.get(slug=slug)
     except Tier.DoesNotExist:
         raise Http404
     if tier.price >= tier_info.tier.price:
         raise Http404
     if tier_info.enforce_payments:
         if tier.price == 0:
             if tier_info.subscription:
                 form = PayPalCancellationForm()
             else:
                 # If they don't have an active subscription, we can't very
                 # well cancel it.
                 form = TierChangeForm(initial={'tier': tier})
         else:
             form = PayPalSubscriptionForm(tier)
     else:
         form = TierChangeForm(initial={'tier': tier})
     context.update({
         'form': form,
         'tier': tier,
         'tier_info': tier_info,
         'admins_to_demote': admins_to_demote(tier),
         'videos_to_deactivate': videos_to_deactivate(tier),
         'have_theme': Theme.objects.filter(default=True).exists()
     })
     return context
Пример #4
0
 def get_context_data(self, **kwargs):
     context = super(DowngradeConfirmationView,
                     self).get_context_data(**kwargs)
     tier_info = SiteTierInfo.objects.get_current()
     slug = self.request.GET.get('tier', '')
     try:
         tier = tier_info.available_tiers.get(slug=slug)
     except Tier.DoesNotExist:
         raise Http404
     if tier.price >= tier_info.tier.price:
         raise Http404
     if tier_info.enforce_payments:
         if tier.price == 0:
             if tier_info.subscription:
                 form = PayPalCancellationForm()
             else:
                 # If they don't have an active subscription, we can't very
                 # well cancel it.
                 form = TierChangeForm(initial={'tier': tier})
         else:
             form = PayPalSubscriptionForm(tier)
     else:
         form = TierChangeForm(initial={'tier': tier})
     context.update({
         'form':
         form,
         'tier':
         tier,
         'tier_info':
         tier_info,
         'admins_to_demote':
         admins_to_demote(tier),
         'videos_to_deactivate':
         videos_to_deactivate(tier),
         'have_theme':
         Theme.objects.filter(default=True).exists()
     })
     return context