Merge pull request #1306 from ae-utbm/cgu

CGV
This commit is contained in:
thomas girod
2026-06-05 13:47:23 +02:00
committed by GitHub
4 changed files with 129 additions and 78 deletions
-1
View File
@@ -141,7 +141,6 @@ form {
display: block; display: block;
margin: calc(var(--nf-input-size) * 1.5) auto 10px; margin: calc(var(--nf-input-size) * 1.5) auto 10px;
line-height: 1; line-height: 1;
white-space: nowrap;
.fields-centered { .fields-centered {
padding: 10px 10px 0; padding: 10px 10px 0;
@@ -6,7 +6,9 @@ interface Basket {
timeout: Date; timeout: Date;
} }
document.addEventListener("alpine:init", () => { document.addEventListener("alpine:init", () => {
Alpine.data("etransaction", (initialData, basket: Basket) => ({ Alpine.data(
"etransaction",
(initialData: Record<string, string>, basket: Basket) => ({
data: initialData, data: initialData,
isCbAvailable: Object.keys(initialData).length > 0, isCbAvailable: Object.keys(initialData).length > 0,
isSithAvailable: true, isSithAvailable: true,
@@ -14,10 +16,11 @@ document.addEventListener("alpine:init", () => {
init() { init() {
const now = new Date(); const now = new Date();
const timeout = basket.timeout.getTime() - now.getTime(); const timeout = basket.timeout.getTime() - now.getTime();
if (timeout <= 0) { if (timeout > 0) {
// basket was already outdated at initial page load // if not going inside this condition, it means that
this.timeoutBasket(); // basket was already outdated at initial page load,
} else { // in which case disabling buttons and displaying
// error message has been done at rendering time
setTimeout(() => this.timeoutBasket(), timeout); setTimeout(() => this.timeoutBasket(), timeout);
} }
}, },
@@ -35,7 +38,7 @@ document.addEventListener("alpine:init", () => {
.getAll() .getAll()
.find( .find(
(n: Notification) => (n: Notification) =>
n.tag === NotificationLevel.Error && n.message === message, n.tag === NotificationLevel.Error && n.text === message,
); );
if (existingNotif === undefined) { if (existingNotif === undefined) {
this.$notifications.error(message); this.$notifications.error(message);
@@ -59,7 +62,7 @@ document.addEventListener("alpine:init", () => {
path: { basket_id: basket.id }, path: { basket_id: basket.id },
}); });
if (res.response.ok) { if (res.response.ok) {
this.data = res.data; this.data = res.data as Record<string, string>;
this.isCbAvailable = true; this.isCbAvailable = true;
} else if (res.response.status === 410) { } else if (res.response.status === 410) {
// The basket is expired, so no payment method should be available at all. // The basket is expired, so no payment method should be available at all.
@@ -68,5 +71,6 @@ document.addEventListener("alpine:init", () => {
this.timeoutBasket(); this.timeoutBasket();
} }
}, },
})); }),
);
}); });
@@ -28,8 +28,8 @@
<thead> <thead>
<tr> <tr>
<td>Article</td> <td>Article</td>
<td>Quantity</td> <td>{% trans %}Quantity{% endtrans %}</td>
<td>Unit price</td> <td>{% trans %}Unit price{% endtrans %}</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -63,10 +63,41 @@
<div @htmx:after-request="fill"> <div @htmx:after-request="fill">
{{ billing_infos_form }} {{ billing_infos_form }}
</div> </div>
{% endif %}
{% include "core/base/notifications.jinja" %} {% include "core/base/notifications.jinja" %}
{% if settings.SITH_EBOUTIC_CB_ENABLED or (basket.total <= user.account_balance and not basket.contains_refilling_item) %}
{# don't display the cgv form if no payment mean is available #}
<form id="cgv-form" x-ref="cgvForm">
{# In order to have one CGV button for both payment means,
we have a third dummy form, containing only the cgv button,
which validation is triggered when one of the two other forms is submitted.
If the validation of this form fails, the submit event will be cancelled. #}
<div class="form-group">
<input
type="checkbox"
id="cgv-checkbox"
name="cgv"
required
{% if basket.is_expired %}
disabled="disabled"
{% else %}
:disabled="!isCbAvailable && !isSithAvailable"
{% endif %}
>
<label for="cgv-checkbox">
{% trans trimmed %}I have read and I accept{% endtrans %}
<a href="{{ url('core:page', 'cgv') }}">{% trans %}the general terms and conditions{% endtrans%}</a>
{%trans%}of the student association of the UTBM{% endtrans %}
</label>
</div>
</form>
{% endif %}
{% if settings.SITH_EBOUTIC_CB_ENABLED %}
<form <form
method="post" method="post"
id="bank-payment-form"
action="{{ settings.SITH_EBOUTIC_ET_URL }}" action="{{ settings.SITH_EBOUTIC_ET_URL }}"
@submit="if (!$refs.cgvForm.reportValidity()) $event.preventDefault()"
> >
<template x-for="[key, value] in Object.entries(data)" :key="key"> <template x-for="[key, value] in Object.entries(data)" :key="key">
<input type="hidden" :name="key" :value="value"> <input type="hidden" :name="key" :value="value">
@@ -98,7 +129,12 @@
{% elif basket.total > user.account_balance %} {% elif basket.total > user.account_balance %}
<p>{% trans %}AE account payment disabled because you do not have enough money remaining.{% endtrans %}</p> <p>{% trans %}AE account payment disabled because you do not have enough money remaining.{% endtrans %}</p>
{% else %} {% else %}
<form method="post" action="{{ url('eboutic:pay_with_sith', basket_id=basket.id) }}" name="sith-pay-form"> <form
method="post"
action="{{ url('eboutic:pay_with_sith', basket_id=basket.id) }}"
id="sith-payment-form"
@submit="if (!$refs.cgvForm.reportValidity()) $event.preventDefault()"
>
{% csrf_token %} {% csrf_token %}
<input <input
{% if basket.is_expired %} {% if basket.is_expired %}
+26 -14
View File
@@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-06-04 17:30+0200\n" "POT-Creation-Date: 2026-06-05 13:39+0200\n"
"PO-Revision-Date: 2016-07-18\n" "PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Maréchal <thomas.girod@utbm.fr\n" "Last-Translator: Maréchal <thomas.girod@utbm.fr\n"
"Language-Team: AE info <ae.info@utbm.fr>\n" "Language-Team: AE info <ae.info@utbm.fr>\n"
@@ -680,6 +680,7 @@ msgstr "Étiquette"
#: core/templates/core/user_account_detail.jinja #: core/templates/core/user_account_detail.jinja
#: core/templates/core/user_stats.jinja #: core/templates/core/user_stats.jinja
#: counter/templates/counter/last_ops.jinja #: counter/templates/counter/last_ops.jinja
#: eboutic/templates/eboutic/eboutic_checkout.jinja
msgid "Quantity" msgid "Quantity"
msgstr "Quantité" msgstr "Quantité"
@@ -963,7 +964,7 @@ msgstr "rôle de club membre"
msgid "Benefit" msgid "Benefit"
msgstr "Bénéfice" msgstr "Bénéfice"
#: club/views.py #: club/views.py eboutic/templates/eboutic/eboutic_checkout.jinja
msgid "Unit price" msgid "Unit price"
msgstr "Prix unitaire" msgstr "Prix unitaire"
@@ -4380,6 +4381,18 @@ msgstr "Solde actuel : "
msgid "Remaining account amount: " msgid "Remaining account amount: "
msgstr "Solde restant : " msgstr "Solde restant : "
#: eboutic/templates/eboutic/eboutic_checkout.jinja
msgid "I have read and I accept"
msgstr "J'ai lu et j'accepte"
#: eboutic/templates/eboutic/eboutic_checkout.jinja
msgid "the general terms and conditions"
msgstr "les conditions générales de vente"
#: eboutic/templates/eboutic/eboutic_checkout.jinja
msgid "of the student association of the UTBM"
msgstr "de l'Association des étudiants de l'UTBM"
#: eboutic/templates/eboutic/eboutic_checkout.jinja #: eboutic/templates/eboutic/eboutic_checkout.jinja
msgid "Pay with credit card" msgid "Pay with credit card"
msgstr "Payer avec une carte bancaire" msgstr "Payer avec une carte bancaire"
@@ -4535,10 +4548,6 @@ msgstr "Utilisateur se présentant"
msgid "Blank vote" msgid "Blank vote"
msgstr "Vote blanc" msgstr "Vote blanc"
#: election/forms.py
msgid "This role already exists for this election"
msgstr "Ce rôle existe déjà pour cette élection"
#: election/models.py #: election/models.py
msgid "clubs" msgid "clubs"
msgstr "clubs" msgstr "clubs"
@@ -4591,6 +4600,10 @@ msgstr ""
"Un rôle de club. Remplir ce champ permet l'autocomplétion du titre et de la " "Un rôle de club. Remplir ce champ permet l'autocomplétion du titre et de la "
"description, et l'attribution automatique des rôles après les élections." "description, et l'attribution automatique des rôles après les élections."
#: election/models.py
msgid "This role already exists for this election"
msgstr "Ce rôle existe déjà pour cette élection"
#: election/models.py #: election/models.py
msgid "election list" msgid "election list"
msgstr "liste électorale" msgstr "liste électorale"
@@ -4627,19 +4640,13 @@ msgid "Polls will open "
msgstr "Les votes ouvriront " msgstr "Les votes ouvriront "
#: election/templates/election/election_detail.jinja #: election/templates/election/election_detail.jinja
msgid " at" msgid "at"
msgstr " à" msgstr "à"
#: election/templates/election/election_detail.jinja #: election/templates/election/election_detail.jinja
msgid "and will close " msgid "and will close "
msgstr "et fermeront" msgstr "et fermeront"
#: election/templates/election/election_detail.jinja
#: election/templates/election/election_list.jinja
#: forum/templates/forum/macros.jinja
msgid " at "
msgstr " à "
#: election/templates/election/election_detail.jinja #: election/templates/election/election_detail.jinja
msgid "Apply election result" msgid "Apply election result"
msgstr "Appliquer les résultats de l'élection" msgstr "Appliquer les résultats de l'élection"
@@ -4693,6 +4700,11 @@ msgstr "Nouvelle élection"
msgid "Applications open from" msgid "Applications open from"
msgstr "Candidatures ouvertes à partir du" msgstr "Candidatures ouvertes à partir du"
#: election/templates/election/election_list.jinja
#: forum/templates/forum/macros.jinja
msgid " at "
msgstr " à "
#: election/templates/election/election_list.jinja #: election/templates/election/election_list.jinja
msgid "to" msgid "to"
msgstr "au" msgstr "au"