diff --git a/orchestra/admin/menu.py b/orchestra/admin/menu.py index 93639046..382f6fad 100644 --- a/orchestra/admin/menu.py +++ b/orchestra/admin/menu.py @@ -68,6 +68,8 @@ def get_administration_items(): if isinstalled('orchestra.apps.orders'): url = reverse('admin:orders_service_changelist') childrens.append(items.MenuItem(_("Services"), url)) + url = reverse('admin:orders_plan_changelist') + childrens.append(items.MenuItem(_("Plans"), url)) if isinstalled('orchestra.apps.orchestration'): route = reverse('admin:orchestration_route_changelist') backendlog = reverse('admin:orchestration_backendlog_changelist') diff --git a/orchestra/apps/orders/admin.py b/orchestra/apps/orders/admin.py index 15e8edc3..324bad68 100644 --- a/orchestra/apps/orders/admin.py +++ b/orchestra/apps/orders/admin.py @@ -15,12 +15,7 @@ from orchestra.utils.humanize import naturaldate from .actions import BillSelectedOrders from .filters import ActiveOrderListFilter, BilledOrderListFilter -from .models import Plan, Rate, Service, Order, MetricStorage - - -class PlanAdmin(AccountAdminMixin, admin.ModelAdmin): - list_display = ('name', 'account_link') - list_filter = ('name',) +from .models import Plan, ContractedPlan, Rate, Service, Order, MetricStorage class RateInline(admin.TabularInline): @@ -28,6 +23,17 @@ class RateInline(admin.TabularInline): ordering = ('plan', 'quantity') +class PlanAdmin(admin.ModelAdmin): + list_display = ('name', 'is_default', 'is_combinable', 'allow_multiple') + list_filter = ('is_default', 'is_combinable', 'allow_multiple') + inlines = [RateInline] + + +class ContractedPlanAdmin(AccountAdminMixin, admin.ModelAdmin): + list_display = ('plan', 'account_link') + list_filter = ('plan__name',) + + class ServiceAdmin(admin.ModelAdmin): list_display = ( 'description', 'content_type', 'handler_type', 'num_orders', 'is_active' @@ -41,14 +47,12 @@ class ServiceAdmin(admin.ModelAdmin): }), (_("Billing options"), { 'classes': ('wide',), - 'fields': ('billing_period', 'billing_point', 'delayed_billing', - 'is_fee') + 'fields': ('billing_period', 'billing_point', 'is_fee') }), (_("Pricing options"), { 'classes': ('wide',), 'fields': ('metric', 'pricing_period', 'rate_algorithm', - 'on_cancel', 'payment_style', - 'tax', 'nominal_price') + 'on_cancel', 'payment_style', 'tax', 'nominal_price') }), ) inlines = [RateInline] @@ -129,6 +133,7 @@ class MetricStorageAdmin(admin.ModelAdmin): admin.site.register(Plan, PlanAdmin) +admin.site.register(ContractedPlan, ContractedPlanAdmin) admin.site.register(Service, ServiceAdmin) admin.site.register(Order, OrderAdmin) admin.site.register(MetricStorage, MetricStorageAdmin) diff --git a/orchestra/apps/orders/models.py b/orchestra/apps/orders/models.py index 172deb32..ea85c403 100644 --- a/orchestra/apps/orders/models.py +++ b/orchestra/apps/orders/models.py @@ -468,5 +468,5 @@ def update_orders(sender, **kwargs): accounts.register(Order) -accounts.register(Plan) -services.register(Plan, menu=False) +accounts.register(ContractedPlan) +services.register(ContractedPlan, menu=False) diff --git a/orchestra/apps/payments/methods/__init__.py b/orchestra/apps/payments/methods/__init__.py index e4da67fe..17af0c2e 100644 --- a/orchestra/apps/payments/methods/__init__.py +++ b/orchestra/apps/payments/methods/__init__.py @@ -1,3 +1 @@ -from .creditcard import CreditCard -from .sepadirectdebit import SEPADirectDebit from .options import PaymentMethod, PaymentSourceDataForm diff --git a/orchestra/apps/payments/methods/options.py b/orchestra/apps/payments/methods/options.py index 0cc5368e..8f9e1589 100644 --- a/orchestra/apps/payments/methods/options.py +++ b/orchestra/apps/payments/methods/options.py @@ -2,6 +2,10 @@ from dateutil import relativedelta from django import forms from orchestra.utils import plugins +from orchestra.utils.functional import cached +from orchestra.utils.python import import_class + +from .. import settings class PaymentMethod(plugins.Plugin): @@ -12,7 +16,13 @@ class PaymentMethod(plugins.Plugin): serializer = None due_delta = relativedelta.relativedelta(months=1) - __metaclass__ = plugins.PluginMount + @classmethod + @cached + def get_plugins(cls): + plugins = [] + for cls in settings.PAYMENTS_ENABLED_METHODS: + plugins.append(import_class(cls)) + return plugins def get_form(self): self.form.plugin = self diff --git a/orchestra/apps/payments/settings.py b/orchestra/apps/payments/settings.py index 188dc646..86d9e3d8 100644 --- a/orchestra/apps/payments/settings.py +++ b/orchestra/apps/payments/settings.py @@ -6,9 +6,18 @@ PAYMENT_CURRENCY = getattr(settings, 'PAYMENT_CURRENCY', 'Eur') PAYMENTS_DD_CREDITOR_NAME = getattr(settings, 'PAYMENTS_DD_CREDITOR_NAME', 'Orchestra') + PAYMENTS_DD_CREDITOR_IBAN = getattr(settings, 'PAYMENTS_DD_CREDITOR_IBAN', 'IE98BOFI90393912121212') + PAYMENTS_DD_CREDITOR_BIC = getattr(settings, 'PAYMENTS_DD_CREDITOR_BIC', 'BOFIIE2D') + PAYMENTS_DD_CREDITOR_AT02_ID = getattr(settings, 'PAYMENTS_DD_CREDITOR_AT02_ID', 'InvalidAT02ID') + + +PAYMENTS_ENABLED_METHODS = getattr(settings, 'PAYMENTS_ENABLED_METHODS', [ + 'orchestra.apps.payments.methods.sepadirectdebit.SEPADirectDebit', + 'orchestra.apps.payments.methods.creditcard.CreditCard', +]) diff --git a/orchestra/conf/base_settings.py b/orchestra/conf/base_settings.py index f3e52dc4..4c0354ca 100644 --- a/orchestra/conf/base_settings.py +++ b/orchestra/conf/base_settings.py @@ -144,7 +144,7 @@ FLUENT_DASHBOARD_APP_GROUPS = ( 'orchestra.apps.contacts.models.Contact', 'orchestra.apps.users.models.User', 'orchestra.apps.orders.models.Order', - 'orchestra.apps.orders.models.Plan', + 'orchestra.apps.orders.models.ContractedPlan', 'orchestra.apps.bills.models.Bill', # 'orchestra.apps.payments.models.PaymentSource', 'orchestra.apps.payments.models.Transaction', @@ -161,6 +161,7 @@ FLUENT_DASHBOARD_APP_GROUPS = ( 'orchestra.apps.resources.models.Resource', 'orchestra.apps.resources.models.Monitor', 'orchestra.apps.orders.models.Service', + 'orchestra.apps.orders.models.Plan', ), 'collapsible': True, }), @@ -186,7 +187,7 @@ FLUENT_DASHBOARD_APP_ICONS = { 'contacts/contact': 'contact_book.png', 'orders/order': 'basket.png', 'orders/service': 'price.png', - 'orders/plan': 'Pack.png', + 'orders/contractedplan': 'Pack.png', 'bills/bill': 'invoice.png', 'payments/paymentsource': 'card_in_use.png', 'payments/transaction': 'transaction.png', @@ -199,6 +200,7 @@ FLUENT_DASHBOARD_APP_ICONS = { 'orchestration/backendlog': 'scriptlog.png', 'resources/resource': "gauge.png", 'resources/monitor': "Utilities-system-monitor.png", + 'orders/plan': 'Pack.png', } # Django-celery