|
|
|
@ -91,7 +91,7 @@ class StatementUnSubmittedAdmin(CommonAdminMixin, admin.ModelAdmin):
|
|
|
|
messages.success(request,
|
|
|
|
messages.success(request,
|
|
|
|
_("Successfully submited %(name)s. The finance department will notify the requestors as soon as possible.") % {'name': str(statement)})
|
|
|
|
_("Successfully submited %(name)s. The finance department will notify the requestors as soon as possible.") % {'name': str(statement)})
|
|
|
|
return HttpResponseRedirect(reverse('admin:%s_%s_changelist' % (self.opts.app_label, self.opts.model_name)))
|
|
|
|
return HttpResponseRedirect(reverse('admin:%s_%s_changelist' % (self.opts.app_label, self.opts.model_name)))
|
|
|
|
|
|
|
|
|
|
|
|
if statement.excursion:
|
|
|
|
if statement.excursion:
|
|
|
|
memberlist = statement.excursion
|
|
|
|
memberlist = statement.excursion
|
|
|
|
context = dict(self.admin_site.each_context(request),
|
|
|
|
context = dict(self.admin_site.each_context(request),
|
|
|
|
@ -120,16 +120,16 @@ class TransactionOnSubmittedStatementInline(admin.TabularInline):
|
|
|
|
}
|
|
|
|
}
|
|
|
|
readonly_fields = ['text_length_warning']
|
|
|
|
readonly_fields = ['text_length_warning']
|
|
|
|
extra = 0
|
|
|
|
extra = 0
|
|
|
|
|
|
|
|
|
|
|
|
def text_length_warning(self, obj):
|
|
|
|
def text_length_warning(self, obj):
|
|
|
|
"""Display reference length, warn if exceeds 140 characters."""
|
|
|
|
"""Display reference length, warn if exceeds 140 characters."""
|
|
|
|
len_reference = len(obj.reference)
|
|
|
|
len_reference = len(obj.reference)
|
|
|
|
len_string = f"{len_reference}/140"
|
|
|
|
len_string = f"{len_reference}/140"
|
|
|
|
if len_reference > 140:
|
|
|
|
if len_reference > 140:
|
|
|
|
return mark_safe(f'<span style="color: red;">{len_string}</span>')
|
|
|
|
return mark_safe(f'<span style="color: red;">{len_string}</span>')
|
|
|
|
|
|
|
|
|
|
|
|
return len_string
|
|
|
|
return len_string
|
|
|
|
text_length_warning.short_description = "Länge"
|
|
|
|
text_length_warning.short_description = _("Length")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BillOnSubmittedStatementInline(BillOnStatementInline):
|
|
|
|
class BillOnSubmittedStatementInline(BillOnStatementInline):
|
|
|
|
@ -213,8 +213,9 @@ class StatementSubmittedAdmin(admin.ModelAdmin):
|
|
|
|
messages.success(request,
|
|
|
|
messages.success(request,
|
|
|
|
_("Successfully confirmed %(name)s. I hope you executed the associated transactions, I wont remind you again.")
|
|
|
|
_("Successfully confirmed %(name)s. I hope you executed the associated transactions, I wont remind you again.")
|
|
|
|
% {'name': str(statement)})
|
|
|
|
% {'name': str(statement)})
|
|
|
|
|
|
|
|
download_link = reverse('admin:finance_statementconfirmed_summary', args=(statement.pk,))
|
|
|
|
messages.success(request,
|
|
|
|
messages.success(request,
|
|
|
|
mark_safe(f"Hier kannst du den Abrechnungsbeleg <a href='../statementconfirmed/{object_id}/summary/' target='_blank'>herunterladen</a>.")) #TODO: nice path resolution
|
|
|
|
mark_safe(_("You can download a <a href='%(link)s', target='_blank'>receipt</a>.") % {'link': download_link}))
|
|
|
|
return HttpResponseRedirect(reverse('admin:%s_%s_changelist' % (self.opts.app_label, self.opts.model_name)))
|
|
|
|
return HttpResponseRedirect(reverse('admin:%s_%s_changelist' % (self.opts.app_label, self.opts.model_name)))
|
|
|
|
if "confirm" in request.POST:
|
|
|
|
if "confirm" in request.POST:
|
|
|
|
res = statement.validity
|
|
|
|
res = statement.validity
|
|
|
|
@ -351,21 +352,25 @@ class StatementConfirmedAdmin(admin.ModelAdmin):
|
|
|
|
statement=statement)
|
|
|
|
statement=statement)
|
|
|
|
|
|
|
|
|
|
|
|
return render(request, 'admin/unconfirm_statement.html', context=context)
|
|
|
|
return render(request, 'admin/unconfirm_statement.html', context=context)
|
|
|
|
|
|
|
|
|
|
|
|
def statement_summary_view(self, request, object_id):
|
|
|
|
def statement_summary_view(self, request, object_id):
|
|
|
|
statement = StatementConfirmed.objects.get(pk=object_id)
|
|
|
|
try:
|
|
|
|
|
|
|
|
statement = StatementConfirmed.objects.get(pk=object_id)
|
|
|
|
|
|
|
|
except StatementConfirmed.DoesNotExist:
|
|
|
|
|
|
|
|
messages.error(request, _('Statement not found.'))
|
|
|
|
|
|
|
|
return HttpResponseRedirect(reverse('admin:%s_%s_changelist' % (self.opts.app_label, self.opts.model_name)))
|
|
|
|
|
|
|
|
|
|
|
|
if not statement.confirmed:
|
|
|
|
if not statement.confirmed:
|
|
|
|
messages.error(request,
|
|
|
|
messages.error(request,
|
|
|
|
_("%(name)s is not yet confirmed.") % {'name': str(statement)})
|
|
|
|
_("%(name)s is not yet confirmed.") % {'name': str(statement)})
|
|
|
|
return HttpResponseRedirect(reverse('admin:%s_%s_change' % (self.opts.app_label, self.opts.model_name), args=(statement.pk,)))
|
|
|
|
return HttpResponseRedirect(reverse('admin:%s_%s_change' % (self.opts.app_label, self.opts.model_name), args=(statement.pk,)))
|
|
|
|
excursion = statement.excursion
|
|
|
|
excursion = statement.excursion
|
|
|
|
context = dict(statement=statement.template_context(), excursion=excursion, settings=settings)
|
|
|
|
context = dict(statement=statement.template_context(), excursion=excursion, settings=settings)
|
|
|
|
|
|
|
|
|
|
|
|
pdf_filename = f"{excursion.code}_{excursion.name}_Zuschussbeleg" if excursion else f"Abrechnungsbeleg"
|
|
|
|
pdf_filename = f"{excursion.code}_{excursion.name}_Zuschussbeleg" if excursion else f"Abrechnungsbeleg"
|
|
|
|
attachments = [bill.proof.path for bill in statement.bills_covered]
|
|
|
|
attachments = [bill.proof.path for bill in statement.bills_covered]
|
|
|
|
return render_tex_with_attachments(pdf_filename, 'finance/statement_summary.tex', context, attachments)
|
|
|
|
return render_tex_with_attachments(pdf_filename, 'finance/statement_summary.tex', context, attachments)
|
|
|
|
|
|
|
|
|
|
|
|
statement_summary_view.short_description = _('Download summary')
|
|
|
|
statement_summary_view.short_description = _('Download summary')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|