From bef7af084b529494b4a5607c4bbb46df5b97fddf Mon Sep 17 00:00:00 2001
From: Marc
Date: Mon, 28 Jul 2014 17:28:00 +0000
Subject: [PATCH] Preliminar implementation of payment methods
---
orchestra/admin/menu.py | 2 +
orchestra/apps/accounts/admin.py | 10 +++-
.../admin/accounts/account/change_form.html | 19 ++++++-
orchestra/apps/bills/models.py | 8 +++
orchestra/apps/bills/serializers.py | 9 ++-
orchestra/apps/lists/backends.py | 8 +--
orchestra/apps/lists/serializers.py | 4 +-
orchestra/apps/orchestration/admin.py | 27 ++++-----
orchestra/apps/orders/api.py | 14 +++++
orchestra/apps/orders/models.py | 8 ++-
orchestra/apps/orders/serializers.py | 14 +++++
orchestra/apps/payments/admin.py | 15 ++++-
orchestra/apps/payments/forms.py | 46 +++++++++++++++
orchestra/apps/payments/methods.py | 37 ++++++++++++
orchestra/apps/payments/models.py | 31 +++++++++-
orchestra/apps/payments/serializers.py | 40 +++++++++++--
orchestra/apps/prices/models.py | 4 +-
orchestra/apps/resources/serializers.py | 3 +-
orchestra/apps/users/backends.py | 6 +-
orchestra/apps/websites/backends/apache.py | 28 ++++-----
orchestra/conf/base_settings.py | 2 +
orchestra/core/__init__.py | 9 ++-
orchestra/models/queryset.py | 47 +++++-----------
.../static/orchestra/icons/card_in_use.png | Bin 0 -> 1108 bytes
.../static/orchestra/icons/card_in_use.svg | 53 ++++++++++++++++++
25 files changed, 349 insertions(+), 95 deletions(-)
create mode 100644 orchestra/apps/orders/api.py
create mode 100644 orchestra/apps/orders/serializers.py
create mode 100644 orchestra/apps/payments/forms.py
create mode 100644 orchestra/static/orchestra/icons/card_in_use.png
create mode 100644 orchestra/static/orchestra/icons/card_in_use.svg
diff --git a/orchestra/admin/menu.py b/orchestra/admin/menu.py
index cb9c1927..0b4362f0 100644
--- a/orchestra/admin/menu.py
+++ b/orchestra/admin/menu.py
@@ -62,6 +62,8 @@ def get_account_items():
if isinstalled('orchestra.apps.payments'):
url = reverse('admin:payments_transaction_changelist')
childrens.append(items.MenuItem(_("Transactions"), url))
+ url = reverse('admin:payments_paymentsource_changelist')
+ childrens.append(items.MenuItem(_("Payment Sources"), url))
if isinstalled('orchestra.apps.issues'):
url = reverse('admin:issues_ticket_changelist')
childrens.append(items.MenuItem(_("Tickets"), url))
diff --git a/orchestra/apps/accounts/admin.py b/orchestra/apps/accounts/admin.py
index fd046721..64820300 100644
--- a/orchestra/apps/accounts/admin.py
+++ b/orchestra/apps/accounts/admin.py
@@ -9,7 +9,7 @@ from django.utils.translation import ugettext_lazy as _
from orchestra.admin import ExtendedModelAdmin
from orchestra.admin.utils import wrap_admin_view, admin_link
-from orchestra.core import services
+from orchestra.core import services, accounts
from .filters import HasMainUserListFilter
from .forms import AccountCreationForm, AccountChangeForm
@@ -60,10 +60,13 @@ class AccountAdmin(ExtendedModelAdmin):
if not account.is_active:
messages.warning(request, 'This account is disabled.')
context = {
- # TODO not services but everythin (payments, bills, etc)
'services': sorted(
[ model._meta for model in services.get() if model is not Account ],
key=lambda i: i.verbose_name_plural.lower()
+ ),
+ 'accounts': sorted(
+ [ model._meta for model in accounts.get() if model is not Account ],
+ key=lambda i: i.verbose_name_plural.lower()
)
}
context.update(extra_context or {})
@@ -83,8 +86,9 @@ class AccountAdmin(ExtendedModelAdmin):
def get_queryset(self, request):
""" Select related for performance """
# TODO move invoicecontact to contacts
+ qs = super(AccountAdmin, self).get_queryset(request)
related = ('user', 'invoicecontact')
- return super(AccountAdmin, self).get_queryset(request).select_related(*related)
+ return qs.select_related(*related)
admin.site.register(Account, AccountAdmin)
diff --git a/orchestra/apps/accounts/templates/admin/accounts/account/change_form.html b/orchestra/apps/accounts/templates/admin/accounts/account/change_form.html
index 52598a41..d93f4d97 100644
--- a/orchestra/apps/accounts/templates/admin/accounts/account/change_form.html
+++ b/orchestra/apps/accounts/templates/admin/accounts/account/change_form.html
@@ -3,11 +3,28 @@
{% block object-tools-items %}
+
+
{% for service in services %}
{{ service.verbose_name_plural|capfirst }}
{% endfor %}
+
+
+
+Account
+
+
+a
+
+