From 23db42e448639c6f55ee82e974bb76531a96b59f Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 25 Mar 2020 13:13:01 +0100 Subject: [PATCH 1/5] Give a reason when a transaction is invalidated --- apps/note/models/transactions.py | 12 ++++++++++++ apps/note/tables.py | 29 +++++++++++++++++++++-------- static/js/base.js | 30 ++++++++++++++++++++++++++---- 3 files changed, 59 insertions(+), 12 deletions(-) diff --git a/apps/note/models/transactions.py b/apps/note/models/transactions.py index 0e40edf6..93d1071a 100644 --- a/apps/note/models/transactions.py +++ b/apps/note/models/transactions.py @@ -115,11 +115,19 @@ class Transaction(PolymorphicModel): verbose_name=_('reason'), max_length=255, ) + valid = models.BooleanField( verbose_name=_('valid'), default=True, ) + invalidity_reason = models.CharField( + verbose_name=_('invalidity reason'), + max_length=255, + default=None, + null=True, + ) + class Meta: verbose_name = _("transaction") verbose_name_plural = _("transactions") @@ -152,6 +160,10 @@ class Transaction(PolymorphicModel): self.source.balance -= to_transfer self.destination.balance += to_transfer + # When a transaction is declared valid, we ensure that the invalidity reason is null, if it was + # previously invalid + self.invalidity_reason = None + # We save first the transaction, in case of the user has no right to transfer money super().save(*args, **kwargs) diff --git a/apps/note/tables.py b/apps/note/tables.py index 20054d2c..ea7bdaa7 100644 --- a/apps/note/tables.py +++ b/apps/note/tables.py @@ -5,6 +5,7 @@ import html import django_tables2 as tables from django.db.models import F +from django.utils.html import format_html from django_tables2.utils import A from django.utils.translation import gettext_lazy as _ @@ -20,19 +21,26 @@ class HistoryTable(tables.Table): 'table table-condensed table-striped table-hover' } model = Transaction - exclude = ("id", "polymorphic_ctype", ) + exclude = ("id", "polymorphic_ctype", "invalidity_reason") template_name = 'django_tables2/bootstrap4.html' - sequence = ('...', 'type', 'total', 'valid', ) + sequence = ('...', 'type', 'total', 'valid',) orderable = False type = tables.Column() total = tables.Column() # will use Transaction.total() !! - valid = tables.Column(attrs={"td": {"id": lambda record: "validate_" + str(record.id), - "class": lambda record: str(record.valid).lower() + ' validate', - "onclick": lambda record: 'de_validate(' + str(record.id) + ', ' - + str(record.valid).lower() + ')'}}) + valid = tables.Column( + attrs={ + "td": { + "id": lambda record: "validate_" + str(record.id), + "class": lambda record: str(record.valid).lower() + ' validate', + "onclick": lambda record: 'in_validate(' + str(record.id) + ', ' + str(record.valid).lower() + ')', + "onmouseover": lambda record: 'hover_validation_btn(' + str(record.id) + ', true)', + "onmouseout": lambda record: 'hover_validation_btn(' + str(record.id) + ', false)', + } + } + ) def order_total(self, queryset, is_descending): # needed for rendering @@ -53,8 +61,13 @@ class HistoryTable(tables.Table): def render_reason(self, value): return html.unescape(value) - def render_valid(self, value): - return "✔" if value else "✖" + def render_valid(self, value, record): + val = "✔" if value else "✖" + val += "
" + return format_html(val) # function delete_button(id) provided in template file diff --git a/static/js/base.js b/static/js/base.js index f7085850..4a78e811 100644 --- a/static/js/base.js +++ b/static/js/base.js @@ -260,8 +260,29 @@ function autoCompleteNote(field_id, alias_matched_id, note_list_id, notes, notes }); } +function hover_validation_btn(id, show) { + let reason_obj = $("#invalidity_reason_" + id); + console.log(reason_obj.val()); + + if (show) { + reason_obj.show(); + reason_obj.focus(); + } + else + reason_obj.hide(); +} + // When a validate button is clicked, we switch the validation status -function de_validate(id, validated) { +function in_validate(id, validated) { + + let invalidity_reason; + let reason_obj = $("#invalidity_reason_" + id); + + if (validated) + invalidity_reason = reason_obj.val(); + else + invalidity_reason = null; + $("#validate_" + id).html("⟳ ..."); // Perform a PATCH request to the API in order to update the transaction @@ -274,12 +295,13 @@ function de_validate(id, validated) { "X-CSRFTOKEN": CSRF_TOKEN }, data: { - "resourcetype": "RecurrentTransaction", - valid: !validated + resourcetype: "RecurrentTransaction", + valid: !validated, + invalidity_reason: invalidity_reason, }, success: function () { // Refresh jQuery objects - $(".validate").click(de_validate); + $(".validate").click(in_validate); refreshBalance(); // error if this method doesn't exist. Please define it. From e5ab391236ecaebd2a656bf6e81240d072f1484b Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 25 Mar 2020 14:50:21 +0100 Subject: [PATCH 2/5] Better user interface --- apps/note/tables.py | 16 ++- locale/de/LC_MESSAGES/django.po | 243 ++++++++++++++++++++------------ locale/fr/LC_MESSAGES/django.po | 243 ++++++++++++++++++++------------ static/js/base.js | 12 -- 4 files changed, 309 insertions(+), 205 deletions(-) diff --git a/apps/note/tables.py b/apps/note/tables.py index ea7bdaa7..c02fdf32 100644 --- a/apps/note/tables.py +++ b/apps/note/tables.py @@ -35,9 +35,13 @@ class HistoryTable(tables.Table): "td": { "id": lambda record: "validate_" + str(record.id), "class": lambda record: str(record.valid).lower() + ' validate', + "data-toggle": "tooltip", + "title": lambda record: _("Click to invalidate") if record.valid else _("Click to validate"), "onclick": lambda record: 'in_validate(' + str(record.id) + ', ' + str(record.valid).lower() + ')', - "onmouseover": lambda record: 'hover_validation_btn(' + str(record.id) + ', true)', - "onmouseout": lambda record: 'hover_validation_btn(' + str(record.id) + ', false)', + "onmouseover": lambda record: '$("#invalidity_reason_' + + str(record.id) + '").show();$("#invalidity_reason_' + + str(record.id) + '").focus();', + "onmouseout": lambda record: '$("#invalidity_reason_' + str(record.id) + '").hide()', } } ) @@ -63,10 +67,12 @@ class HistoryTable(tables.Table): def render_valid(self, value, record): val = "✔" if value else "✖" - val += "
" + + " placeholder='" + html.escape(_("invalidity reason").capitalize()) + "'" \ + + " style='position: absolute; width: 15em; margin-left: -15.5em; margin-top: -2em; display: none;'>" return format_html(val) diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index e61efb2a..519cf289 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-03-16 11:53+0100\n" +"POT-Creation-Date: 2020-03-25 14:46+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -23,9 +23,9 @@ msgid "activity" msgstr "" #: apps/activity/models.py:19 apps/activity/models.py:44 -#: apps/member/models.py:61 apps/member/models.py:112 +#: apps/member/models.py:63 apps/member/models.py:114 #: apps/note/models/notes.py:188 apps/note/models/transactions.py:24 -#: apps/note/models/transactions.py:44 apps/note/models/transactions.py:202 +#: apps/note/models/transactions.py:44 apps/note/models/transactions.py:210 #: templates/member/profile_detail.html:15 msgid "name" msgstr "" @@ -47,11 +47,12 @@ msgid "activity types" msgstr "" #: apps/activity/models.py:48 apps/note/models/transactions.py:69 +#: apps/permission/models.py:91 msgid "description" msgstr "" #: apps/activity/models.py:54 apps/note/models/notes.py:164 -#: apps/note/models/transactions.py:62 apps/note/models/transactions.py:115 +#: apps/note/models/transactions.py:62 msgid "type" msgstr "" @@ -119,11 +120,11 @@ msgstr "" msgid "create" msgstr "" -#: apps/logs/models.py:61 +#: apps/logs/models.py:61 apps/note/tables.py:126 msgid "edit" msgstr "" -#: apps/logs/models.py:62 +#: apps/logs/models.py:62 apps/note/tables.py:130 msgid "delete" msgstr "" @@ -143,114 +144,114 @@ msgstr "" msgid "member" msgstr "" -#: apps/member/models.py:23 +#: apps/member/models.py:25 msgid "phone number" msgstr "" -#: apps/member/models.py:29 templates/member/profile_detail.html:28 +#: apps/member/models.py:31 templates/member/profile_detail.html:28 msgid "section" msgstr "" -#: apps/member/models.py:30 +#: apps/member/models.py:32 msgid "e.g. \"1A0\", \"9A♥\", \"SAPHIRE\"" msgstr "" -#: apps/member/models.py:36 templates/member/profile_detail.html:31 +#: apps/member/models.py:38 templates/member/profile_detail.html:31 msgid "address" msgstr "" -#: apps/member/models.py:42 +#: apps/member/models.py:44 msgid "paid" msgstr "" -#: apps/member/models.py:47 apps/member/models.py:48 +#: apps/member/models.py:49 apps/member/models.py:50 msgid "user profile" msgstr "" -#: apps/member/models.py:66 +#: apps/member/models.py:68 msgid "email" msgstr "" -#: apps/member/models.py:71 +#: apps/member/models.py:73 msgid "membership fee" msgstr "" -#: apps/member/models.py:75 +#: apps/member/models.py:77 msgid "membership duration" msgstr "" -#: apps/member/models.py:76 +#: apps/member/models.py:78 msgid "The longest time a membership can last (NULL = infinite)." msgstr "" -#: apps/member/models.py:81 +#: apps/member/models.py:83 msgid "membership start" msgstr "" -#: apps/member/models.py:82 +#: apps/member/models.py:84 msgid "How long after January 1st the members can renew their membership." msgstr "" -#: apps/member/models.py:87 +#: apps/member/models.py:89 msgid "membership end" msgstr "" -#: apps/member/models.py:88 +#: apps/member/models.py:90 msgid "" "How long the membership can last after January 1st of the next year after " "members can renew their membership." msgstr "" -#: apps/member/models.py:94 apps/note/models/notes.py:139 +#: apps/member/models.py:96 apps/note/models/notes.py:139 msgid "club" msgstr "" -#: apps/member/models.py:95 +#: apps/member/models.py:97 msgid "clubs" msgstr "" -#: apps/member/models.py:118 +#: apps/member/models.py:120 apps/permission/models.py:276 msgid "role" msgstr "" -#: apps/member/models.py:119 +#: apps/member/models.py:121 msgid "roles" msgstr "" -#: apps/member/models.py:143 +#: apps/member/models.py:145 msgid "membership starts on" msgstr "" -#: apps/member/models.py:146 +#: apps/member/models.py:148 msgid "membership ends on" msgstr "" -#: apps/member/models.py:150 +#: apps/member/models.py:152 msgid "fee" msgstr "" -#: apps/member/models.py:154 +#: apps/member/models.py:162 msgid "membership" msgstr "" -#: apps/member/models.py:155 +#: apps/member/models.py:163 msgid "memberships" msgstr "" -#: apps/member/views.py:69 templates/member/profile_detail.html:46 +#: apps/member/views.py:80 templates/member/profile_detail.html:46 msgid "Update Profile" msgstr "" -#: apps/member/views.py:82 +#: apps/member/views.py:93 msgid "An alias with a similar name already exists." msgstr "" -#: apps/member/views.py:132 +#: apps/member/views.py:146 #, python-format msgid "Account #%(id)s: %(username)s" msgstr "" -#: apps/member/views.py:202 +#: apps/member/views.py:216 msgid "Alias successfully deleted" msgstr "" @@ -415,84 +416,114 @@ msgstr "" msgid "quantity" msgstr "" -#: apps/note/models/transactions.py:117 templates/note/transaction_form.html:15 -msgid "Gift" -msgstr "" - -#: apps/note/models/transactions.py:118 templates/base.html:90 -#: templates/note/transaction_form.html:19 -#: templates/note/transaction_form.html:126 -msgid "Transfer" -msgstr "" - -#: apps/note/models/transactions.py:119 -msgid "Template" -msgstr "" - -#: apps/note/models/transactions.py:120 templates/note/transaction_form.html:23 -msgid "Credit" -msgstr "" - -#: apps/note/models/transactions.py:121 templates/note/transaction_form.html:27 -msgid "Debit" -msgstr "" - -#: apps/note/models/transactions.py:122 apps/note/models/transactions.py:230 -msgid "membership transaction" -msgstr "" - -#: apps/note/models/transactions.py:129 +#: apps/note/models/transactions.py:115 msgid "reason" msgstr "" -#: apps/note/models/transactions.py:133 +#: apps/note/models/transactions.py:120 msgid "valid" msgstr "" -#: apps/note/models/transactions.py:138 +#: apps/note/models/transactions.py:125 apps/note/tables.py:74 +msgid "invalidity reason" +msgstr "" + +#: apps/note/models/transactions.py:132 msgid "transaction" msgstr "" -#: apps/note/models/transactions.py:139 +#: apps/note/models/transactions.py:133 msgid "transactions" msgstr "" -#: apps/note/models/transactions.py:207 +#: apps/note/models/transactions.py:180 templates/base.html:83 +#: templates/note/transaction_form.html:19 +#: templates/note/transaction_form.html:145 +msgid "Transfer" +msgstr "" + +#: apps/note/models/transactions.py:200 +msgid "Template" +msgstr "" + +#: apps/note/models/transactions.py:215 msgid "first_name" msgstr "" -#: apps/note/models/transactions.py:212 +#: apps/note/models/transactions.py:220 msgid "bank" msgstr "" -#: apps/note/models/transactions.py:231 +#: apps/note/models/transactions.py:226 templates/note/transaction_form.html:24 +msgid "Credit" +msgstr "" + +#: apps/note/models/transactions.py:226 templates/note/transaction_form.html:28 +msgid "Debit" +msgstr "" + +#: apps/note/models/transactions.py:242 apps/note/models/transactions.py:247 +msgid "membership transaction" +msgstr "" + +#: apps/note/models/transactions.py:243 msgid "membership transactions" msgstr "" -#: apps/note/views.py:31 +#: apps/note/tables.py:39 +msgid "Click to invalidate" +msgstr "" + +#: apps/note/tables.py:39 +msgid "Click to validate" +msgstr "" + +#: apps/note/tables.py:72 +msgid "No reason specified" +msgstr "" + +#: apps/note/views.py:42 msgid "Transfer money" msgstr "" -#: apps/note/views.py:132 templates/base.html:78 +#: apps/note/views.py:158 templates/base.html:79 msgid "Consumptions" msgstr "" -#: note_kfet/settings/__init__.py:61 +#: apps/permission/models.py:70 apps/permission/models.py:263 +#, python-brace-format +msgid "Can {type} {model}.{field} in {query}" +msgstr "" + +#: apps/permission/models.py:72 apps/permission/models.py:265 +#, python-brace-format +msgid "Can {type} {model} in {query}" +msgstr "" + +#: apps/permission/models.py:85 +msgid "rank" +msgstr "" + +#: apps/permission/models.py:148 +msgid "Specifying field applies only to view and change permission types." +msgstr "" + +#: note_kfet/settings/__init__.py:63 msgid "" "The Central Authentication Service grants you access to most of our websites " "by authenticating only once, so you don't need to type your credentials " "again unless your session expires or you logout." msgstr "" -#: note_kfet/settings/base.py:156 +#: note_kfet/settings/base.py:151 msgid "German" msgstr "" -#: note_kfet/settings/base.py:157 +#: note_kfet/settings/base.py:152 msgid "English" msgstr "" -#: note_kfet/settings/base.py:158 +#: note_kfet/settings/base.py:153 msgid "French" msgstr "" @@ -500,18 +531,14 @@ msgstr "" msgid "The ENS Paris-Saclay BDE note." msgstr "" -#: templates/base.html:81 +#: templates/base.html:87 msgid "Clubs" msgstr "" -#: templates/base.html:84 +#: templates/base.html:92 msgid "Activities" msgstr "" -#: templates/base.html:87 -msgid "Buttons" -msgstr "" - #: templates/cas_server/base.html:7 msgid "Central Authentication Service" msgstr "" @@ -653,7 +680,7 @@ msgstr "" msgid "Sign up" msgstr "" -#: templates/note/conso_form.html:28 templates/note/transaction_form.html:38 +#: templates/note/conso_form.html:28 templates/note/transaction_form.html:50 msgid "Select emitters" msgstr "" @@ -681,49 +708,53 @@ msgstr "" msgid "Double consumptions" msgstr "" -#: templates/note/conso_form.html:141 +#: templates/note/conso_form.html:141 templates/note/transaction_form.html:152 msgid "Recent transactions history" msgstr "" -#: templates/note/transaction_form.html:55 +#: templates/note/transaction_form.html:15 +msgid "Gift" +msgstr "" + +#: templates/note/transaction_form.html:68 msgid "External payment" msgstr "" -#: templates/note/transaction_form.html:63 +#: templates/note/transaction_form.html:76 msgid "Transfer type" msgstr "" -#: templates/note/transaction_form.html:73 +#: templates/note/transaction_form.html:86 msgid "Name" msgstr "" -#: templates/note/transaction_form.html:79 +#: templates/note/transaction_form.html:92 msgid "First name" msgstr "" -#: templates/note/transaction_form.html:85 +#: templates/note/transaction_form.html:98 msgid "Bank" msgstr "" -#: templates/note/transaction_form.html:97 -#: templates/note/transaction_form.html:179 -#: templates/note/transaction_form.html:186 +#: templates/note/transaction_form.html:111 +#: templates/note/transaction_form.html:169 +#: templates/note/transaction_form.html:176 msgid "Select receivers" msgstr "" -#: templates/note/transaction_form.html:114 +#: templates/note/transaction_form.html:128 msgid "Amount" msgstr "" -#: templates/note/transaction_form.html:119 +#: templates/note/transaction_form.html:138 msgid "Reason" msgstr "" -#: templates/note/transaction_form.html:193 +#: templates/note/transaction_form.html:183 msgid "Credit note" msgstr "" -#: templates/note/transaction_form.html:200 +#: templates/note/transaction_form.html:190 msgid "Debit note" msgstr "" @@ -731,6 +762,22 @@ msgstr "" msgid "Buttons list" msgstr "" +#: templates/note/transactiontemplate_list.html:9 +msgid "search button" +msgstr "" + +#: templates/note/transactiontemplate_list.html:20 +msgid "buttons listing " +msgstr "" + +#: templates/note/transactiontemplate_list.html:71 +msgid "button successfully deleted " +msgstr "" + +#: templates/note/transactiontemplate_list.html:75 +msgid "Unable to delete button " +msgstr "" + #: templates/registration/logged_out.html:8 msgid "Thanks for spending some quality time with the Web site today." msgstr "" @@ -740,7 +787,7 @@ msgid "Log in again" msgstr "" #: templates/registration/login.html:7 templates/registration/login.html:8 -#: templates/registration/login.html:26 +#: templates/registration/login.html:28 #: templates/registration/password_reset_complete.html:10 msgid "Log in" msgstr "" @@ -752,7 +799,15 @@ msgid "" "page. Would you like to login to a different account?" msgstr "" -#: templates/registration/login.html:27 +#: templates/registration/login.html:22 +msgid "You can also register via the central authentification server " +msgstr "" + +#: templates/registration/login.html:23 +msgid "using this link " +msgstr "" + +#: templates/registration/login.html:29 msgid "Forgotten your password or username?" msgstr "" diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 5e6e9470..d07c4f21 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -3,7 +3,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-03-16 11:53+0100\n" +"POT-Creation-Date: 2020-03-25 14:46+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,9 +18,9 @@ msgid "activity" msgstr "activité" #: apps/activity/models.py:19 apps/activity/models.py:44 -#: apps/member/models.py:61 apps/member/models.py:112 +#: apps/member/models.py:63 apps/member/models.py:114 #: apps/note/models/notes.py:188 apps/note/models/transactions.py:24 -#: apps/note/models/transactions.py:44 apps/note/models/transactions.py:202 +#: apps/note/models/transactions.py:44 apps/note/models/transactions.py:210 #: templates/member/profile_detail.html:15 msgid "name" msgstr "nom" @@ -42,11 +42,12 @@ msgid "activity types" msgstr "types d'activité" #: apps/activity/models.py:48 apps/note/models/transactions.py:69 +#: apps/permission/models.py:91 msgid "description" msgstr "description" #: apps/activity/models.py:54 apps/note/models/notes.py:164 -#: apps/note/models/transactions.py:62 apps/note/models/transactions.py:115 +#: apps/note/models/transactions.py:62 msgid "type" msgstr "type" @@ -114,11 +115,11 @@ msgstr "Nouvelles données" msgid "create" msgstr "Créer" -#: apps/logs/models.py:61 +#: apps/logs/models.py:61 apps/note/tables.py:126 msgid "edit" msgstr "Modifier" -#: apps/logs/models.py:62 +#: apps/logs/models.py:62 apps/note/tables.py:130 msgid "delete" msgstr "Supprimer" @@ -138,61 +139,61 @@ msgstr "Les logs ne peuvent pas être détruits." msgid "member" msgstr "adhérent" -#: apps/member/models.py:23 +#: apps/member/models.py:25 msgid "phone number" msgstr "numéro de téléphone" -#: apps/member/models.py:29 templates/member/profile_detail.html:28 +#: apps/member/models.py:31 templates/member/profile_detail.html:28 msgid "section" msgstr "section" -#: apps/member/models.py:30 +#: apps/member/models.py:32 msgid "e.g. \"1A0\", \"9A♥\", \"SAPHIRE\"" msgstr "e.g. \"1A0\", \"9A♥\", \"SAPHIRE\"" -#: apps/member/models.py:36 templates/member/profile_detail.html:31 +#: apps/member/models.py:38 templates/member/profile_detail.html:31 msgid "address" msgstr "adresse" -#: apps/member/models.py:42 +#: apps/member/models.py:44 msgid "paid" msgstr "payé" -#: apps/member/models.py:47 apps/member/models.py:48 +#: apps/member/models.py:49 apps/member/models.py:50 msgid "user profile" msgstr "profil utilisateur" -#: apps/member/models.py:66 +#: apps/member/models.py:68 msgid "email" msgstr "courriel" -#: apps/member/models.py:71 +#: apps/member/models.py:73 msgid "membership fee" msgstr "cotisation pour adhérer" -#: apps/member/models.py:75 +#: apps/member/models.py:77 msgid "membership duration" msgstr "durée de l'adhésion" -#: apps/member/models.py:76 +#: apps/member/models.py:78 msgid "The longest time a membership can last (NULL = infinite)." msgstr "La durée maximale d'une adhésion (NULL = infinie)." -#: apps/member/models.py:81 +#: apps/member/models.py:83 msgid "membership start" msgstr "début de l'adhésion" -#: apps/member/models.py:82 +#: apps/member/models.py:84 msgid "How long after January 1st the members can renew their membership." msgstr "" "Combien de temps après le 1er Janvier les adhérents peuvent renouveler leur " "adhésion." -#: apps/member/models.py:87 +#: apps/member/models.py:89 msgid "membership end" msgstr "fin de l'adhésion" -#: apps/member/models.py:88 +#: apps/member/models.py:90 msgid "" "How long the membership can last after January 1st of the next year after " "members can renew their membership." @@ -200,56 +201,56 @@ msgstr "" "Combien de temps l'adhésion peut durer après le 1er Janvier de l'année " "suivante avant que les adhérents peuvent renouveler leur adhésion." -#: apps/member/models.py:94 apps/note/models/notes.py:139 +#: apps/member/models.py:96 apps/note/models/notes.py:139 msgid "club" msgstr "club" -#: apps/member/models.py:95 +#: apps/member/models.py:97 msgid "clubs" msgstr "clubs" -#: apps/member/models.py:118 +#: apps/member/models.py:120 apps/permission/models.py:276 msgid "role" msgstr "rôle" -#: apps/member/models.py:119 +#: apps/member/models.py:121 msgid "roles" msgstr "rôles" -#: apps/member/models.py:143 +#: apps/member/models.py:145 msgid "membership starts on" msgstr "l'adhésion commence le" -#: apps/member/models.py:146 +#: apps/member/models.py:148 msgid "membership ends on" msgstr "l'adhésion finie le" -#: apps/member/models.py:150 +#: apps/member/models.py:152 msgid "fee" msgstr "cotisation" -#: apps/member/models.py:154 +#: apps/member/models.py:162 msgid "membership" msgstr "adhésion" -#: apps/member/models.py:155 +#: apps/member/models.py:163 msgid "memberships" msgstr "adhésions" -#: apps/member/views.py:69 templates/member/profile_detail.html:46 +#: apps/member/views.py:80 templates/member/profile_detail.html:46 msgid "Update Profile" msgstr "Modifier le profil" -#: apps/member/views.py:82 +#: apps/member/views.py:93 msgid "An alias with a similar name already exists." msgstr "Un alias avec un nom similaire existe déjà." -#: apps/member/views.py:132 +#: apps/member/views.py:146 #, python-format msgid "Account #%(id)s: %(username)s" msgstr "Compte n°%(id)s : %(username)s" -#: apps/member/views.py:202 +#: apps/member/views.py:216 msgid "Alias successfully deleted" msgstr "L'alias a bien été supprimé" @@ -415,84 +416,114 @@ msgstr "modèles de transaction" msgid "quantity" msgstr "quantité" -#: apps/note/models/transactions.py:117 templates/note/transaction_form.html:15 -msgid "Gift" -msgstr "Don" - -#: apps/note/models/transactions.py:118 templates/base.html:90 -#: templates/note/transaction_form.html:19 -#: templates/note/transaction_form.html:126 -msgid "Transfer" -msgstr "Virement" - -#: apps/note/models/transactions.py:119 -msgid "Template" -msgstr "Bouton" - -#: apps/note/models/transactions.py:120 templates/note/transaction_form.html:23 -msgid "Credit" -msgstr "Crédit" - -#: apps/note/models/transactions.py:121 templates/note/transaction_form.html:27 -msgid "Debit" -msgstr "Retrait" - -#: apps/note/models/transactions.py:122 apps/note/models/transactions.py:230 -msgid "membership transaction" -msgstr "transaction d'adhésion" - -#: apps/note/models/transactions.py:129 +#: apps/note/models/transactions.py:115 msgid "reason" msgstr "raison" -#: apps/note/models/transactions.py:133 +#: apps/note/models/transactions.py:120 msgid "valid" msgstr "valide" -#: apps/note/models/transactions.py:138 +#: apps/note/models/transactions.py:125 apps/note/tables.py:74 +msgid "invalidity reason" +msgstr "Motif d'invalidité" + +#: apps/note/models/transactions.py:132 msgid "transaction" msgstr "transaction" -#: apps/note/models/transactions.py:139 +#: apps/note/models/transactions.py:133 msgid "transactions" msgstr "transactions" -#: apps/note/models/transactions.py:207 +#: apps/note/models/transactions.py:180 templates/base.html:83 +#: templates/note/transaction_form.html:19 +#: templates/note/transaction_form.html:145 +msgid "Transfer" +msgstr "Virement" + +#: apps/note/models/transactions.py:200 +msgid "Template" +msgstr "Bouton" + +#: apps/note/models/transactions.py:215 msgid "first_name" msgstr "Prénom" -#: apps/note/models/transactions.py:212 +#: apps/note/models/transactions.py:220 msgid "bank" msgstr "Banque" -#: apps/note/models/transactions.py:231 +#: apps/note/models/transactions.py:226 templates/note/transaction_form.html:24 +msgid "Credit" +msgstr "Crédit" + +#: apps/note/models/transactions.py:226 templates/note/transaction_form.html:28 +msgid "Debit" +msgstr "Retrait" + +#: apps/note/models/transactions.py:242 apps/note/models/transactions.py:247 +msgid "membership transaction" +msgstr "transaction d'adhésion" + +#: apps/note/models/transactions.py:243 msgid "membership transactions" msgstr "transactions d'adhésion" -#: apps/note/views.py:31 +#: apps/note/tables.py:39 +msgid "Click to invalidate" +msgstr "Cliquez pour dévalider" + +#: apps/note/tables.py:39 +msgid "Click to validate" +msgstr "Cliquez pour valider" + +#: apps/note/tables.py:72 +msgid "No reason specified" +msgstr "Pas de motif spécifié" + +#: apps/note/views.py:42 msgid "Transfer money" msgstr "Transferts d'argent" -#: apps/note/views.py:132 templates/base.html:78 +#: apps/note/views.py:158 templates/base.html:79 msgid "Consumptions" msgstr "Consommations" -#: note_kfet/settings/__init__.py:61 +#: apps/permission/models.py:70 apps/permission/models.py:263 +#, python-brace-format +msgid "Can {type} {model}.{field} in {query}" +msgstr "" + +#: apps/permission/models.py:72 apps/permission/models.py:265 +#, python-brace-format +msgid "Can {type} {model} in {query}" +msgstr "" + +#: apps/permission/models.py:85 +msgid "rank" +msgstr "rang" + +#: apps/permission/models.py:148 +msgid "Specifying field applies only to view and change permission types." +msgstr "" + +#: note_kfet/settings/__init__.py:63 msgid "" "The Central Authentication Service grants you access to most of our websites " "by authenticating only once, so you don't need to type your credentials " "again unless your session expires or you logout." msgstr "" -#: note_kfet/settings/base.py:156 +#: note_kfet/settings/base.py:151 msgid "German" msgstr "" -#: note_kfet/settings/base.py:157 +#: note_kfet/settings/base.py:152 msgid "English" msgstr "" -#: note_kfet/settings/base.py:158 +#: note_kfet/settings/base.py:153 msgid "French" msgstr "" @@ -500,18 +531,14 @@ msgstr "" msgid "The ENS Paris-Saclay BDE note." msgstr "La note du BDE de l'ENS Paris-Saclay." -#: templates/base.html:81 +#: templates/base.html:87 msgid "Clubs" msgstr "Clubs" -#: templates/base.html:84 +#: templates/base.html:92 msgid "Activities" msgstr "Activités" -#: templates/base.html:87 -msgid "Buttons" -msgstr "Boutons" - #: templates/cas_server/base.html:7 msgid "Central Authentication Service" msgstr "" @@ -655,7 +682,7 @@ msgstr "Sauvegarder les changements" msgid "Sign up" msgstr "Inscription" -#: templates/note/conso_form.html:28 templates/note/transaction_form.html:38 +#: templates/note/conso_form.html:28 templates/note/transaction_form.html:50 msgid "Select emitters" msgstr "Sélection des émetteurs" @@ -683,49 +710,53 @@ msgstr "Consos simples" msgid "Double consumptions" msgstr "Consos doubles" -#: templates/note/conso_form.html:141 +#: templates/note/conso_form.html:141 templates/note/transaction_form.html:152 msgid "Recent transactions history" msgstr "Historique des transactions récentes" -#: templates/note/transaction_form.html:55 +#: templates/note/transaction_form.html:15 +msgid "Gift" +msgstr "Don" + +#: templates/note/transaction_form.html:68 msgid "External payment" msgstr "Paiement extérieur" -#: templates/note/transaction_form.html:63 +#: templates/note/transaction_form.html:76 msgid "Transfer type" msgstr "Type de transfert" -#: templates/note/transaction_form.html:73 +#: templates/note/transaction_form.html:86 msgid "Name" msgstr "Nom" -#: templates/note/transaction_form.html:79 +#: templates/note/transaction_form.html:92 msgid "First name" msgstr "Prénom" -#: templates/note/transaction_form.html:85 +#: templates/note/transaction_form.html:98 msgid "Bank" msgstr "Banque" -#: templates/note/transaction_form.html:97 -#: templates/note/transaction_form.html:179 -#: templates/note/transaction_form.html:186 +#: templates/note/transaction_form.html:111 +#: templates/note/transaction_form.html:169 +#: templates/note/transaction_form.html:176 msgid "Select receivers" msgstr "Sélection des destinataires" -#: templates/note/transaction_form.html:114 +#: templates/note/transaction_form.html:128 msgid "Amount" msgstr "Montant" -#: templates/note/transaction_form.html:119 +#: templates/note/transaction_form.html:138 msgid "Reason" msgstr "Raison" -#: templates/note/transaction_form.html:193 +#: templates/note/transaction_form.html:183 msgid "Credit note" msgstr "Note à créditer" -#: templates/note/transaction_form.html:200 +#: templates/note/transaction_form.html:190 msgid "Debit note" msgstr "Note à débiter" @@ -733,6 +764,22 @@ msgstr "Note à débiter" msgid "Buttons list" msgstr "Liste des boutons" +#: templates/note/transactiontemplate_list.html:9 +msgid "search button" +msgstr "Chercher un bouton" + +#: templates/note/transactiontemplate_list.html:20 +msgid "buttons listing " +msgstr "Liste des boutons" + +#: templates/note/transactiontemplate_list.html:71 +msgid "button successfully deleted " +msgstr "Le bouton a bien été supprimé" + +#: templates/note/transactiontemplate_list.html:75 +msgid "Unable to delete button " +msgstr "Impossible de supprimer le bouton " + #: templates/registration/logged_out.html:8 msgid "Thanks for spending some quality time with the Web site today." msgstr "" @@ -742,7 +789,7 @@ msgid "Log in again" msgstr "" #: templates/registration/login.html:7 templates/registration/login.html:8 -#: templates/registration/login.html:26 +#: templates/registration/login.html:28 #: templates/registration/password_reset_complete.html:10 msgid "Log in" msgstr "" @@ -754,7 +801,15 @@ msgid "" "page. Would you like to login to a different account?" msgstr "" -#: templates/registration/login.html:27 +#: templates/registration/login.html:22 +msgid "You can also register via the central authentification server " +msgstr "" + +#: templates/registration/login.html:23 +msgid "using this link " +msgstr "" + +#: templates/registration/login.html:29 msgid "Forgotten your password or username?" msgstr "" diff --git a/static/js/base.js b/static/js/base.js index 4a78e811..81f9f323 100644 --- a/static/js/base.js +++ b/static/js/base.js @@ -260,18 +260,6 @@ function autoCompleteNote(field_id, alias_matched_id, note_list_id, notes, notes }); } -function hover_validation_btn(id, show) { - let reason_obj = $("#invalidity_reason_" + id); - console.log(reason_obj.val()); - - if (show) { - reason_obj.show(); - reason_obj.focus(); - } - else - reason_obj.hide(); -} - // When a validate button is clicked, we switch the validation status function in_validate(id, validated) { From bc3fdbe7a711bc607bc1288bb2fb372f7927ea98 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 25 Mar 2020 14:54:26 +0100 Subject: [PATCH 3/5] Add docstring --- apps/note/tables.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/note/tables.py b/apps/note/tables.py index c02fdf32..328f620a 100644 --- a/apps/note/tables.py +++ b/apps/note/tables.py @@ -66,6 +66,9 @@ class HistoryTable(tables.Table): return html.unescape(value) def render_valid(self, value, record): + """ + When the validation status is hovered, an input field is displayed to let the user specify an invalidity reason + """ val = "✔" if value else "✖" val += " Date: Wed, 25 Mar 2020 15:27:38 +0100 Subject: [PATCH 4/5] When a transaction can't becreated because the user don't have the permission to take too much money, then we create an invalid transaction --- apps/permission/fixtures/initial.json | 4 +- static/js/consos.js | 24 ++++++++-- static/js/transfer.js | 66 +++++++++++++++++++++------ 3 files changed, 76 insertions(+), 18 deletions(-) diff --git a/apps/permission/fixtures/initial.json b/apps/permission/fixtures/initial.json index 4c7de16d..43d39a36 100644 --- a/apps/permission/fixtures/initial.json +++ b/apps/permission/fixtures/initial.json @@ -327,7 +327,7 @@ "note", "transaction" ], - "query": "[\"AND\", {\"source\": [\"user\", \"note\"]}, {\"amount__lte\": [\"user\", \"note\", \"balance\"]}]", + "query": "[\"AND\", {\"source\": [\"user\", \"note\"]}, [\"OR\", {\"amount__lte\": [\"user\", \"note\", \"balance\"]}, {\"valid\": false}]]", "type": "add", "mask": 1, "field": "", @@ -387,7 +387,7 @@ "note", "recurrenttransaction" ], - "query": "[\"AND\", {\"destination\": [\"club\", \"note\"]}, {\"amount__lte\": {\"F\": [\"ADD\", [\"F\", \"source__balance\"], 5000]}}]", + "query": "[\"AND\", {\"destination\": [\"club\", \"note\"]}, [\"OR\", {\"amount__lte\": {\"F\": [\"ADD\", [\"F\", \"source__balance\"], 5000]}}, {\"valid\": false}]]", "type": "add", "mask": 2, "field": "", diff --git a/static/js/consos.js b/static/js/consos.js index 896f996c..b201e748 100644 --- a/static/js/consos.js +++ b/static/js/consos.js @@ -199,8 +199,26 @@ function consume(source, dest, quantity, amount, reason, type, category, templat "category": category, "template": template }, reset).fail(function (e) { - reset(); - - addMsg("Une erreur est survenue lors de la transaction : " + e.responseText, "danger"); + $.post("/api/note/transaction/transaction/", + { + "csrfmiddlewaretoken": CSRF_TOKEN, + "quantity": quantity, + "amount": amount, + "reason": reason, + "valid": false, + "invalidity_reason": "Solde insuffisant", + "polymorphic_ctype": type, + "resourcetype": "RecurrentTransaction", + "source": source, + "destination": dest, + "category": category, + "template": template + }).done(function() { + reset(); + addMsg("La transaction n'a pas pu être validée pour cause de solde insuffisant.", "danger"); + }).fail(function () { + reset(); + addMsg("Une erreur est survenue lors de la transaction : " + e.responseText, "danger"); + }); }); } diff --git a/static/js/transfer.js b/static/js/transfer.js index c615f932..cfa4f1f9 100644 --- a/static/js/transfer.js +++ b/static/js/transfer.js @@ -73,18 +73,38 @@ $("#transfer").click(function() { "resourcetype": "Transaction", "source": user_id, "destination": dest.id - }, function () { + }).done(function () { addMsg("Le transfert de " + pretty_money(dest.quantity * 100 * $("#amount").val()) + " de votre note " + " vers la note " + dest.name + " a été fait avec succès !", "success"); reset(); - }).fail(function (err) { - addMsg("Le transfert de " - + pretty_money(dest.quantity * 100 * $("#amount").val()) + " de votre note " - + " vers la note " + dest.name + " a échoué : " + err.responseText, "danger"); + }).fail(function () { + $.post("/api/note/transaction/transaction/", + { + "csrfmiddlewaretoken": CSRF_TOKEN, + "quantity": dest.quantity, + "amount": 100 * $("#amount").val(), + "reason": $("#reason").val(), + "valid": false, + "invalidity_reason": "Solde insuffisant", + "polymorphic_ctype": TRANSFER_POLYMORPHIC_CTYPE, + "resourcetype": "Transaction", + "source": user_id, + "destination": dest.id + }).done(function () { + addMsg("Le transfert de " + + pretty_money(dest.quantity * 100 * $("#amount").val()) + " de votre note " + + " vers la note " + dest.name + " a échoué : Solde insuffisant", "danger"); - reset(); + reset(); + }).fail(function (err) { + addMsg("Le transfert de " + + pretty_money(dest.quantity * 100 * $("#amount").val()) + " de votre note " + + " vers la note " + dest.name + " a échoué : " + err.responseText, "danger"); + + reset(); + }); }); }); } @@ -102,18 +122,38 @@ $("#transfer").click(function() { "resourcetype": "Transaction", "source": source.id, "destination": dest.id - }, function () { + }).done(function () { addMsg("Le transfert de " + pretty_money(source.quantity * dest.quantity * 100 * $("#amount").val()) + " de la note " + source.name + " vers la note " + dest.name + " a été fait avec succès !", "success"); reset(); }).fail(function (err) { - addMsg("Le transfert de " - + pretty_money(source.quantity * dest.quantity * 100 * $("#amount").val()) + " de la note " + source.name - + " vers la note " + dest.name + " a échoué : " + err.responseText, "danger"); + $.post("/api/note/transaction/transaction/", + { + "csrfmiddlewaretoken": CSRF_TOKEN, + "quantity": source.quantity * dest.quantity, + "amount": 100 * $("#amount").val(), + "reason": $("#reason").val(), + "valid": false, + "invalidity_reason": "Solde insuffisant", + "polymorphic_ctype": TRANSFER_POLYMORPHIC_CTYPE, + "resourcetype": "Transaction", + "source": source.id, + "destination": dest.id + }).done(function () { + addMsg("Le transfert de " + + pretty_money(source.quantity * dest.quantity * 100 * $("#amount").val()) + " de la note " + source.name + + " vers la note " + dest.name + " a échoué : Solde insuffisant", "danger"); - reset(); + reset(); + }).fail(function (err) { + addMsg("Le transfert de " + + pretty_money(source.quantity * dest.quantity * 100 * $("#amount").val()) + " de la note " + source.name + + " vers la note " + dest.name + " a échoué : " + err.responseText, "danger"); + + reset(); + }); }); }); }); @@ -150,11 +190,11 @@ $("#transfer").click(function() { "last_name": $("#last_name").val(), "first_name": $("#first_name").val(), "bank": $("#bank").val() - }, function () { + }).done(function () { addMsg("Le crédit/retrait a bien été effectué !", "success"); reset(); }).fail(function (err) { - addMsg("Le crédit/transfert a échoué : " + err.responseText, "danger"); + addMsg("Le crédit/retrait a échoué : " + err.responseText, "danger"); reset(); }); } From 41aa6964d2a1ff411cd36b469f322c708a7fe437 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 26 Mar 2020 14:45:48 +0100 Subject: [PATCH 5/5] Store used aliases in transactions --- apps/note/models/transactions.py | 22 ++++++++++ apps/note/tables.py | 20 ++++++++- locale/de/LC_MESSAGES/django.po | 73 +++++++++++++++++--------------- locale/fr/LC_MESSAGES/django.po | 73 +++++++++++++++++--------------- static/js/consos.js | 7 ++- static/js/transfer.js | 16 +++++-- 6 files changed, 136 insertions(+), 75 deletions(-) diff --git a/apps/note/models/transactions.py b/apps/note/models/transactions.py index 93d1071a..c6b8baa6 100644 --- a/apps/note/models/transactions.py +++ b/apps/note/models/transactions.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later from django.db import models +from django.db.models import F from django.urls import reverse from django.utils import timezone from django.utils.translation import gettext_lazy as _ @@ -93,12 +94,26 @@ class Transaction(PolymorphicModel): related_name='+', verbose_name=_('source'), ) + + source_alias = models.CharField( + max_length=255, + default="", # Will be remplaced by the name of the note on save + verbose_name=_('used alias'), + ) + destination = models.ForeignKey( Note, on_delete=models.PROTECT, related_name='+', verbose_name=_('destination'), ) + + destination_alias = models.CharField( + max_length=255, + default="", # Will be remplaced by the name of the note on save + verbose_name=_('used alias'), + ) + created_at = models.DateTimeField( verbose_name=_('created at'), default=timezone.now, @@ -142,6 +157,13 @@ class Transaction(PolymorphicModel): When saving, also transfer money between two notes """ + # If the aliases are not entered, we assume that the used alias is the name of the note + if not self.source_alias: + self.source_alias = str(self.source) + + if not self.destination_alias: + self.destination_alias = str(self.destination) + if self.source.pk == self.destination.pk: # When source == destination, no money is transfered super().save(*args, **kwargs) diff --git a/apps/note/tables.py b/apps/note/tables.py index 328f620a..4b57cfa2 100644 --- a/apps/note/tables.py +++ b/apps/note/tables.py @@ -21,11 +21,29 @@ class HistoryTable(tables.Table): 'table table-condensed table-striped table-hover' } model = Transaction - exclude = ("id", "polymorphic_ctype", "invalidity_reason") + exclude = ("id", "polymorphic_ctype", "invalidity_reason", "source_alias", "destination_alias",) template_name = 'django_tables2/bootstrap4.html' sequence = ('...', 'type', 'total', 'valid',) orderable = False + source = tables.Column( + attrs={ + "td": { + "data-toggle": "tooltip", + "title": lambda record: _("used alias").capitalize() + " : " + record.source_alias, + } + } + ) + + destination = tables.Column( + attrs={ + "td": { + "data-toggle": "tooltip", + "title": lambda record: _("used alias").capitalize() + " : " + record.destination_alias, + } + } + ) + type = tables.Column() total = tables.Column() # will use Transaction.total() !! diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index 519cf289..bc1a0d03 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-03-25 14:46+0100\n" +"POT-Creation-Date: 2020-03-26 14:40+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -24,8 +24,8 @@ msgstr "" #: apps/activity/models.py:19 apps/activity/models.py:44 #: apps/member/models.py:63 apps/member/models.py:114 -#: apps/note/models/notes.py:188 apps/note/models/transactions.py:24 -#: apps/note/models/transactions.py:44 apps/note/models/transactions.py:210 +#: apps/note/models/notes.py:188 apps/note/models/transactions.py:25 +#: apps/note/models/transactions.py:45 apps/note/models/transactions.py:232 #: templates/member/profile_detail.html:15 msgid "name" msgstr "" @@ -46,13 +46,13 @@ msgstr "" msgid "activity types" msgstr "" -#: apps/activity/models.py:48 apps/note/models/transactions.py:69 +#: apps/activity/models.py:48 apps/note/models/transactions.py:70 #: apps/permission/models.py:91 msgid "description" msgstr "" #: apps/activity/models.py:54 apps/note/models/notes.py:164 -#: apps/note/models/transactions.py:62 +#: apps/note/models/transactions.py:63 msgid "type" msgstr "" @@ -120,11 +120,11 @@ msgstr "" msgid "create" msgstr "" -#: apps/logs/models.py:61 apps/note/tables.py:126 +#: apps/logs/models.py:61 apps/note/tables.py:147 msgid "edit" msgstr "" -#: apps/logs/models.py:62 apps/note/tables.py:130 +#: apps/logs/models.py:62 apps/note/tables.py:151 msgid "delete" msgstr "" @@ -255,12 +255,12 @@ msgstr "" msgid "Alias successfully deleted" msgstr "" -#: apps/note/admin.py:120 apps/note/models/transactions.py:94 +#: apps/note/admin.py:120 apps/note/models/transactions.py:95 msgid "source" msgstr "" #: apps/note/admin.py:128 apps/note/admin.py:156 -#: apps/note/models/transactions.py:53 apps/note/models/transactions.py:100 +#: apps/note/models/transactions.py:54 apps/note/models/transactions.py:108 msgid "destination" msgstr "" @@ -310,7 +310,7 @@ msgstr "" msgid "display image" msgstr "" -#: apps/note/models/notes.py:53 apps/note/models/transactions.py:103 +#: apps/note/models/notes.py:53 apps/note/models/transactions.py:118 msgid "created at" msgstr "" @@ -384,101 +384,106 @@ msgstr "" msgid "You can't delete your main alias." msgstr "" -#: apps/note/models/transactions.py:30 +#: apps/note/models/transactions.py:31 msgid "transaction category" msgstr "" -#: apps/note/models/transactions.py:31 +#: apps/note/models/transactions.py:32 msgid "transaction categories" msgstr "" -#: apps/note/models/transactions.py:47 +#: apps/note/models/transactions.py:48 msgid "A template with this name already exist" msgstr "" -#: apps/note/models/transactions.py:56 apps/note/models/transactions.py:111 +#: apps/note/models/transactions.py:57 apps/note/models/transactions.py:126 msgid "amount" msgstr "" -#: apps/note/models/transactions.py:57 +#: apps/note/models/transactions.py:58 msgid "in centimes" msgstr "" -#: apps/note/models/transactions.py:75 +#: apps/note/models/transactions.py:76 msgid "transaction template" msgstr "" -#: apps/note/models/transactions.py:76 +#: apps/note/models/transactions.py:77 msgid "transaction templates" msgstr "" -#: apps/note/models/transactions.py:107 +#: apps/note/models/transactions.py:101 apps/note/models/transactions.py:114 +#: apps/note/tables.py:33 apps/note/tables.py:42 +msgid "used alias" +msgstr "" + +#: apps/note/models/transactions.py:122 msgid "quantity" msgstr "" -#: apps/note/models/transactions.py:115 +#: apps/note/models/transactions.py:130 msgid "reason" msgstr "" -#: apps/note/models/transactions.py:120 +#: apps/note/models/transactions.py:135 msgid "valid" msgstr "" -#: apps/note/models/transactions.py:125 apps/note/tables.py:74 +#: apps/note/models/transactions.py:140 apps/note/tables.py:95 msgid "invalidity reason" msgstr "" -#: apps/note/models/transactions.py:132 +#: apps/note/models/transactions.py:147 msgid "transaction" msgstr "" -#: apps/note/models/transactions.py:133 +#: apps/note/models/transactions.py:148 msgid "transactions" msgstr "" -#: apps/note/models/transactions.py:180 templates/base.html:83 +#: apps/note/models/transactions.py:202 templates/base.html:83 #: templates/note/transaction_form.html:19 #: templates/note/transaction_form.html:145 msgid "Transfer" msgstr "" -#: apps/note/models/transactions.py:200 +#: apps/note/models/transactions.py:222 msgid "Template" msgstr "" -#: apps/note/models/transactions.py:215 +#: apps/note/models/transactions.py:237 msgid "first_name" msgstr "" -#: apps/note/models/transactions.py:220 +#: apps/note/models/transactions.py:242 msgid "bank" msgstr "" -#: apps/note/models/transactions.py:226 templates/note/transaction_form.html:24 +#: apps/note/models/transactions.py:248 templates/note/transaction_form.html:24 msgid "Credit" msgstr "" -#: apps/note/models/transactions.py:226 templates/note/transaction_form.html:28 +#: apps/note/models/transactions.py:248 templates/note/transaction_form.html:28 msgid "Debit" msgstr "" -#: apps/note/models/transactions.py:242 apps/note/models/transactions.py:247 +#: apps/note/models/transactions.py:264 apps/note/models/transactions.py:269 msgid "membership transaction" msgstr "" -#: apps/note/models/transactions.py:243 +#: apps/note/models/transactions.py:265 msgid "membership transactions" msgstr "" -#: apps/note/tables.py:39 +#: apps/note/tables.py:57 msgid "Click to invalidate" msgstr "" -#: apps/note/tables.py:39 +#: apps/note/tables.py:57 msgid "Click to validate" msgstr "" -#: apps/note/tables.py:72 +#: apps/note/tables.py:93 msgid "No reason specified" msgstr "" diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index d07c4f21..f7f1d1a4 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -3,7 +3,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-03-25 14:46+0100\n" +"POT-Creation-Date: 2020-03-26 14:40+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -19,8 +19,8 @@ msgstr "activité" #: apps/activity/models.py:19 apps/activity/models.py:44 #: apps/member/models.py:63 apps/member/models.py:114 -#: apps/note/models/notes.py:188 apps/note/models/transactions.py:24 -#: apps/note/models/transactions.py:44 apps/note/models/transactions.py:210 +#: apps/note/models/notes.py:188 apps/note/models/transactions.py:25 +#: apps/note/models/transactions.py:45 apps/note/models/transactions.py:232 #: templates/member/profile_detail.html:15 msgid "name" msgstr "nom" @@ -41,13 +41,13 @@ msgstr "type d'activité" msgid "activity types" msgstr "types d'activité" -#: apps/activity/models.py:48 apps/note/models/transactions.py:69 +#: apps/activity/models.py:48 apps/note/models/transactions.py:70 #: apps/permission/models.py:91 msgid "description" msgstr "description" #: apps/activity/models.py:54 apps/note/models/notes.py:164 -#: apps/note/models/transactions.py:62 +#: apps/note/models/transactions.py:63 msgid "type" msgstr "type" @@ -115,11 +115,11 @@ msgstr "Nouvelles données" msgid "create" msgstr "Créer" -#: apps/logs/models.py:61 apps/note/tables.py:126 +#: apps/logs/models.py:61 apps/note/tables.py:147 msgid "edit" msgstr "Modifier" -#: apps/logs/models.py:62 apps/note/tables.py:130 +#: apps/logs/models.py:62 apps/note/tables.py:151 msgid "delete" msgstr "Supprimer" @@ -254,12 +254,12 @@ msgstr "Compte n°%(id)s : %(username)s" msgid "Alias successfully deleted" msgstr "L'alias a bien été supprimé" -#: apps/note/admin.py:120 apps/note/models/transactions.py:94 +#: apps/note/admin.py:120 apps/note/models/transactions.py:95 msgid "source" msgstr "source" #: apps/note/admin.py:128 apps/note/admin.py:156 -#: apps/note/models/transactions.py:53 apps/note/models/transactions.py:100 +#: apps/note/models/transactions.py:54 apps/note/models/transactions.py:108 msgid "destination" msgstr "destination" @@ -310,7 +310,7 @@ msgstr "" msgid "display image" msgstr "image affichée" -#: apps/note/models/notes.py:53 apps/note/models/transactions.py:103 +#: apps/note/models/notes.py:53 apps/note/models/transactions.py:118 msgid "created at" msgstr "créée le" @@ -384,101 +384,106 @@ msgstr "Un alias avec un nom similaire existe déjà : {}" msgid "You can't delete your main alias." msgstr "Vous ne pouvez pas supprimer votre alias principal." -#: apps/note/models/transactions.py:30 +#: apps/note/models/transactions.py:31 msgid "transaction category" msgstr "catégorie de transaction" -#: apps/note/models/transactions.py:31 +#: apps/note/models/transactions.py:32 msgid "transaction categories" msgstr "catégories de transaction" -#: apps/note/models/transactions.py:47 +#: apps/note/models/transactions.py:48 msgid "A template with this name already exist" msgstr "Un modèle de transaction avec un nom similaire existe déjà." -#: apps/note/models/transactions.py:56 apps/note/models/transactions.py:111 +#: apps/note/models/transactions.py:57 apps/note/models/transactions.py:126 msgid "amount" msgstr "montant" -#: apps/note/models/transactions.py:57 +#: apps/note/models/transactions.py:58 msgid "in centimes" msgstr "en centimes" -#: apps/note/models/transactions.py:75 +#: apps/note/models/transactions.py:76 msgid "transaction template" msgstr "modèle de transaction" -#: apps/note/models/transactions.py:76 +#: apps/note/models/transactions.py:77 msgid "transaction templates" msgstr "modèles de transaction" -#: apps/note/models/transactions.py:107 +#: apps/note/models/transactions.py:101 apps/note/models/transactions.py:114 +#: apps/note/tables.py:33 apps/note/tables.py:42 +msgid "used alias" +msgstr "alias utilisé" + +#: apps/note/models/transactions.py:122 msgid "quantity" msgstr "quantité" -#: apps/note/models/transactions.py:115 +#: apps/note/models/transactions.py:130 msgid "reason" msgstr "raison" -#: apps/note/models/transactions.py:120 +#: apps/note/models/transactions.py:135 msgid "valid" msgstr "valide" -#: apps/note/models/transactions.py:125 apps/note/tables.py:74 +#: apps/note/models/transactions.py:140 apps/note/tables.py:95 msgid "invalidity reason" msgstr "Motif d'invalidité" -#: apps/note/models/transactions.py:132 +#: apps/note/models/transactions.py:147 msgid "transaction" msgstr "transaction" -#: apps/note/models/transactions.py:133 +#: apps/note/models/transactions.py:148 msgid "transactions" msgstr "transactions" -#: apps/note/models/transactions.py:180 templates/base.html:83 +#: apps/note/models/transactions.py:202 templates/base.html:83 #: templates/note/transaction_form.html:19 #: templates/note/transaction_form.html:145 msgid "Transfer" msgstr "Virement" -#: apps/note/models/transactions.py:200 +#: apps/note/models/transactions.py:222 msgid "Template" msgstr "Bouton" -#: apps/note/models/transactions.py:215 +#: apps/note/models/transactions.py:237 msgid "first_name" msgstr "Prénom" -#: apps/note/models/transactions.py:220 +#: apps/note/models/transactions.py:242 msgid "bank" msgstr "Banque" -#: apps/note/models/transactions.py:226 templates/note/transaction_form.html:24 +#: apps/note/models/transactions.py:248 templates/note/transaction_form.html:24 msgid "Credit" msgstr "Crédit" -#: apps/note/models/transactions.py:226 templates/note/transaction_form.html:28 +#: apps/note/models/transactions.py:248 templates/note/transaction_form.html:28 msgid "Debit" msgstr "Retrait" -#: apps/note/models/transactions.py:242 apps/note/models/transactions.py:247 +#: apps/note/models/transactions.py:264 apps/note/models/transactions.py:269 msgid "membership transaction" msgstr "transaction d'adhésion" -#: apps/note/models/transactions.py:243 +#: apps/note/models/transactions.py:265 msgid "membership transactions" msgstr "transactions d'adhésion" -#: apps/note/tables.py:39 +#: apps/note/tables.py:57 msgid "Click to invalidate" msgstr "Cliquez pour dévalider" -#: apps/note/tables.py:39 +#: apps/note/tables.py:57 msgid "Click to validate" msgstr "Cliquez pour valider" -#: apps/note/tables.py:72 +#: apps/note/tables.py:93 msgid "No reason specified" msgstr "Pas de motif spécifié" diff --git a/static/js/consos.js b/static/js/consos.js index b201e748..8ac2b7eb 100644 --- a/static/js/consos.js +++ b/static/js/consos.js @@ -167,7 +167,7 @@ function reset() { function consumeAll() { notes_display.forEach(function(note_display) { buttons.forEach(function(button) { - consume(note_display.id, button.dest, button.quantity * note_display.quantity, button.amount, + consume(note_display.id, note_display.name, button.dest, button.quantity * note_display.quantity, button.amount, button.name + " (" + button.category_name + ")", button.type, button.category_id, button.id); }); }); @@ -176,6 +176,7 @@ function consumeAll() { /** * Create a new transaction from a button through the API. * @param source The note that paid the item (type: int) + * @param source_alias The alias used for the source (type: str) * @param dest The note that sold the item (type: int) * @param quantity The quantity sold (type: int) * @param amount The price of one item, in cents (type: int) @@ -184,7 +185,7 @@ function consumeAll() { * @param category The category id of the button (type: int) * @param template The button id (type: int) */ -function consume(source, dest, quantity, amount, reason, type, category, template) { +function consume(source, source_alias, dest, quantity, amount, reason, type, category, template) { $.post("/api/note/transaction/transaction/", { "csrfmiddlewaretoken": CSRF_TOKEN, @@ -195,6 +196,7 @@ function consume(source, dest, quantity, amount, reason, type, category, templat "polymorphic_ctype": type, "resourcetype": "RecurrentTransaction", "source": source, + "source_alias": source_alias, "destination": dest, "category": category, "template": template @@ -210,6 +212,7 @@ function consume(source, dest, quantity, amount, reason, type, category, templat "polymorphic_ctype": type, "resourcetype": "RecurrentTransaction", "source": source, + "source_alias": source_alias, "destination": dest, "category": category, "template": template diff --git a/static/js/transfer.js b/static/js/transfer.js index cfa4f1f9..a23c6e38 100644 --- a/static/js/transfer.js +++ b/static/js/transfer.js @@ -72,7 +72,8 @@ $("#transfer").click(function() { "polymorphic_ctype": TRANSFER_POLYMORPHIC_CTYPE, "resourcetype": "Transaction", "source": user_id, - "destination": dest.id + "destination": dest.id, + "destination_alias": dest.name }).done(function () { addMsg("Le transfert de " + pretty_money(dest.quantity * 100 * $("#amount").val()) + " de votre note " @@ -91,7 +92,8 @@ $("#transfer").click(function() { "polymorphic_ctype": TRANSFER_POLYMORPHIC_CTYPE, "resourcetype": "Transaction", "source": user_id, - "destination": dest.id + "destination": dest.id, + "destination_alias": dest.name }).done(function () { addMsg("Le transfert de " + pretty_money(dest.quantity * 100 * $("#amount").val()) + " de votre note " @@ -121,7 +123,9 @@ $("#transfer").click(function() { "polymorphic_ctype": TRANSFER_POLYMORPHIC_CTYPE, "resourcetype": "Transaction", "source": source.id, - "destination": dest.id + "source_alias": source.name, + "destination": dest.id, + "destination_alias": dest.name }).done(function () { addMsg("Le transfert de " + pretty_money(source.quantity * dest.quantity * 100 * $("#amount").val()) + " de la note " + source.name @@ -140,7 +144,9 @@ $("#transfer").click(function() { "polymorphic_ctype": TRANSFER_POLYMORPHIC_CTYPE, "resourcetype": "Transaction", "source": source.id, - "destination": dest.id + "source_alias": source.name, + "destination": dest.id, + "destination_alias": dest.name }).done(function () { addMsg("Le transfert de " + pretty_money(source.quantity * dest.quantity * 100 * $("#amount").val()) + " de la note " + source.name @@ -186,7 +192,9 @@ $("#transfer").click(function() { "polymorphic_ctype": SPECIAL_TRANSFER_POLYMORPHIC_CTYPE, "resourcetype": "SpecialTransaction", "source": source, + "source_alias": source.name, "destination": dest, + "destination_alias": dest.name, "last_name": $("#last_name").val(), "first_name": $("#first_name").val(), "bank": $("#bank").val()