mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-21 18:08:21 +02:00
Test and cover note app
This commit is contained in:
@ -119,10 +119,6 @@ class TransactionAdmin(PolymorphicParentModelAdmin):
|
||||
list_display = ('created_at', 'poly_source', 'poly_destination',
|
||||
'quantity', 'amount', 'valid')
|
||||
list_filter = ('valid',)
|
||||
readonly_fields = (
|
||||
'source',
|
||||
'destination',
|
||||
)
|
||||
|
||||
def poly_source(self, obj):
|
||||
"""
|
||||
@ -145,10 +141,7 @@ class TransactionAdmin(PolymorphicParentModelAdmin):
|
||||
Only valid can be edited after creation
|
||||
Else the amount of money would not be transferred
|
||||
"""
|
||||
if obj: # user is editing an existing object
|
||||
return 'created_at', 'source', 'destination', 'quantity', \
|
||||
'amount'
|
||||
return []
|
||||
return 'created_at', 'source', 'destination', 'quantity', 'amount' if obj else ()
|
||||
|
||||
|
||||
@admin.register(MembershipTransaction, site=admin_site)
|
||||
@ -157,6 +150,13 @@ class MembershipTransactionAdmin(PolymorphicChildModelAdmin):
|
||||
Admin customisation for MembershipTransaction
|
||||
"""
|
||||
|
||||
def get_readonly_fields(self, request, obj=None):
|
||||
"""
|
||||
Only valid can be edited after creation
|
||||
Else the amount of money would not be transferred
|
||||
"""
|
||||
return ('created_at', 'source', 'destination', 'quantity', 'amount') if obj else ()
|
||||
|
||||
|
||||
@admin.register(RecurrentTransaction, site=admin_site)
|
||||
class RecurrentTransactionAdmin(PolymorphicChildModelAdmin):
|
||||
@ -164,6 +164,13 @@ class RecurrentTransactionAdmin(PolymorphicChildModelAdmin):
|
||||
Admin customisation for RecurrentTransaction
|
||||
"""
|
||||
|
||||
def get_readonly_fields(self, request, obj=None):
|
||||
"""
|
||||
Only valid can be edited after creation
|
||||
Else the amount of money would not be transferred
|
||||
"""
|
||||
return ('created_at', 'source', 'destination', 'quantity', 'amount') if obj else ()
|
||||
|
||||
|
||||
@admin.register(SpecialTransaction, site=admin_site)
|
||||
class SpecialTransactionAdmin(PolymorphicChildModelAdmin):
|
||||
@ -171,6 +178,13 @@ class SpecialTransactionAdmin(PolymorphicChildModelAdmin):
|
||||
Admin customisation for SpecialTransaction
|
||||
"""
|
||||
|
||||
def get_readonly_fields(self, request, obj=None):
|
||||
"""
|
||||
Only valid can be edited after creation
|
||||
Else the amount of money would not be transferred
|
||||
"""
|
||||
return ('created_at', 'source', 'destination', 'quantity', 'amount') if obj else ()
|
||||
|
||||
|
||||
@admin.register(TransactionTemplate, site=admin_site)
|
||||
class TransactionTemplateAdmin(admin.ModelAdmin):
|
||||
|
Reference in New Issue
Block a user