diff --git a/apps/note/templates/note/amount_input.html b/apps/note/templates/note/amount_input.html index f4515234..43ac1687 100644 --- a/apps/note/templates/note/amount_input.html +++ b/apps/note/templates/note/amount_input.html @@ -1,12 +1,14 @@ +{# Select amount to transfert in € #}

-
\ No newline at end of file + diff --git a/apps/note/templates/note/conso_form.html b/apps/note/templates/note/conso_form.html index 29acb3de..18cac578 100644 --- a/apps/note/templates/note/conso_form.html +++ b/apps/note/templates/note/conso_form.html @@ -45,7 +45,7 @@ - + {# Summary of consumption and consume button #}
@@ -91,7 +91,6 @@
{# Regroup buttons under categories #} - {# {% regroup transaction_templates by category as categories %} #}
{# Tabs for button categories #} @@ -148,7 +147,7 @@
- + {# history of transaction #}

diff --git a/apps/note/templates/note/transaction_form.html b/apps/note/templates/note/transaction_form.html index 4715e79f..aec1f2e2 100644 --- a/apps/note/templates/note/transaction_form.html +++ b/apps/note/templates/note/transaction_form.html @@ -6,7 +6,7 @@ SPDX-License-Identifier: GPL-2.0-or-later {% load i18n static django_tables2 perms %} {% block content %} - +{# bandeau transfert/crédit/débit/activité #}

@@ -34,8 +34,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
-
+ {# Preview note profile (picture, username and balance) #} - + {# list of emitters #}
@@ -66,7 +66,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
- +{# list of receiver #}
@@ -83,7 +83,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
- +{# Information on transaction (amount, reason, name,...) #}
@@ -108,7 +108,7 @@ SPDX-License-Identifier: GPL-2.0-or-later

- + {# in case of special transaction add identity information #}
@@ -149,7 +149,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
- +{# transaction history #}

diff --git a/apps/note/templates/note/transactiontemplate_list.html b/apps/note/templates/note/transactiontemplate_list.html index 91b34728..76b116e9 100644 --- a/apps/note/templates/note/transactiontemplate_list.html +++ b/apps/note/templates/note/transactiontemplate_list.html @@ -5,6 +5,7 @@ {% block content %}

+ {# Search field , see js #}
{% trans "New button" %} diff --git a/apps/note/views.py b/apps/note/views.py index 6aadb4ab..9b383b1f 100644 --- a/apps/note/views.py +++ b/apps/note/views.py @@ -29,21 +29,19 @@ class TransactionCreateView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTabl e.g. for donation/transfer between people and clubs or for credit/debit with :models:`note.NoteSpecial` """ template_name = "note/transaction_form.html" - + # SingleTableView creates `context["table"]` we will load it with transaction history model = Transaction # Transaction history table table_class = HistoryTable extra_context = {"title": _("Transfer money")} def get_queryset(self, **kwargs): + # retrieves only Transaction that user has the right to see. return Transaction.objects.filter( PermissionBackend.filter_queryset(self.request.user, Transaction, "view") ).order_by("-created_at").all()[:20] def get_context_data(self, **kwargs): - """ - Add some context variables in template such as page title - """ context = super().get_context_data(**kwargs) context['amount_widget'] = AmountInput(attrs={"id": "amount"}) context['polymorphic_ctype'] = ContentType.objects.get_for_model(Transaction).pk @@ -146,7 +144,7 @@ class TransactionTemplateUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, Up class ConsoView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView): """ The Magic View that make people pay their beer and burgers. - (Most of the magic happens in the dark world of Javascript see consos.js) + (Most of the magic happens in the dark world of Javascript see `note_kfet/static/js/consos.js`) """ model = Transaction template_name = "note/conso_form.html" @@ -168,21 +166,25 @@ class ConsoView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView): return super().dispatch(request, *args, **kwargs) def get_queryset(self, **kwargs): + """ + restrict to the transaction history the user can see. + """ return Transaction.objects.filter( PermissionBackend.filter_queryset(self.request.user, Transaction, "view") ).order_by("-created_at").all()[:20] def get_context_data(self, **kwargs): - """ - Add some context variables in template such as page title - """ context = super().get_context_data(**kwargs) + categories = TemplateCategory.objects.order_by('name').all() + # for each category, find which transaction templates the user can see. for category in categories: category.templates_filtered = category.templates.filter( PermissionBackend().filter_queryset(self.request.user, TransactionTemplate, "view") ).filter(display=True).order_by('name').all() + context['categories'] = [cat for cat in categories if cat.templates_filtered] + # some transactiontemplate are put forward to find them easily context['highlighted'] = TransactionTemplate.objects.filter(highlighted=True).filter( PermissionBackend().filter_queryset(self.request.user, TransactionTemplate, "view") ).order_by('name').all()