From 5d09c69f2c38f3206628fc9ff3264892f340e990 Mon Sep 17 00:00:00 2001 From: Ivo Branco Date: Fri, 12 Apr 2024 14:25:19 +0100 Subject: [PATCH] feat: add retry sent to financial manager on admin Add an action to Django Admin that allows to retry send the information to financial manager. --- nau_extensions/admin.py | 31 +++++++++++++++++- .../locale/en/LC_MESSAGES/django.po | 14 +++++++- .../locale/pt_PT/LC_MESSAGES/django.mo | Bin 1861 -> 2250 bytes .../locale/pt_PT/LC_MESSAGES/django.po | 14 +++++++- 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/nau_extensions/admin.py b/nau_extensions/admin.py index 149df0d..c1d09bf 100644 --- a/nau_extensions/admin.py +++ b/nau_extensions/admin.py @@ -1,7 +1,10 @@ from pprint import pformat -from django.contrib import admin +from django.contrib import admin, messages from django.utils.html import format_html +from django.utils.translation import gettext_lazy as _ +from nau_extensions.financial_manager import \ + send_to_financial_manager_if_enabled from nau_extensions.models import (BasketBillingInformation, BasketTransactionIntegration) @@ -28,3 +31,29 @@ def formatted_response(self, obj): # Use format_html() to escape user-provided inputs, avoiding an XSS vulnerability. return format_html('

{}
', pretty_response) + + @admin.action(description=_("Retry Send to Financial Manager System")) + def retry_send_to_financial_manager(self, request, queryset): + """ + Django admin action that permit to retry send information to financial manager. + """ + for bti in queryset: + sent = send_to_financial_manager_if_enabled(bti) + if sent: + self.message_user( + request, + _( + "Retry Send to Financial Manager System with success.", + ), + messages.SUCCESS, + ) + else: + self.message_user( + request, + _( + "Retry Send to Financial Manager System with an error.", + ), + messages.ERROR, + ) + + actions = [retry_send_to_financial_manager] diff --git a/nau_extensions/locale/en/LC_MESSAGES/django.po b/nau_extensions/locale/en/LC_MESSAGES/django.po index a3252e2..94c31e4 100644 --- a/nau_extensions/locale/en/LC_MESSAGES/django.po +++ b/nau_extensions/locale/en/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-19 17:43+0000\n" +"POT-Creation-Date: 2024-04-12 14:12+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,6 +18,18 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#: nau_extensions/admin.py:35 +msgid "Retry Send to Financial Manager System" +msgstr "" + +#: nau_extensions/admin.py:46 +msgid "Retry Send to Financial Manager System with success." +msgstr "" + +#: nau_extensions/admin.py:54 +msgid "Retry Send to Financial Manager System with an error." +msgstr "" + #: nau_extensions/models.py:36 #: nau_extensions/templates/nau_extensions/checkout/basket_billing_information/vatin.html:21 msgid "VAT Identification Number (VATIN)" diff --git a/nau_extensions/locale/pt_PT/LC_MESSAGES/django.mo b/nau_extensions/locale/pt_PT/LC_MESSAGES/django.mo index 91adaa04f7e61d35c5d8d92d4dcd73bf8149e4a3..116577df46851dd2254190b88d96cd076df8e77d 100644 GIT binary patch delta 907 zcma*kzfTlF6u|L!z=^0JcYr8dbcDcFQVnbkThL?-md+9(W>b_+O(pa zpPbi?<8*1$fu_-F=}9Q503?-BHG@ulp=mIBRazZ+`75)WymO<_HX-ICNd&8&Lyys^Gw47G|WK#^5k|;IEe=O_&&mqY=A|=q^ J;4u9n^&2`LpAi56 delta 530 zcmXxhJ4*vW6o%om*^TQpW}{Jww`h|ptssb?g_UiZbdlKE=z>}(=|zN)SXsEWZ7S_j zq>->zLO{^J5b+1-`vv#F?6Wh>nK?7_8uT)a&zyH}!~$)F)~Bt~t{gtZ5NGfk3;2u6 zSV)=8;ug-~0s2_QEFPhUA#UR3fByj|=toF?!=CsF7fgm3fox5 z2*)r+QtTZUDQa^9^Qf4oX_B5p#i%e%)|DxAGfAiz vJxvn29Tlccb)&3r8Ja>*p`xhOY_DEFI}XEQSUYbWrXD-j?wZ@#^>3X&5iBgM diff --git a/nau_extensions/locale/pt_PT/LC_MESSAGES/django.po b/nau_extensions/locale/pt_PT/LC_MESSAGES/django.po index 8504351..0337c87 100644 --- a/nau_extensions/locale/pt_PT/LC_MESSAGES/django.po +++ b/nau_extensions/locale/pt_PT/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-19 17:43+0000\n" +"POT-Creation-Date: 2024-04-12 14:12+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,6 +17,18 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +#: nau_extensions/admin.py:35 +msgid "Retry Send to Financial Manager System" +msgstr "Repetir envio para o sistema de gestão financeira" + +#: nau_extensions/admin.py:46 +msgid "Retry Send to Financial Manager System with success." +msgstr "Reenvio para o sistema de gestão financeira com sucesso" + +#: nau_extensions/admin.py:54 +msgid "Retry Send to Financial Manager System with an error." +msgstr "Reenvio para o sistema de gestão financeira com erro." + #: nau_extensions/models.py:36 #: nau_extensions/templates/nau_extensions/checkout/basket_billing_information/vatin.html:21 msgid "VAT Identification Number (VATIN)"