diff --git a/apps/member/views.py b/apps/member/views.py index 82c15b99..dacfde33 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -124,7 +124,7 @@ class UserDetailView(LoginRequiredMixin, DetailView): context = super().get_context_data(**kwargs) user = context['user_object'] history_list = \ - Transaction.objects.all().filter(Q(source=user.note) | Q(destination=user.note)) + Transaction.objects.all().filter(Q(source=user.note) | Q(destination=user.note)).order_by("-id") context['history_list'] = HistoryTable(history_list) club_list = \ Membership.objects.all().filter(user=user).only("club") diff --git a/static/js/base.js b/static/js/base.js index 882ef1d8..3105764e 100644 --- a/static/js/base.js +++ b/static/js/base.js @@ -229,3 +229,42 @@ function autoCompleteNote(field_id, alias_matched_id, note_list_id, notes, notes }); }); } + +// When a validate button is clicked, we switch the validation status +function de_validate(id, validated) { + $("#validate_" + id).html("⟳ ..."); + + // Perform a PATCH request to the API in order to update the transaction + // If the user has insuffisent rights, an error message will appear + $.ajax({ + "url": "/api/note/transaction/transaction/" + id + "/", + type: "PATCH", + dataType: "json", + headers: { + "X-CSRFTOKEN": CSRF_TOKEN + }, + data: { + "resourcetype": "TemplateTransaction", + valid: !validated + }, + success: function () { + // Refresh jQuery objects + $(".validate").click(de_validate); + + refreshBalance(); + // error if this method doesn't exist. Please define it. + refreshHistory(); + }, + error: function(err) { + let msgDiv = $("#messages"); + let html = msgDiv.html(); + html += "
Une erreur est survenue lors de la validation/dévalidation " + + "de cette transaction : " + err.responseText + "
"; + msgDiv.html(html); + + refreshBalance(); + // error if this method doesn't exist. Please define it. + refreshHistory(); + } + }); +} diff --git a/static/js/consos.js b/static/js/consos.js index 7e04a845..902ffee2 100644 --- a/static/js/consos.js +++ b/static/js/consos.js @@ -177,31 +177,3 @@ function consume(source, dest, quantity, amount, reason, type, category, templat refreshBalance(); }); } - -// When a validate button is clicked, we switch the validation status -function de_validate(id, validated) { - $("#validate_" + id).html("⟳ ..."); - - // Perform a PATCH request to the API in order to update the transaction - // If the user has insuffisent rights, an error message will appear - // TODO: Add this error message - $.ajax({ - "url": "/api/note/transaction/transaction/" + id + "/", - type: "PATCH", - dataType: "json", - headers: { - "X-CSRFTOKEN": CSRF_TOKEN - }, - data: { - "resourcetype": "TemplateTransaction", - valid: !validated - }, - success: function () { - refreshHistory(); - refreshBalance(); - - // Refresh jQuery objects - $(".validate").click(de_validate); - } - }); -} diff --git a/templates/base.html b/templates/base.html index eefad7c8..e6193702 100644 --- a/templates/base.html +++ b/templates/base.html @@ -53,6 +53,13 @@ SPDX-License-Identifier: GPL-3.0-or-later {{ form.media }} {% endif %} + + {% block extracss %}{% endblock %} diff --git a/templates/member/profile_detail.html b/templates/member/profile_detail.html index e997b333..31510acf 100644 --- a/templates/member/profile_detail.html +++ b/templates/member/profile_detail.html @@ -10,7 +10,7 @@ -
+
{% trans 'name'|capfirst %}, {% trans 'first name' %}
{{ object.last_name }} {{ object.first_name }}
@@ -76,7 +76,9 @@
- {% render_table history_list %} +
+ {% render_table history_list %} +
@@ -84,3 +86,12 @@ {% endblock %} + +{% block extrajavascript %} + +{% endblock %} diff --git a/templates/note/conso_form.html b/templates/note/conso_form.html index 9bd4919c..3925241d 100644 --- a/templates/note/conso_form.html +++ b/templates/note/conso_form.html @@ -145,15 +145,6 @@ {% endblock %} -{% block extracss %} - -{% endblock %} - {% block extrajavascript %}