From ba2f2d5898eb931b1d87f2b65810536370596148 Mon Sep 17 00:00:00 2001 From: Frederic Date: Fri, 13 Sep 2013 12:22:07 +0200 Subject: [PATCH] code cosmetics --- cash/admin.py | 18 ++++++++++++------ cash/models.py | 5 ++++- cash/views.py | 3 ++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/cash/admin.py b/cash/admin.py index 973ed8f..b8a533a 100644 --- a/cash/admin.py +++ b/cash/admin.py @@ -8,7 +8,9 @@ from django.utils.translation import ugettext_lazy from django.utils.translation import ugettext_noop class AccountForm(forms.ModelForm): - credit_change = forms.DecimalField(max_digits = 5, decimal_places = 2, required = False, label = ugettext_lazy('change change')) + credit_change = forms.DecimalField(max_digits = 5, decimal_places = 2, + required = False, + label = ugettext_lazy('change change')) class Meta: model = Account @@ -19,7 +21,9 @@ class AccountAdmin(admin.ModelAdmin): readonly_fields = ('credit',) def transaction_link(self, account): - return '%s' % (reverse("admin:cash_transaction_changelist"), account.id, _('Transactions')) + return '%s' % \ + (reverse("admin:cash_transaction_changelist"), account.id, + _('Transactions')) transaction_link.short_description = ugettext_lazy('Transaction link') @@ -40,7 +44,8 @@ class AccountAdmin(admin.ModelAdmin): else: subject = PAYOUT_SUBJECT - obj.change_credit(amount, subject, DESC % (request.user.first_name, request.user.last_name)) + obj.change_credit(amount, subject, DESC % (request.user.first_name, + request.user.last_name)) class ProductBarcodeInline(admin.TabularInline): @@ -66,7 +71,7 @@ class TransactionAdmin(admin.ModelAdmin): actions = None date_hierarchy = 'timestamp' - # Disable tampering with the transactions completely + # Disable tampering with the transactions completely. def has_add_permission(self, request): return False def has_change_permission(self, request, obj=None): @@ -76,11 +81,12 @@ class TransactionAdmin(admin.ModelAdmin): def has_delete_permission(self, request, obj=None): return False - # Needed to not trigger an ImproperlyConfigured exception + # Needed to not trigger an ImproperlyConfigured exception. # FIXME: a bit too hacky def changelist_view(self, request, extra_context=None): self.list_display_links = (None, ) - return super(TransactionAdmin, self).changelist_view(request, extra_context=None) + return super(TransactionAdmin, self).changelist_view(request, + extra_context=None) admin.site.register(Account, AccountAdmin) admin.site.register(Product, ProductAdmin) diff --git a/cash/models.py b/cash/models.py index a75be0c..a6128aa 100644 --- a/cash/models.py +++ b/cash/models.py @@ -151,5 +151,8 @@ def logentry_pre_delete_handler(sender, instance, **kwargs): SUBJECT = ugettext_noop('Cancellation') DESC = '%d x %s' - instance.account.change_credit(instance.unit_price * instance.count, SUBJECT, DESC % (instance.count, instance.product.name)) + instance.account.change_credit( + instance.unit_price * instance.count, + SUBJECT, DESC % (instance.count, instance.product.name) + ) diff --git a/cash/views.py b/cash/views.py index 933299c..ec2e49a 100644 --- a/cash/views.py +++ b/cash/views.py @@ -9,7 +9,8 @@ from django.utils.translation import ugettext as _ @login_required def overview(request): - return render_to_response('cash/index.html', context_instance=RequestContext(request)) + return render_to_response('cash/index.html', + context_instance=RequestContext(request)) class ProductView(generic.DetailView):