|
|
|
@ -8,7 +8,9 @@ from django.utils.translation import ugettext_lazy
@@ -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):
@@ -19,7 +21,9 @@ class AccountAdmin(admin.ModelAdmin):
|
|
|
|
|
readonly_fields = ('credit',) |
|
|
|
|
|
|
|
|
|
def transaction_link(self, account): |
|
|
|
|
return '<a href="%s?account__id__exact=%d">%s</a>' % (reverse("admin:cash_transaction_changelist"), account.id, _('Transactions')) |
|
|
|
|
return '<a href="%s?account__id__exact=%d">%s</a>' % \ |
|
|
|
|
(reverse("admin:cash_transaction_changelist"), account.id, |
|
|
|
|
_('Transactions')) |
|
|
|
|
|
|
|
|
|
transaction_link.short_description = ugettext_lazy('Transaction link') |
|
|
|
|
|
|
|
|
@ -40,7 +44,8 @@ class AccountAdmin(admin.ModelAdmin):
@@ -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):
@@ -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):
@@ -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) |
|
|
|
|