|
|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
from django.contrib import admin, messages
|
|
|
|
|
from django.utils.safestring import mark_safe
|
|
|
|
|
from django import forms
|
|
|
|
|
from django.forms import Textarea, ClearableFileInput
|
|
|
|
|
from django.http import HttpResponse, HttpResponseRedirect
|
|
|
|
|
@ -112,12 +113,23 @@ class StatementUnSubmittedAdmin(CommonAdminMixin, admin.ModelAdmin):
|
|
|
|
|
|
|
|
|
|
class TransactionOnSubmittedStatementInline(admin.TabularInline):
|
|
|
|
|
model = Transaction
|
|
|
|
|
fields = ['amount', 'member', 'reference', 'ledger']
|
|
|
|
|
fields = ['amount', 'member', 'reference', 'text_length_warning', 'ledger']
|
|
|
|
|
formfield_overrides = {
|
|
|
|
|
TextField: {'widget': Textarea(attrs={'rows': 1, 'cols': 40})}
|
|
|
|
|
}
|
|
|
|
|
readonly_fields = ['text_length_warning']
|
|
|
|
|
extra = 0
|
|
|
|
|
|
|
|
|
|
def text_length_warning(self, obj):
|
|
|
|
|
"""Display reference length, warn if exceeds 140 characters."""
|
|
|
|
|
len_reference = len(obj.reference)
|
|
|
|
|
len_string = f"{len_reference}/140"
|
|
|
|
|
if len_reference > 140:
|
|
|
|
|
return mark_safe(f'<span style="color: red;">{len_string}</span>')
|
|
|
|
|
|
|
|
|
|
return len_string
|
|
|
|
|
text_length_warning.short_description = "Länge"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BillOnSubmittedStatementInline(BillOnStatementInline):
|
|
|
|
|
model = BillOnStatementProxy
|
|
|
|
|
|