示例#1
0
    def test_get_context_data__bad_price(self):
        """
        If the tier isn't a downgrade, a 404 should be raised.

        """
        tier3 = self.create_tier(name='Tier3', slug='tier3', price=40)
        self.tier_info.available_tiers.add(tier3)
        view = DowngradeConfirmationView()
        view.request = self.factory.get('/', data={'tier': 'tier3'})
        self.assertRaises(Http404, view.get_context_data)
示例#2
0
 def test_get_context_data(self):
     view = DowngradeConfirmationView()
     view.request = self.factory.get('/', data={'tier': 'tier1'})
     data = view.get_context_data()
     self.assertIsInstance(data.get('form'), TierChangeForm)
     self.assertEqual(data.get('tier'), self.tier1)
     self.assertEqual(data.get('tier_info'), self.tier_info)
     self.assertIsInstance(data.get('admins_to_demote'), list)
     self.assertIsInstance(data.get('videos_to_deactivate'), list)
     self.assertIsInstance(data.get('have_theme'), bool)
 def test_get_context_data(self):
     view = DowngradeConfirmationView()
     view.request = self.factory.get('/', data={'tier': 'tier1'})
     data = view.get_context_data()
     self.assertIsInstance(data.get('form'), TierChangeForm)
     self.assertEqual(data.get('tier'), self.tier1)
     self.assertEqual(data.get('tier_info'), self.tier_info)
     self.assertIsInstance(data.get('admins_to_demote'), list)
     self.assertIsInstance(data.get('videos_to_deactivate'), list)
     self.assertIsInstance(data.get('have_theme'), bool)
示例#4
0
    def test_get_context_data__bad_slug(self):
        """
        If the slug doesn't represent an available tier, a 404 should be
        raised.

        """
        self.create_tier(name='Tier3', slug='tier3', price=10)
        view = DowngradeConfirmationView()
        view.request = self.factory.get('/', data={'tier': 'tier3'})
        self.assertRaises(Http404, view.get_context_data)
    def test_get_context_data__bad_price(self):
        """
        If the tier isn't a downgrade, a 404 should be raised.

        """
        tier3 = self.create_tier(name='Tier3', slug='tier3', price=40)
        self.tier_info.available_tiers.add(tier3)
        view = DowngradeConfirmationView()
        view.request = self.factory.get('/', data={'tier': 'tier3'})
        self.assertRaises(Http404, view.get_context_data)
    def test_get_context_data__bad_slug(self):
        """
        If the slug doesn't represent an available tier, a 404 should be
        raised.

        """
        self.create_tier(name='Tier3', slug='tier3', price=10)
        view = DowngradeConfirmationView()
        view.request = self.factory.get('/', data={'tier': 'tier3'})
        self.assertRaises(Http404, view.get_context_data)
示例#7
0
    def test_get_context_data__enforced__cancellation__no_subscription(self):
        """
        If payments are enforced, but there is no active subscription, a
        non-paypal-based form should be used.
        """
        self.tier_info.enforce_payments = True
        self.tier_info.save()

        view = DowngradeConfirmationView()
        view.request = self.factory.get('/', data={'tier': 'tier1'})
        data = view.get_context_data()
        self.assertIsInstance(data.get('form'), TierChangeForm)
        self.assertEqual(data.get('tier'), self.tier1)
        self.assertEqual(data.get('tier_info'), self.tier_info)
        self.assertIsInstance(data.get('admins_to_demote'), list)
        self.assertIsInstance(data.get('videos_to_deactivate'), list)
        self.assertIsInstance(data.get('have_theme'), bool)
    def test_get_context_data__enforced__cancellation__no_subscription(self):
        """
        If payments are enforced, but there is no active subscription, a
        non-paypal-based form should be used.
        """
        self.tier_info.enforce_payments = True
        self.tier_info.save()

        view = DowngradeConfirmationView()
        view.request = self.factory.get('/', data={'tier': 'tier1'})
        data = view.get_context_data()
        self.assertIsInstance(data.get('form'), TierChangeForm)
        self.assertEqual(data.get('tier'), self.tier1)
        self.assertEqual(data.get('tier_info'), self.tier_info)
        self.assertIsInstance(data.get('admins_to_demote'), list)
        self.assertIsInstance(data.get('videos_to_deactivate'), list)
        self.assertIsInstance(data.get('have_theme'), bool)
示例#9
0
    def test_get_context_data__enforced__cancellation(self):
        """
        If payments are enforced, a paypal-based form should be used.
        """
        self.tier_info.enforce_payments = True
        self.tier_info.save()

        view = DowngradeConfirmationView()
        view.request = self.factory.get('/', data={'tier': 'tier1'})
        with mock.patch.object(self.tier_info, 'subscription',
                               signup_or_modify=self.create_ipn()):
            data = view.get_context_data()
        self.assertIsInstance(data.get('form'), PayPalCancellationForm)
        self.assertEqual(data.get('tier'), self.tier1)
        self.assertEqual(data.get('tier_info'), self.tier_info)
        self.assertIsInstance(data.get('admins_to_demote'), list)
        self.assertIsInstance(data.get('videos_to_deactivate'), list)
        self.assertIsInstance(data.get('have_theme'), bool)
示例#10
0
    def test_get_context_data__enforced(self):
        """
        If payments are enforced, a paypal-based form should be used.
        """
        self.tier_info.enforce_payments = True
        self.tier_info.save()
        self.tier1.price = 10
        self.tier1.save()

        view = DowngradeConfirmationView()
        view.request = self.factory.get('/', data={'tier': 'tier1'})
        data = view.get_context_data()
        self.assertIsInstance(data.get('form'), PayPalSubscriptionForm)
        self.assertEqual(data.get('tier'), self.tier1)
        self.assertEqual(data.get('tier_info'), self.tier_info)
        self.assertIsInstance(data.get('admins_to_demote'), list)
        self.assertIsInstance(data.get('videos_to_deactivate'), list)
        self.assertIsInstance(data.get('have_theme'), bool)
    def test_get_context_data__enforced(self):
        """
        If payments are enforced, a paypal-based form should be used.
        """
        self.tier_info.enforce_payments = True
        self.tier_info.save()
        self.tier1.price = 10
        self.tier1.save()

        view = DowngradeConfirmationView()
        view.request = self.factory.get('/', data={'tier': 'tier1'})
        data = view.get_context_data()
        self.assertIsInstance(data.get('form'), PayPalSubscriptionForm)
        self.assertEqual(data.get('tier'), self.tier1)
        self.assertEqual(data.get('tier_info'), self.tier_info)
        self.assertIsInstance(data.get('admins_to_demote'), list)
        self.assertIsInstance(data.get('videos_to_deactivate'), list)
        self.assertIsInstance(data.get('have_theme'), bool)
    def test_get_context_data__enforced__cancellation(self):
        """
        If payments are enforced, a paypal-based form should be used.
        """
        self.tier_info.enforce_payments = True
        self.tier_info.save()

        view = DowngradeConfirmationView()
        view.request = self.factory.get('/', data={'tier': 'tier1'})
        with mock.patch.object(self.tier_info,
                               'subscription',
                               signup_or_modify=self.create_ipn()):
            data = view.get_context_data()
        self.assertIsInstance(data.get('form'), PayPalCancellationForm)
        self.assertEqual(data.get('tier'), self.tier1)
        self.assertEqual(data.get('tier_info'), self.tier_info)
        self.assertIsInstance(data.get('admins_to_demote'), list)
        self.assertIsInstance(data.get('videos_to_deactivate'), list)
        self.assertIsInstance(data.get('have_theme'), bool)
示例#13
0
from localtv.decorators import require_site_admin

from mirocommunity_saas.admin.forms import (EditSettingsForm, AuthorForm,
                                            AuthorFormSet, VideoFormSet)
from mirocommunity_saas.admin.views import (index, TierView, TierChangeView,
                                            DowngradeConfirmationView)

# Tier urls
urlpatterns = patterns(
    '',
    url(r'^$', index, name='localtv_admin_index'),
    url(r'^upgrade/$',
        require_site_admin(TierView.as_view()),
        name='localtv_admin_tier'),
    url(r'^upgrade/confirm_downgrade/$',
        require_site_admin(DowngradeConfirmationView.as_view()),
        name='localtv_admin_tier_confirm'),
    url(r'^upgrade/complete/$',
        require_site_admin(TierChangeView.as_view()),
        name='localtv_admin_tier_change'),
    url(r'^paypal/', include('paypal.standard.ipn.urls')),
)

# Moderation overrides
urlpatterns += patterns(
    'mirocommunity_saas.admin.approve_reject_views',
    url(r'^actions/approve_video/$',
        'approve_video',
        name='localtv_admin_approve_video'),
    url(r'^actions/feature_video/$',
        'feature_video',
示例#14
0
from localtv.decorators import require_site_admin

from mirocommunity_saas.admin.forms import (EditSettingsForm, AuthorForm,
                                            AuthorFormSet, VideoFormSet)
from mirocommunity_saas.admin.views import (index, TierView, TierChangeView,
                                            DowngradeConfirmationView)


# Tier urls
urlpatterns = patterns('',
    url(r'^$', index, name='localtv_admin_index'),
    url(r'^upgrade/$',
        require_site_admin(TierView.as_view()),
        name='localtv_admin_tier'),
    url(r'^upgrade/confirm_downgrade/$',
        require_site_admin(DowngradeConfirmationView.as_view()),
        name='localtv_admin_tier_confirm'),
    url(r'^upgrade/complete/$',
        require_site_admin(TierChangeView.as_view()),
        name='localtv_admin_tier_change'),
    url(r'^paypal/', include('paypal.standard.ipn.urls')),
)

# Moderation overrides
urlpatterns += patterns('mirocommunity_saas.admin.approve_reject_views',
    url(r'^actions/approve_video/$', 'approve_video',
        name='localtv_admin_approve_video'),
    url(r'^actions/feature_video/$', 'feature_video',
        name='localtv_admin_feature_video'),
    url(r'^actions/approve_all/$', 'approve_all',
        name='localtv_admin_approve_all'),