Beispiel #1
0
 def setUp(self):
     self.factory = RequestFactory()
     request = self.factory.get('')
     middleware = SessionMiddleware(lambda x: x)
     middleware.process_request(request)
     self.create_view = CreateOrderView()
     self.create_view.request = request
Beispiel #2
0
class CreateOrderViewTestCase(TestCase):
    def setUp(self):
        self.factory = RequestFactory()
        request = self.factory.get('')
        middleware = SessionMiddleware(lambda x: x)
        middleware.process_request(request)
        self.create_view = CreateOrderView()
        self.create_view.request = request

    def test_recalculate_order_no_connection(self):
        # VAT is right, but with no internet connection
        with no_connection():
            with patch('plans.taxation.eu.logger') as mock_logger:
                o = self.create_view.recalculate(
                    10, BillingInfo(tax_number='48136450', country='CZ'))
                self.assertEqual(o.tax, 21)
                mock_logger.exception.assert_called_with("TAX_ID=CZ48136450")

    def test_recalculate_order(self):
        # BE 0203.201.340 is VAT ID of Belgium national bank.
        # It is used, because national provider for VIES seems to be stable enough
        c = self.create_view
        o = c.recalculate(
            10, BillingInfo(tax_number='BE 0203 201 340', country='BE'))
        self.assertEqual(o.tax, None)

        o = c.recalculate(10,
                          BillingInfo(tax_number='0203 201 340', country='BE'))
        self.assertEqual(o.tax, None)

        o = c.recalculate(10, BillingInfo(tax_number='1234565', country='BE'))
        self.assertEqual(o.tax, 21)

        o = c.recalculate(10, BillingInfo(tax_number='1234567', country='GR'))
        self.assertEqual(o.tax, 24)

        o = c.recalculate(10, BillingInfo(tax_number='090145420',
                                          country='GR'))
        self.assertEqual(o.tax, None)
Beispiel #3
0
from django.conf.urls.defaults import patterns, url
from plans.views import CreateOrderView, OrderListView, InvoiceDetailView, AccountActivationView, OrderPaymentReturnView, CurrentPlanView, UpgradePlanView, OrderView, BillingInfoRedirectView, BillingInfoCreateView, BillingInfoUpdateView, BillingInfoDeleteView, CreateOrderPlanChangeView, ChangePlanView

urlpatterns = patterns(
    '',
    url(r'^account/$',
        login_required(CurrentPlanView.as_view()),
        name='current_plan'),
    url(r'^account/activation/$',
        login_required(AccountActivationView.as_view()),
        name='account_activation'),
    url(r'^upgrade/$',
        login_required(UpgradePlanView.as_view()),
        name='upgrade_plan'),
    url(r'^order/extend/new/(?P<pk>\d+)/$',
        login_required(CreateOrderView.as_view()),
        name='create_order_plan'),
    url(r'^order/upgrade/new/(?P<pk>\d+)/$',
        login_required(CreateOrderPlanChangeView.as_view()),
        name='create_order_plan_change'),
    url(r'^change/(?P<pk>\d+)/$',
        login_required(ChangePlanView.as_view()),
        name='change_plan'),
    url(r'^order/$',
        login_required(OrderListView.as_view()),
        name='order_list'),
    url(r'^order/(?P<pk>\d+)/$',
        login_required(OrderView.as_view()),
        name='order'),
    url(r'^order/(?P<pk>\d+)/payment/success/$',
        login_required(OrderPaymentReturnView.as_view(status='success')),
Beispiel #4
0
from django.conf import settings
from django.conf.urls import patterns, url

from plans.views import CreateOrderView, OrderListView, InvoiceDetailView, AccountActivationView, \
    OrderPaymentReturnView, CurrentPlanView, UpgradePlanView, OrderView, BillingInfoRedirectView, \
    BillingInfoCreateView, BillingInfoUpdateView, BillingInfoDeleteView, CreateOrderPlanChangeView, ChangePlanView, \
    PricingView, FakePaymentsView

urlpatterns = patterns(
    '',
    url(r'^pricing/$', PricingView.as_view(), name='pricing'),
    url(r'^account/$', CurrentPlanView.as_view(), name='current_plan'),
    url(r'^account/activation/$', AccountActivationView.as_view(), name='account_activation'),
    url(r'^upgrade/$', UpgradePlanView.as_view(), name='upgrade_plan'),
    url(r'^order/extend/new/(?P<pk>\d+)/$', CreateOrderView.as_view(), name='create_order_plan'),
    url(r'^order/upgrade/new/(?P<pk>\d+)/$', CreateOrderPlanChangeView.as_view(), name='create_order_plan_change'),
    url(r'^change/(?P<pk>\d+)/$', ChangePlanView.as_view(redirect_page = getattr(settings, "PLANS_REDIRECT_AFTER_CHANGE", 'plans:upgrade_plan')), name='change_plan'),
    url(r'^order/$', OrderListView.as_view(), name='order_list'),
    url(r'^order/(?P<pk>\d+)/$', OrderView.as_view(), name='order'),
    url(r'^order/(?P<pk>\d+)/payment/success/$', OrderPaymentReturnView.as_view(status='success'),
        name='order_payment_success'),
    url(r'^order/(?P<pk>\d+)/payment/failure/$', OrderPaymentReturnView.as_view(status='failure'),
        name='order_payment_failure'),
    url(r'^billing/$', BillingInfoRedirectView.as_view(), name='billing_info'),
    url(r'^billing/create/$', BillingInfoCreateView.as_view(), name='billing_info_create'),
    url(r'^billing/update/$', BillingInfoUpdateView.as_view(), name='billing_info_update'),
    url(r'^billing/delete/$', BillingInfoDeleteView.as_view(), name='billing_info_delete'),
    url(r'^invoice/(?P<pk>\d+)/preview/html/$', InvoiceDetailView.as_view(), name='invoice_preview_html'),
)

if getattr(settings, 'DEBUG', False):
Beispiel #5
0
from django.contrib.auth.decorators import login_required, permission_required
from django.conf.urls.defaults import patterns, include, url
from plans.models import Invoice
from plans.views import CreateOrderView, OrderListView, InvoiceDetailView, AccountActivationView, OrderPaymentReturnView, CurrentPlanView, UpgradePlanView, OrderView, BillingInfoRedirectView, BillingInfoCreateView, BillingInfoUpdateView, BillingInfoDeleteView, CreateOrderPlanChangeView,  ChangePlanView

urlpatterns = patterns('',

    
    url(r'^account/$', login_required(CurrentPlanView.as_view()), name='current_plan'),
    url(r'^account/activation/$', login_required(AccountActivationView.as_view()), name='account_activation'),

    url(r'^upgrade/$', login_required(UpgradePlanView.as_view()), name='upgrade_plan'),
    url(r'^order/extend/new/(?P<pk>\d+)/$', login_required(CreateOrderView.as_view()), name='create_order_plan'),
    url(r'^order/upgrade/new/(?P<pk>\d+)/$', login_required(CreateOrderPlanChangeView.as_view()), name='create_order_plan_change'),
    url(r'^change/(?P<pk>\d+)/$', login_required(ChangePlanView.as_view()), name='change_plan'),


    url(r'^order/$', login_required(OrderListView.as_view()), name='order_list'),

    url(r'^order/(?P<pk>\d+)/$', login_required(OrderView.as_view()), name='order'),
    url(r'^order/(?P<pk>\d+)/payment/success/$', login_required(OrderPaymentReturnView.as_view(status='success')), name='order_payment_success'),
    url(r'^order/(?P<pk>\d+)/payment/failure/$', login_required(OrderPaymentReturnView.as_view(status='failure')), name='order_payment_failure'),

    url(r'^billing/$', login_required(BillingInfoRedirectView.as_view()), name='billing_info'),
    url(r'^billing/create/$', login_required(BillingInfoCreateView.as_view()), name='billing_info_create'),
    url(r'^billing/update/$', login_required(BillingInfoUpdateView.as_view()), name='billing_info_update'),
    url(r'^billing/delete/$', login_required(BillingInfoDeleteView.as_view()), name='billing_info_delete'),
    url(r'^invoice/(?P<pk>\d+)/preview/html/$', login_required(InvoiceDetailView.as_view()), name='invoice_preview_html'),

#    url(r'^invoice/(?P<pk>\d+)/preview/pdf/$', login_required(PDFDetailView.as_view(queryset=Invoice.objects.all(), template_name='plans/PL_EN.html')), name='invoice_preview_pdf'),
Beispiel #6
0
from plans.views import (CreateOrderView, OrderListView, InvoiceDetailView,
                         AccountActivationView, OrderPaymentReturnView,
                         CurrentPlanView, UpgradePlanView, OrderView,
                         BillingInfoRedirectView, BillingInfoCreateView,
                         BillingInfoUpdateView, BillingInfoDeleteView,
                         CreateOrderPlanChangeView, ChangePlanView,
                         PricingView, FakePaymentsView)

urlpatterns = [
    url(r'^pricing/$', PricingView.as_view(), name='pricing'),
    url(r'^account/$', CurrentPlanView.as_view(), name='current_plan'),
    url(r'^account/activation/$',
        AccountActivationView.as_view(), name='account_activation'),
    url(r'^upgrade/$', UpgradePlanView.as_view(), name='upgrade_plan'),
    url(r'^order/extend/new/(?P<pk>\d+)/$',
        CreateOrderView.as_view(), name='create_order_plan'),
    url(r'^order/upgrade/new/(?P<pk>\d+)/$',
        CreateOrderPlanChangeView.as_view(), name='create_order_plan_change'),
    url(r'^change/(?P<pk>\d+)/$',
        ChangePlanView.as_view(), name='change_plan'),
    url(r'^order/$', OrderListView.as_view(), name='order_list'),
    url(r'^order/(?P<pk>\d+)/$', OrderView.as_view(), name='order'),
    url(r'^order/(?P<pk>\d+)/payment/success/$',
        OrderPaymentReturnView.as_view(status='success'),
        name='order_payment_success'),
    url(r'^order/(?P<pk>\d+)/payment/failure/$',
        OrderPaymentReturnView.as_view(status='failure'),
        name='order_payment_failure'),
    url(r'^billing/$', BillingInfoRedirectView.as_view(), name='billing_info'),
    url(r'^billing/create/$',
        BillingInfoCreateView.as_view(), name='billing_info_create'),
Beispiel #7
0
from django.conf.urls import url

from plans.views import CreateOrderView, OrderListView, InvoiceDetailView, AccountActivationView, \
    OrderPaymentReturnView, CurrentPlanView, UpgradePlanView, OrderView, BillingInfoRedirectView, \
    BillingInfoCreateView, BillingInfoUpdateView, BillingInfoDeleteView, CreateOrderPlanChangeView, ChangePlanView, \
    PricingView, FakePaymentsView

urlpatterns = [
    url(r'^pricing/$', PricingView.as_view(), name='pricing'),
    url(r'^account/$', CurrentPlanView.as_view(), name='current_plan'),
    url(r'^account/activation/$',
        AccountActivationView.as_view(),
        name='account_activation'),
    url(r'^upgrade/$', UpgradePlanView.as_view(), name='upgrade_plan'),
    url(r'^order/extend/new/(?P<pk>[0-9a-f-]+)/$',
        CreateOrderView.as_view(),
        name='create_order_plan'),
    url(r'^order/upgrade/new/(?P<pk>[0-9a-f-]+)/$',
        CreateOrderPlanChangeView.as_view(),
        name='create_order_plan_change'),
    url(r'^change/(?P<pk>[0-9a-f-]+)/$',
        ChangePlanView.as_view(),
        name='change_plan'),
    url(r'^order/$', OrderListView.as_view(), name='order_list'),
    url(r'^order/(?P<pk>[0-9a-f-]+)/$', OrderView.as_view(), name='order'),
    url(r'^order/(?P<pk>[0-9a-f-]+)/payment/success/$',
        OrderPaymentReturnView.as_view(status='success'),
        name='order_payment_success'),
    url(r'^order/(?P<pk>[0-9a-f-]+)/payment/failure/$',
        OrderPaymentReturnView.as_view(status='failure'),
        name='order_payment_failure'),
Beispiel #8
0
from django.conf import settings
from django.conf.urls import patterns, url

from plans.views import CreateOrderView, OrderListView, InvoiceDetailView, AccountActivationView, \
    OrderPaymentReturnView, CurrentPlanView, UpgradePlanView, OrderView, BillingInfoRedirectView, \
    BillingInfoCreateView, BillingInfoUpdateView, BillingInfoDeleteView, CreateOrderPlanChangeView, ChangePlanView, \
    PricingView, FakePaymentsView

urlpatterns = patterns(
    '',
    url(r'^pricing/$', PricingView.as_view(), name='pricing'),
    url(r'^account/$', CurrentPlanView.as_view(), name='current_plan'),
    url(r'^account/activation/$', AccountActivationView.as_view(), name='account_activation'),
    url(r'^upgrade/$', UpgradePlanView.as_view(), name='upgrade_plan'),
    url(r'^order/extend/new/(?P<pk>\d+)/$', CreateOrderView.as_view(), name='create_order_plan'),
    url(r'^order/upgrade/new/(?P<pk>\d+)/$', CreateOrderPlanChangeView.as_view(), name='create_order_plan_change'),
    url(r'^change/(?P<pk>\d+)/$', ChangePlanView.as_view(), name='change_plan'),
    url(r'^order/$', OrderListView.as_view(), name='order_list'),
    url(r'^order/(?P<pk>\d+)/$', OrderView.as_view(), name='order'),
    url(r'^order/(?P<pk>\d+)/payment/success/$', OrderPaymentReturnView.as_view(status='success'),
        name='order_payment_success'),
    url(r'^order/(?P<pk>\d+)/payment/failure/$', OrderPaymentReturnView.as_view(status='failure'),
        name='order_payment_failure'),
    url(r'^billing/$', BillingInfoRedirectView.as_view(), name='billing_info'),
    url(r'^billing/create/$', BillingInfoCreateView.as_view(), name='billing_info_create'),
    url(r'^billing/update/$', BillingInfoUpdateView.as_view(), name='billing_info_update'),
    url(r'^billing/delete/$', BillingInfoDeleteView.as_view(), name='billing_info_delete'),
    url(r'^invoice/(?P<pk>\d+)/preview/html/$', InvoiceDetailView.as_view(), name='invoice_preview_html'),
)

if getattr(settings, 'DEBUG', False):