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;
margin: calc(var(--nf-input-size) * 1.5) auto 10px;
line-height: 1;
white-space: nowrap;
.fields-centered {
padding: 10px 10px 0;
@@ -6,67 +6,71 @@ interface Basket {
timeout: Date;
}
document.addEventListener("alpine:init", () => {
Alpine.data("etransaction", (initialData, basket: Basket) => ({
data: initialData,
isCbAvailable: Object.keys(initialData).length > 0,
isSithAvailable: true,
Alpine.data(
"etransaction",
(initialData: Record<string, string>, basket: Basket) => ({
data: initialData,
isCbAvailable: Object.keys(initialData).length > 0,
isSithAvailable: true,
init() {
const now = new Date();
const timeout = basket.timeout.getTime() - now.getTime();
if (timeout <= 0) {
// basket was already outdated at initial page load
this.timeoutBasket();
} else {
setTimeout(() => this.timeoutBasket(), timeout);
}
},
init() {
const now = new Date();
const timeout = basket.timeout.getTime() - now.getTime();
if (timeout > 0) {
// if not going inside this condition, it means that
// basket was already outdated at initial page load,
// in which case disabling buttons and displaying
// error message has been done at rendering time
setTimeout(() => this.timeoutBasket(), timeout);
}
},
/**
* Make this basket into a timeout state.
* All submission inputs are disabled, and an error message is displayed.
*/
timeoutBasket() {
this.isCbAvailable = false;
this.isSithAvailable = false;
const message = gettext("Basket expired");
/**
* Make this basket into a timeout state.
* All submission inputs are disabled, and an error message is displayed.
*/
timeoutBasket() {
this.isCbAvailable = false;
this.isSithAvailable = false;
const message = gettext("Basket expired");
const existingNotif: Notification | undefined = this.$notifications
.getAll()
.find(
(n: Notification) =>
n.tag === NotificationLevel.Error && n.message === message,
);
if (existingNotif === undefined) {
this.$notifications.error(message);
}
},
const existingNotif: Notification | undefined = this.$notifications
.getAll()
.find(
(n: Notification) =>
n.tag === NotificationLevel.Error && n.text === message,
);
if (existingNotif === undefined) {
this.$notifications.error(message);
}
},
/**
* Refresh the data used for etransaction.
*
* Note: if this is called while the basket is expired, it will be a no-op
*/
async fill() {
if (new Date() > basket.timeout) {
// refresh etransaction data only if the basket is still valid.
this.timeoutBasket();
return;
}
this.isCbAvailable = false;
const res = await etransactioninfoFetchEtransactionData({
// biome-ignore lint/style/useNamingConvention: api is in snake_case
path: { basket_id: basket.id },
});
if (res.response.ok) {
this.data = res.data;
this.isCbAvailable = true;
} else if (res.response.status === 410) {
// The basket is expired, so no payment method should be available at all.
// This shouldn't happen, because we don't send the request
// when the timeout is passed, but we are better safe than sorry
this.timeoutBasket();
}
},
}));
/**
* Refresh the data used for etransaction.
*
* Note: if this is called while the basket is expired, it will be a no-op
*/
async fill() {
if (new Date() > basket.timeout) {
// refresh etransaction data only if the basket is still valid.
this.timeoutBasket();
return;
}
this.isCbAvailable = false;
const res = await etransactioninfoFetchEtransactionData({
// biome-ignore lint/style/useNamingConvention: api is in snake_case
path: { basket_id: basket.id },
});
if (res.response.ok) {
this.data = res.data as Record<string, string>;
this.isCbAvailable = true;
} else if (res.response.status === 410) {
// The basket is expired, so no payment method should be available at all.
// This shouldn't happen, because we don't send the request
// when the timeout is passed, but we are better safe than sorry
this.timeoutBasket();
}
},
}),
);
});
@@ -28,8 +28,8 @@
<thead>
<tr>
<td>Article</td>
<td>Quantity</td>
<td>Unit price</td>
<td>{% trans %}Quantity{% endtrans %}</td>
<td>{% trans %}Unit price{% endtrans %}</td>
</tr>
</thead>
<tbody>
@@ -63,10 +63,41 @@
<div @htmx:after-request="fill">
{{ billing_infos_form }}
</div>
{% include "core/base/notifications.jinja" %}
{% endif %}
{% 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
method="post"
id="bank-payment-form"
action="{{ settings.SITH_EBOUTIC_ET_URL }}"
@submit="if (!$refs.cgvForm.reportValidity()) $event.preventDefault()"
>
<template x-for="[key, value] in Object.entries(data)" :key="key">
<input type="hidden" :name="key" :value="value">
@@ -98,7 +129,12 @@
{% elif basket.total > user.account_balance %}
<p>{% trans %}AE account payment disabled because you do not have enough money remaining.{% endtrans %}</p>
{% 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 %}
<input
{% if basket.is_expired %}
+26 -14
View File
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"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"
"Last-Translator: Maréchal <thomas.girod@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_stats.jinja
#: counter/templates/counter/last_ops.jinja
#: eboutic/templates/eboutic/eboutic_checkout.jinja
msgid "Quantity"
msgstr "Quantité"
@@ -963,7 +964,7 @@ msgstr "rôle de club membre"
msgid "Benefit"
msgstr "Bénéfice"
#: club/views.py
#: club/views.py eboutic/templates/eboutic/eboutic_checkout.jinja
msgid "Unit price"
msgstr "Prix unitaire"
@@ -4380,6 +4381,18 @@ msgstr "Solde actuel : "
msgid "Remaining account amount: "
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
msgid "Pay with credit card"
msgstr "Payer avec une carte bancaire"
@@ -4535,10 +4548,6 @@ msgstr "Utilisateur se présentant"
msgid "Blank vote"
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
msgid "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 "
"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
msgid "election list"
msgstr "liste électorale"
@@ -4627,19 +4640,13 @@ msgid "Polls will open "
msgstr "Les votes ouvriront "
#: election/templates/election/election_detail.jinja
msgid " at"
msgstr " à"
msgid "at"
msgstr "à"
#: election/templates/election/election_detail.jinja
msgid "and will close "
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
msgid "Apply election result"
msgstr "Appliquer les résultats de l'élection"
@@ -4693,6 +4700,11 @@ msgstr "Nouvelle élection"
msgid "Applications open from"
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
msgid "to"
msgstr "au"