diff --git a/jdav_web/finance/admin.py b/jdav_web/finance/admin.py index f277f3b..3decee5 100644 --- a/jdav_web/finance/admin.py +++ b/jdav_web/finance/admin.py @@ -32,12 +32,12 @@ class BillOnStatementInline(admin.TabularInline): @admin.register(StatementUnSubmitted) -class StatementUnSubmitteddAdmin(admin.ModelAdmin): +class StatementUnSubmittedAdmin(admin.ModelAdmin): fields = ['short_description', 'explanation', 'excursion', 'submitted'] inlines = [BillOnStatementInline] def get_readonly_fields(self, request, obj=None): - readonly_fields = ['submitted'] + readonly_fields = ['submitted', 'excursion'] if obj is not None and obj.submitted: return readonly_fields + self.fields else: @@ -67,7 +67,7 @@ class StatementUnSubmitteddAdmin(admin.ModelAdmin): if statement.submitted: messages.error(request, _("%(name)s is already submitted.") % {'name': str(statement)}) - return HttpResponseRedirect(reverse('admin:%s_%s_changelist' % (self.opts.app_label, self.opts.model_name), args=(statement.pk,))) + return HttpResponseRedirect(reverse('admin:%s_%s_changelist' % (self.opts.app_label, self.opts.model_name))) if "apply" in request.POST: statement.submit(get_member(request)) @@ -250,7 +250,11 @@ class TransactionAdmin(admin.ModelAdmin): list_filter = ('ledger', 'member', 'statement', 'confirmed') search_fields = ('reference', ) fields = ['reference', 'amount', 'member', 'ledger', 'statement'] - readonly_fields = fields + + def get_readonly_fields(self, request, obj=None): + if obj is not None and obj.confirmed: + return self.fields + return super(TransactionAdmin, self).get_readonly_fields(request, obj) @admin.register(Bill) diff --git a/jdav_web/finance/apps.py b/jdav_web/finance/apps.py index 53023d8..5233c0d 100644 --- a/jdav_web/finance/apps.py +++ b/jdav_web/finance/apps.py @@ -1,6 +1,8 @@ from django.apps import AppConfig +from django.utils.translation import gettext_lazy as _ class FinanceConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'finance' + verbose_name = _('Finance') diff --git a/jdav_web/finance/locale/de/LC_MESSAGES/django.po b/jdav_web/finance/locale/de/LC_MESSAGES/django.po index a0a2344..705dd7a 100644 --- a/jdav_web/finance/locale/de/LC_MESSAGES/django.po +++ b/jdav_web/finance/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-03-17 21:05+0100\n" +"POT-Creation-Date: 2023-03-17 23:19+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -104,11 +104,15 @@ msgstr "Eingereichte Abrechnung einsehen" msgid "Successfully reduced transactions for %(name)s." msgstr "Überweisungsträger für %(name)s minimiert." +#: apps.py:8 +msgid "Finance" +msgstr "Finanzen" + #: models.py:13 msgid "Name" msgstr "Name" -#: models.py:19 models.py:351 models.py:375 +#: models.py:19 models.py:352 models.py:376 #: templates/admin/confirmed_statement.html:38 #: templates/admin/overview_submitted_statement.html:100 msgid "Ledger" @@ -118,7 +122,7 @@ msgstr "Geldtopf" msgid "Ledgers" msgstr "Geldtöpfe" -#: models.py:42 models.py:323 models.py:374 +#: models.py:42 models.py:323 models.py:375 msgid "Short description" msgstr "Kurzbeschreibung" @@ -146,7 +150,7 @@ msgstr "Eingereicht am" msgid "Confirmed" msgstr "Abgewickelt" -#: models.py:57 models.py:358 +#: models.py:57 models.py:359 msgid "Paid on" msgstr "Bezahlt am" @@ -154,11 +158,11 @@ msgstr "Bezahlt am" msgid "Submitted by" msgstr "Eingereicht bei" -#: models.py:64 models.py:327 models.py:359 +#: models.py:64 models.py:360 msgid "Authorized by" msgstr "Autorisiert von" -#: models.py:71 models.py:322 models.py:354 +#: models.py:71 models.py:322 models.py:355 msgid "Statement" msgstr "Abrechnung" @@ -208,6 +212,10 @@ msgstr "Bezahlte Abrechnung" msgid "Paid statements" msgstr "Bezahlte Abrechnungen" +#: models.py:327 +msgid "Paid by" +msgstr "Bezahlt von" + #: models.py:329 msgid "Covered" msgstr "Übernommen" @@ -220,32 +228,38 @@ msgstr "Ausgezahlt" msgid "Proof" msgstr "Beleg" -#: models.py:342 +#: models.py:340 models.py:349 templates/admin/confirmed_statement.html:36 +#: templates/admin/overview_submitted_statement.html:31 +#: templates/admin/overview_submitted_statement.html:98 +msgid "Amount" +msgstr "Betrag" + +#: models.py:343 msgid "Bill" msgstr "Quittung" -#: models.py:343 templates/admin/overview_submitted_statement.html:26 +#: models.py:344 templates/admin/overview_submitted_statement.html:26 msgid "Bills" msgstr "Quittungen" -#: models.py:347 templates/admin/confirmed_statement.html:37 +#: models.py:348 templates/admin/confirmed_statement.html:37 #: templates/admin/overview_submitted_statement.html:99 msgid "Reference" msgstr "Verwendungszweck" -#: models.py:349 +#: models.py:350 msgid "Recipient" msgstr "Empfänger" -#: models.py:357 +#: models.py:358 msgid "Paid" msgstr "Bezahlt" -#: models.py:369 +#: models.py:370 msgid "Transaction" msgstr "Überweisung" -#: models.py:370 templates/admin/overview_submitted_statement.html:84 +#: models.py:371 templates/admin/overview_submitted_statement.html:84 msgid "Transactions" msgstr "Überweisungen" @@ -275,12 +289,6 @@ msgstr "" msgid "IBAN" msgstr "IBAN" -#: templates/admin/confirmed_statement.html:36 -#: templates/admin/overview_submitted_statement.html:31 -#: templates/admin/overview_submitted_statement.html:98 -msgid "Amount" -msgstr "Betrag" - #: templates/admin/confirmed_statement.html:66 msgid "I did execute the listed transactions." msgstr "Ich habe die aufgeführten Überweisungen ausgeführt." diff --git a/jdav_web/finance/models.py b/jdav_web/finance/models.py index 6c532b5..8c47230 100644 --- a/jdav_web/finance/models.py +++ b/jdav_web/finance/models.py @@ -324,7 +324,7 @@ class Bill(models.Model): explanation = models.TextField(verbose_name=_('Explanation'), blank=True) amount = models.DecimalField(max_digits=6, decimal_places=2, default=0) - paid_by = models.ForeignKey(Member, verbose_name=_('Authorized by'), null=True, + paid_by = models.ForeignKey(Member, verbose_name=_('Paid by'), null=True, on_delete=models.SET_NULL) costs_covered = models.BooleanField(verbose_name=_('Covered'), default=False) refunded = models.BooleanField(verbose_name=_('Refunded'), default=False) diff --git a/jdav_web/locale/de/LC_MESSAGES/django.po b/jdav_web/locale/de/LC_MESSAGES/django.po index f6f5eee..88fde65 100644 --- a/jdav_web/locale/de/LC_MESSAGES/django.po +++ b/jdav_web/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-10-02 12:55+0200\n" +"POT-Creation-Date: 2023-03-17 23:10+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -22,6 +22,31 @@ msgstr "" msgid "Startpage" msgstr "Startseite" +#: templates/admin/finance/statementconfirmed/change_form_object_tools.html:8 +msgid "Unconfirm" +msgstr "" + +#: templates/admin/finance/statementsubmitted/change_form_object_tools.html:21 +msgid "Reduce transactions" +msgstr "Überweisungen minimieren" + +#: templates/admin/finance/statementsubmitted/change_form_object_tools.html:36 +msgid "Overview" +msgstr "Übersicht" + +#: templates/admin/finance/statementunsubmitted/change_form_object_tools.html:9 +msgid "Submit" +msgstr "Einreichen" + +#: templates/admin/members/freizeit/change_form_object_tools.html:8 +msgid "Submit statement" +msgstr "Abrechnung einreichen" + +#: templates/admin/members/memberwaitinglist/change_form_object_tools.html:8 +#: templates/admin/members/memberwaitinglist/submit_line.html:9 +msgid "Invite to group" +msgstr "Zu Gruppe einladen" + #: utils.py:26 msgid "Filetype not supported." msgstr "Dateityp nicht unterstützt." diff --git a/jdav_web/members/admin.py b/jdav_web/members/admin.py index 7868981..90d9e8a 100644 --- a/jdav_web/members/admin.py +++ b/jdav_web/members/admin.py @@ -410,14 +410,24 @@ class BillOnStatementInline(admin.TabularInline): TextField: {'widget': Textarea(attrs={'rows': 1, 'cols': 40})} } + def get_readonly_fields(self, request, obj=None): + if obj is not None and obj.submitted: + return self.fields + return super(BillOnStatementInline, self).get_readonly_fields(request, obj) + class StatementOnListInline(nested_admin.NestedStackedInline): model = Statement extra = 1 sortable_options = [] - fields = ['explanation'] + fields = ['night_cost'] inlines = [BillOnStatementInline] + def get_readonly_fields(self, request, obj=None): + if obj is not None and hasattr(obj, 'statement') and obj.statement.submitted: + return self.fields + return super(StatementOnListInline, self).get_readonly_fields(request, obj) + class InterventionOnLJPInline(admin.TabularInline): model = Intervention diff --git a/jdav_web/templates/admin/members/freizeit/change_form_object_tools.html b/jdav_web/templates/admin/members/freizeit/change_form_object_tools.html new file mode 100644 index 0000000..fc52ee7 --- /dev/null +++ b/jdav_web/templates/admin/members/freizeit/change_form_object_tools.html @@ -0,0 +1,14 @@ +{% extends "admin/change_form_object_tools.html" %} +{% load i18n admin_urls %} + +{% block object-tools-items %} + +
  • + {% if original.statement and not original.statement.submitted %} + {% trans 'Submit statement' %} + {% endif %} +
  • + +{{block.super}} + +{% endblock %}