From fc44c8bfc09fc850c786e3900cec29db026b035e Mon Sep 17 00:00:00 2001 From: Marc Date: Mon, 8 Sep 2014 10:03:42 +0000 Subject: [PATCH] Moved account service management object-tools to cl filters --- TODO.md | 2 -- orchestra/admin/forms.py | 6 ++-- orchestra/apps/accounts/admin.py | 18 ++++++---- orchestra/apps/accounts/filters.py | 1 + .../admin/accounts/account/change_list.html | 34 +++++++++++++------ orchestra/apps/bills/actions.py | 4 ++- .../bills/templates/bills/microspective.html | 8 ++--- .../apps/orders/{backends.py => billing.py} | 0 orchestra/apps/orders/models.py | 5 ++- orchestra/apps/orders/settings.py | 4 +++ orchestra/apps/payments/actions.py | 7 ++-- orchestra/models/queryset.py | 9 ++++- 12 files changed, 65 insertions(+), 33 deletions(-) rename orchestra/apps/orders/{backends.py => billing.py} (100%) diff --git a/TODO.md b/TODO.md index 7034a32c..bd8b5f31 100644 --- a/TODO.md +++ b/TODO.md @@ -89,6 +89,4 @@ at + clock time, midnight, noon- At 3:30 p.m., At 4:01, At noon * help_text on readonly_fields specialy Bill.state. (eg. A bill is in OPEN state when bla bla ) -* Account link and "show all" button on the filters secction instead of object-tools - * Create ProForma from orders orders.bill(proforma=True) diff --git a/orchestra/admin/forms.py b/orchestra/admin/forms.py index b73e499e..ed675457 100644 --- a/orchestra/admin/forms.py +++ b/orchestra/admin/forms.py @@ -37,8 +37,8 @@ class AdminFormSet(BaseModelFormSet): return template.render(Context({'inline_admin_formset': inline_admin_formset})) -def adminmodelformset_factory(modeladmin, form): - formset = modelformset_factory(modeladmin.model, extra=0, - form=form, formset=AdminFormSet) +def adminmodelformset_factory(modeladmin, form, formset=AdminFormSet, **kwargs): + formset = modelformset_factory(modeladmin.model, form=form, formset=formset, + **kwargs) formset.modeladmin = modeladmin return formset diff --git a/orchestra/apps/accounts/admin.py b/orchestra/apps/accounts/admin.py index 771f0795..dfd50ee5 100644 --- a/orchestra/apps/accounts/admin.py +++ b/orchestra/apps/accounts/admin.py @@ -198,19 +198,25 @@ class AccountAdminMixin(object): def changelist_view(self, request, extra_context=None): account_id = request.GET.get('account') - context = { - 'from_account': False - } + context = {} if account_id: opts = self.model._meta account = Account.objects.get(pk=account_id) context = { - 'from_account': True, - 'title': _("Select %s to change for %s") % ( - opts.verbose_name, account.name), 'account': not account_id or Account.objects.get(pk=account_id), 'account_opts': Account._meta, + 'all_selected': True, } + if not request.GET.get('all'): + context.update({ + 'all_selected': False, + 'title': _("Select %s to change for %s") % ( + opts.verbose_name, account.name), + }) + else: + request_copy = request.GET.copy() + request_copy.pop('account') + request.GET = request_copy context.update(extra_context or {}) return super(AccountAdminMixin, self).changelist_view(request, extra_context=context) diff --git a/orchestra/apps/accounts/filters.py b/orchestra/apps/accounts/filters.py index 84a27831..078d44aa 100644 --- a/orchestra/apps/accounts/filters.py +++ b/orchestra/apps/accounts/filters.py @@ -1,4 +1,5 @@ from django.contrib.admin import SimpleListFilter +from django.utils.encoding import force_text from django.utils.translation import ugettext_lazy as _ diff --git a/orchestra/apps/accounts/templates/admin/accounts/account/change_list.html b/orchestra/apps/accounts/templates/admin/accounts/account/change_list.html index ea9d101b..08a7b563 100644 --- a/orchestra/apps/accounts/templates/admin/accounts/account/change_list.html +++ b/orchestra/apps/accounts/templates/admin/accounts/account/change_list.html @@ -1,11 +1,11 @@ {% extends "admin/change_list.html" %} -{% load i18n admin_urls %} +{% load i18n admin_urls admin_list %} {% block breadcrumbs %}