Random stuff

This commit is contained in:
Marc 2014-09-16 15:01:02 +00:00
parent 22f47d4fcd
commit 2b91495657
7 changed files with 43 additions and 17 deletions

View File

@ -68,6 +68,8 @@ def get_administration_items():
if isinstalled('orchestra.apps.orders'): if isinstalled('orchestra.apps.orders'):
url = reverse('admin:orders_service_changelist') url = reverse('admin:orders_service_changelist')
childrens.append(items.MenuItem(_("Services"), url)) childrens.append(items.MenuItem(_("Services"), url))
url = reverse('admin:orders_plan_changelist')
childrens.append(items.MenuItem(_("Plans"), url))
if isinstalled('orchestra.apps.orchestration'): if isinstalled('orchestra.apps.orchestration'):
route = reverse('admin:orchestration_route_changelist') route = reverse('admin:orchestration_route_changelist')
backendlog = reverse('admin:orchestration_backendlog_changelist') backendlog = reverse('admin:orchestration_backendlog_changelist')

View File

@ -15,12 +15,7 @@ from orchestra.utils.humanize import naturaldate
from .actions import BillSelectedOrders from .actions import BillSelectedOrders
from .filters import ActiveOrderListFilter, BilledOrderListFilter from .filters import ActiveOrderListFilter, BilledOrderListFilter
from .models import Plan, Rate, Service, Order, MetricStorage from .models import Plan, ContractedPlan, Rate, Service, Order, MetricStorage
class PlanAdmin(AccountAdminMixin, admin.ModelAdmin):
list_display = ('name', 'account_link')
list_filter = ('name',)
class RateInline(admin.TabularInline): class RateInline(admin.TabularInline):
@ -28,6 +23,17 @@ class RateInline(admin.TabularInline):
ordering = ('plan', 'quantity') 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): class ServiceAdmin(admin.ModelAdmin):
list_display = ( list_display = (
'description', 'content_type', 'handler_type', 'num_orders', 'is_active' 'description', 'content_type', 'handler_type', 'num_orders', 'is_active'
@ -41,14 +47,12 @@ class ServiceAdmin(admin.ModelAdmin):
}), }),
(_("Billing options"), { (_("Billing options"), {
'classes': ('wide',), 'classes': ('wide',),
'fields': ('billing_period', 'billing_point', 'delayed_billing', 'fields': ('billing_period', 'billing_point', 'is_fee')
'is_fee')
}), }),
(_("Pricing options"), { (_("Pricing options"), {
'classes': ('wide',), 'classes': ('wide',),
'fields': ('metric', 'pricing_period', 'rate_algorithm', 'fields': ('metric', 'pricing_period', 'rate_algorithm',
'on_cancel', 'payment_style', 'on_cancel', 'payment_style', 'tax', 'nominal_price')
'tax', 'nominal_price')
}), }),
) )
inlines = [RateInline] inlines = [RateInline]
@ -129,6 +133,7 @@ class MetricStorageAdmin(admin.ModelAdmin):
admin.site.register(Plan, PlanAdmin) admin.site.register(Plan, PlanAdmin)
admin.site.register(ContractedPlan, ContractedPlanAdmin)
admin.site.register(Service, ServiceAdmin) admin.site.register(Service, ServiceAdmin)
admin.site.register(Order, OrderAdmin) admin.site.register(Order, OrderAdmin)
admin.site.register(MetricStorage, MetricStorageAdmin) admin.site.register(MetricStorage, MetricStorageAdmin)

View File

@ -468,5 +468,5 @@ def update_orders(sender, **kwargs):
accounts.register(Order) accounts.register(Order)
accounts.register(Plan) accounts.register(ContractedPlan)
services.register(Plan, menu=False) services.register(ContractedPlan, menu=False)

View File

@ -1,3 +1 @@
from .creditcard import CreditCard
from .sepadirectdebit import SEPADirectDebit
from .options import PaymentMethod, PaymentSourceDataForm from .options import PaymentMethod, PaymentSourceDataForm

View File

@ -2,6 +2,10 @@ from dateutil import relativedelta
from django import forms from django import forms
from orchestra.utils import plugins 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): class PaymentMethod(plugins.Plugin):
@ -12,7 +16,13 @@ class PaymentMethod(plugins.Plugin):
serializer = None serializer = None
due_delta = relativedelta.relativedelta(months=1) 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): def get_form(self):
self.form.plugin = self self.form.plugin = self

View File

@ -6,9 +6,18 @@ PAYMENT_CURRENCY = getattr(settings, 'PAYMENT_CURRENCY', 'Eur')
PAYMENTS_DD_CREDITOR_NAME = getattr(settings, 'PAYMENTS_DD_CREDITOR_NAME', PAYMENTS_DD_CREDITOR_NAME = getattr(settings, 'PAYMENTS_DD_CREDITOR_NAME',
'Orchestra') 'Orchestra')
PAYMENTS_DD_CREDITOR_IBAN = getattr(settings, 'PAYMENTS_DD_CREDITOR_IBAN', PAYMENTS_DD_CREDITOR_IBAN = getattr(settings, 'PAYMENTS_DD_CREDITOR_IBAN',
'IE98BOFI90393912121212') 'IE98BOFI90393912121212')
PAYMENTS_DD_CREDITOR_BIC = getattr(settings, 'PAYMENTS_DD_CREDITOR_BIC', PAYMENTS_DD_CREDITOR_BIC = getattr(settings, 'PAYMENTS_DD_CREDITOR_BIC',
'BOFIIE2D') 'BOFIIE2D')
PAYMENTS_DD_CREDITOR_AT02_ID = getattr(settings, 'PAYMENTS_DD_CREDITOR_AT02_ID', PAYMENTS_DD_CREDITOR_AT02_ID = getattr(settings, 'PAYMENTS_DD_CREDITOR_AT02_ID',
'InvalidAT02ID') 'InvalidAT02ID')
PAYMENTS_ENABLED_METHODS = getattr(settings, 'PAYMENTS_ENABLED_METHODS', [
'orchestra.apps.payments.methods.sepadirectdebit.SEPADirectDebit',
'orchestra.apps.payments.methods.creditcard.CreditCard',
])

View File

@ -144,7 +144,7 @@ FLUENT_DASHBOARD_APP_GROUPS = (
'orchestra.apps.contacts.models.Contact', 'orchestra.apps.contacts.models.Contact',
'orchestra.apps.users.models.User', 'orchestra.apps.users.models.User',
'orchestra.apps.orders.models.Order', 'orchestra.apps.orders.models.Order',
'orchestra.apps.orders.models.Plan', 'orchestra.apps.orders.models.ContractedPlan',
'orchestra.apps.bills.models.Bill', 'orchestra.apps.bills.models.Bill',
# 'orchestra.apps.payments.models.PaymentSource', # 'orchestra.apps.payments.models.PaymentSource',
'orchestra.apps.payments.models.Transaction', 'orchestra.apps.payments.models.Transaction',
@ -161,6 +161,7 @@ FLUENT_DASHBOARD_APP_GROUPS = (
'orchestra.apps.resources.models.Resource', 'orchestra.apps.resources.models.Resource',
'orchestra.apps.resources.models.Monitor', 'orchestra.apps.resources.models.Monitor',
'orchestra.apps.orders.models.Service', 'orchestra.apps.orders.models.Service',
'orchestra.apps.orders.models.Plan',
), ),
'collapsible': True, 'collapsible': True,
}), }),
@ -186,7 +187,7 @@ FLUENT_DASHBOARD_APP_ICONS = {
'contacts/contact': 'contact_book.png', 'contacts/contact': 'contact_book.png',
'orders/order': 'basket.png', 'orders/order': 'basket.png',
'orders/service': 'price.png', 'orders/service': 'price.png',
'orders/plan': 'Pack.png', 'orders/contractedplan': 'Pack.png',
'bills/bill': 'invoice.png', 'bills/bill': 'invoice.png',
'payments/paymentsource': 'card_in_use.png', 'payments/paymentsource': 'card_in_use.png',
'payments/transaction': 'transaction.png', 'payments/transaction': 'transaction.png',
@ -199,6 +200,7 @@ FLUENT_DASHBOARD_APP_ICONS = {
'orchestration/backendlog': 'scriptlog.png', 'orchestration/backendlog': 'scriptlog.png',
'resources/resource': "gauge.png", 'resources/resource': "gauge.png",
'resources/monitor': "Utilities-system-monitor.png", 'resources/monitor': "Utilities-system-monitor.png",
'orders/plan': 'Pack.png',
} }
# Django-celery # Django-celery