diff --git a/BaseBillet/templates/htmx/fragments/card.html b/BaseBillet/templates/htmx/fragments/card.html deleted file mode 100644 index 203bb5f4..00000000 --- a/BaseBillet/templates/htmx/fragments/card.html +++ /dev/null @@ -1,10 +0,0 @@ -{% load static %} -
-
-
-
Some Kind Of Blues
-

Deftones

-
-
- diff --git a/BaseBillet/templates/htmx/fragments/cards.html b/BaseBillet/templates/htmx/fragments/cards.html new file mode 100644 index 00000000..2c15bb9f --- /dev/null +++ b/BaseBillet/templates/htmx/fragments/cards.html @@ -0,0 +1,24 @@ +{% load tibitags %} +{% load i18n %} +{% load static %} + +{% for card in cards %} +
+
+
+
Number : {{ card.number_printed }}
+

Origin : {{ card.origin.place.name }}

+

Génération : {{ card.origin.generation }}

+
+
+
{% translate "If you've lost your card, please report it. Your account will not be deleted, and you will keep your tokens and memberships. You can request and scan a new blank card at the front desk of your favorite venue :)" %}
+ +{% endfor %} + diff --git a/BaseBillet/templates/htmx/fragments/my_account_profil.html b/BaseBillet/templates/htmx/fragments/my_account_profil.html index e579eaaf..c2f2ff29 100644 --- a/BaseBillet/templates/htmx/fragments/my_account_profil.html +++ b/BaseBillet/templates/htmx/fragments/my_account_profil.html @@ -1,6 +1,7 @@ {% load i18n %} +
-

{% translate "My account" %}

+

{% translate "My cards" %}

{% if not user.email_valid %} {% translate "Thanks to valid your email for activate your accont" %} @@ -11,6 +12,16 @@

{% translate "My account" %}

{% translate "Resend validation email" %} {% else %} - {% translate "email verified" %} +{# {% translate "email verified" %}#} +
+ {% translate "Loading NFC Card info" %} +
+
+
+
+ + {% endif %} -
\ No newline at end of file + diff --git a/BaseBillet/templatetags/tibitags.py b/BaseBillet/templatetags/tibitags.py index e3d959c5..91bcb38b 100644 --- a/BaseBillet/templatetags/tibitags.py +++ b/BaseBillet/templatetags/tibitags.py @@ -71,6 +71,11 @@ def randImg(value): return f"/static/images/404-{randint(1,9)}.jpg" return value +@register.filter +def randCardImg(value): + if not value : + return f"/static/images/404-Card-1.jpg" + return value # @register.filter # def wallet_name(wallet): # return wallet.uuid \ No newline at end of file diff --git a/BaseBillet/views.py b/BaseBillet/views.py index 0a154756..6d043071 100644 --- a/BaseBillet/views.py +++ b/BaseBillet/views.py @@ -254,8 +254,30 @@ def wallet(self, request: HttpRequest) -> HttpResponse: template_context['header'] = False return render(request, "htmx/fragments/my_account_wallet.html", context=template_context) - # @action(detail=False, methods=['GET']) - # def my_card(self, request): + @action(detail=False, methods=['GET']) + def my_cards(self, request): + if request.user.email_valid: + fedowAPI = FedowAPI() + cards = fedowAPI.NFCcard.retrieve_card_by_signature(request.user) + context = { + 'cards': cards + } + return render(request, "htmx/fragments/cards.html", context=context) + else : + logger.warning("User email not active") + + @action(detail=True, methods=['GET']) + def lost_my_card(self, request, pk): + if request.user.email_valid: + fedowAPI = FedowAPI() + lost_card_report = fedowAPI.NFCcard.lost_my_card_by_signature(request.user, number_printed=pk) + if lost_card_report : + messages.add_message(request, messages.SUCCESS, _("Your wallet has been detached from this card. You can scan a new one to link it again.")) + else : + messages.add_message(request, messages.ERROR, _("Error when detaching your card. Contact an administrator.")) + return HttpResponseClientRedirect('/my_account/') + else : + logger.warning("User email not active") @action(detail=False, methods=['GET']) def tokens_table(self, request): diff --git a/bashrc b/bashrc index 889e4f01..ddb82174 100644 --- a/bashrc +++ b/bashrc @@ -8,8 +8,8 @@ alias cel="poetry run celery -A TiBillet worker -l INFO" alias test="poetry run python /DjangoFiles/manage.py test" -alias mmes="django-admin makemessages -l en && django-admin makemessages -l fr" -alias cmes="django-admin compilemessages" +alias mmes="poetry run django-admin makemessages -l en && django-admin makemessages -l fr" +alias cmes="poetry run django-admin compilemessages" tibinstall() { poetry run python /DjangoFiles/manage.py collectstatic diff --git a/fedow_connect/fedow_api.py b/fedow_connect/fedow_api.py index 3f4eee26..34dc4b4c 100644 --- a/fedow_connect/fedow_api.py +++ b/fedow_connect/fedow_api.py @@ -450,6 +450,37 @@ def __init__(self, fedow_config: FedowConfig or None = None): if fedow_config is None: self.config = FedowConfig.get_solo() + def retrieve_card_by_signature(self, user: TibilletUser): + response_get_card = _get( + self.fedow_config, + user=user, + path=f'card/retrieve_card_by_signature', + ) + + if not response_get_card.status_code == 200: + logger.error(f"retrieve_by_signature ERRORS : {response_get_card.status_code}") + raise Exception(f"retrieve_by_signature ERRORS : {response_get_card.status_code}") + + card_serialized = CardValidator(data=response_get_card.json(), many=True) + if card_serialized.is_valid(): + return card_serialized.validated_data + else: + logger.error(f"retrieve_by_signature card_serialized ERRORS : {card_serialized.errors}") + raise Exception(f"retrieve_by_signature card_serialized ERRORS : {card_serialized.errors}") + + def lost_my_card_by_signature(self, user, number_printed): + response_lost_my_card = _post( + self.fedow_config, + user=user, + path=f'card/lost_my_card_by_signature', + data={'number_printed': number_printed} + ) + + if not response_lost_my_card.status_code == 200: + logger.error(f"retrieve_by_signature ERRORS : {response_lost_my_card.status_code}") + raise Exception(f"retrieve_by_signature ERRORS : {response_lost_my_card.status_code}") + return True + def qr_retrieve(self, qrcode_uuid: uuid4): # On vérifie que l'uuid soit bien un uuid : checked_uuid = uuid.UUID(str(qrcode_uuid)) diff --git a/locale/en/LC_MESSAGES/django.po b/locale/en/LC_MESSAGES/django.po index 72f6a154..33a48cb7 100644 --- a/locale/en/LC_MESSAGES/django.po +++ b/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-06-09 20:13+0000\n" +"POT-Creation-Date: 2024-06-11 13:03+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -865,12 +865,12 @@ msgid "Réservation validée" msgstr "" #: BaseBillet/templates/htmx/fragments/my_account_membership.html:4 -#: BaseBillet/templates/htmx/fragments/my_account_wallet.html:14 +#: BaseBillet/templates/htmx/fragments/my_account_wallet.html:18 msgid "Loading tokens" msgstr "" #: BaseBillet/templates/htmx/fragments/my_account_profil.html:3 -msgid "My profil" +msgid "My account" msgstr "" #: BaseBillet/templates/htmx/fragments/my_account_profil.html:5 @@ -881,15 +881,19 @@ msgstr "" msgid "Resend validation email" msgstr "" -#: BaseBillet/templates/htmx/fragments/my_account_profil.html:16 -msgid "My card" +#: BaseBillet/templates/htmx/fragments/my_account_profil.html:14 +msgid "email verified" msgstr "" -#: BaseBillet/templates/htmx/fragments/my_account_wallet.html:9 +#: BaseBillet/templates/htmx/fragments/my_account_profil.html:17 +msgid "Loading NFC Card info" +msgstr "" + +#: BaseBillet/templates/htmx/fragments/my_account_wallet.html:12 msgid "Refill my wallet" msgstr "" -#: BaseBillet/templates/htmx/fragments/my_account_wallet.html:30 +#: BaseBillet/templates/htmx/fragments/my_account_wallet.html:35 msgid "Show the last transactions" msgstr "" @@ -946,11 +950,11 @@ msgstr "" msgid "Terms and Conditions" msgstr "" -#: BaseBillet/templates/htmx/views/inscription.html:77 +#: BaseBillet/templates/htmx/views/inscription.html:78 msgid "Sign up" msgstr "" -#: BaseBillet/templates/htmx/views/inscription.html:83 +#: BaseBillet/templates/htmx/views/inscription.html:84 msgid "" "Learn more about TiBillet, a free and privacy-friendly software for " "cooperatives networks :" @@ -991,22 +995,50 @@ msgid "" "compte. Vous trouverez la facture en pièce jointe." msgstr "" -#: BaseBillet/views.py:201 BaseBillet/views.py:254 +#: BaseBillet/views.py:132 +msgid "" +"To access your space, please validate\n" +"your email address. Don't forget to check your spam!" +msgstr "" + +#: BaseBillet/views.py:191 BaseBillet/views.py:244 msgid "" -"Merci de valider votre email pour acceder à toute les fonctionnalitées de " -"votre espace profil." +"Please validate your email to access all the features of your profile area." msgstr "" -#: BaseBillet/views.py:227 +#: BaseBillet/views.py:217 msgid "" -"Vous semblez déja posséder une carte TiBillet en lien avec votre " -"portefeuille. Merci de la révoquer d'abord dans votre espace profil." +"You seem to already have a TiBillet card linked to your wallet. Please " +"revoke it first in your profile area to link a new one." msgstr "" -#: BaseBillet/views.py:232 +#: BaseBillet/views.py:222 msgid "Not valid" msgstr "" +#: BaseBillet/views.py:363 +msgid "Refilled wallet" +msgstr "" + +#: BaseBillet/views.py:365 +msgid "Payment verification error" +msgstr "" + +#: BaseBillet/views.py:473 +#, python-brace-format +msgid "" +"Your subscription has been validated. You will receive a confirmation email " +"at {email}. Thank you very much!" +msgstr "" + +#: BaseBillet/views.py:475 +msgid "Your payment is awaiting validation." +msgstr "" + +#: BaseBillet/views.py:478 +msgid "An error has occurred, please contact the administrator." +msgstr "" + #: Customers/models.py:18 MetaBillet/models.py:165 msgid "Artiste" msgstr "" diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 79c7f8ed..84a87f5d 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/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-06-09 20:13+0000\n" +"POT-Creation-Date: 2024-06-11 13:03+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -865,12 +865,12 @@ msgid "Réservation validée" msgstr "" #: BaseBillet/templates/htmx/fragments/my_account_membership.html:4 -#: BaseBillet/templates/htmx/fragments/my_account_wallet.html:14 +#: BaseBillet/templates/htmx/fragments/my_account_wallet.html:18 msgid "Loading tokens" msgstr "" #: BaseBillet/templates/htmx/fragments/my_account_profil.html:3 -msgid "My profil" +msgid "My account" msgstr "" #: BaseBillet/templates/htmx/fragments/my_account_profil.html:5 @@ -881,15 +881,19 @@ msgstr "" msgid "Resend validation email" msgstr "" -#: BaseBillet/templates/htmx/fragments/my_account_profil.html:16 -msgid "My card" +#: BaseBillet/templates/htmx/fragments/my_account_profil.html:14 +msgid "email verified" msgstr "" -#: BaseBillet/templates/htmx/fragments/my_account_wallet.html:9 +#: BaseBillet/templates/htmx/fragments/my_account_profil.html:17 +msgid "Loading NFC Card info" +msgstr "" + +#: BaseBillet/templates/htmx/fragments/my_account_wallet.html:12 msgid "Refill my wallet" msgstr "" -#: BaseBillet/templates/htmx/fragments/my_account_wallet.html:30 +#: BaseBillet/templates/htmx/fragments/my_account_wallet.html:35 msgid "Show the last transactions" msgstr "" @@ -946,11 +950,11 @@ msgstr "J'accepte les" msgid "Terms and Conditions" msgstr "CGU/CGV" -#: BaseBillet/templates/htmx/views/inscription.html:77 +#: BaseBillet/templates/htmx/views/inscription.html:78 msgid "Sign up" msgstr "S'enregistrer" -#: BaseBillet/templates/htmx/views/inscription.html:83 +#: BaseBillet/templates/htmx/views/inscription.html:84 msgid "" "Learn more about TiBillet, a free and privacy-friendly software for " "cooperatives networks :" @@ -993,22 +997,50 @@ msgid "" "compte. Vous trouverez la facture en pièce jointe." msgstr "" -#: BaseBillet/views.py:201 BaseBillet/views.py:254 +#: BaseBillet/views.py:132 +msgid "" +"To access your space, please validate\n" +"your email address. Don't forget to check your spam!" +msgstr "" + +#: BaseBillet/views.py:191 BaseBillet/views.py:244 msgid "" -"Merci de valider votre email pour acceder à toute les fonctionnalitées de " -"votre espace profil." +"Please validate your email to access all the features of your profile area." msgstr "" -#: BaseBillet/views.py:227 +#: BaseBillet/views.py:217 msgid "" -"Vous semblez déja posséder une carte TiBillet en lien avec votre " -"portefeuille. Merci de la révoquer d'abord dans votre espace profil." +"You seem to already have a TiBillet card linked to your wallet. Please " +"revoke it first in your profile area to link a new one." msgstr "" -#: BaseBillet/views.py:232 +#: BaseBillet/views.py:222 msgid "Not valid" msgstr "" +#: BaseBillet/views.py:363 +msgid "Refilled wallet" +msgstr "" + +#: BaseBillet/views.py:365 +msgid "Payment verification error" +msgstr "" + +#: BaseBillet/views.py:473 +#, python-brace-format +msgid "" +"Your subscription has been validated. You will receive a confirmation email " +"at {email}. Thank you very much!" +msgstr "" + +#: BaseBillet/views.py:475 +msgid "Your payment is awaiting validation." +msgstr "" + +#: BaseBillet/views.py:478 +msgid "An error has occurred, please contact the administrator." +msgstr "" + #: Customers/models.py:18 MetaBillet/models.py:165 msgid "Artiste" msgstr ""