diff --git a/apps/note/views.py b/apps/note/views.py index 167ef4f0d4c4c8a45c251e7e60af2ebb622b98b1..c42c243fb33645fff9b0228027e3cf23939ab53d 100644 --- a/apps/note/views.py +++ b/apps/note/views.py @@ -138,8 +138,8 @@ class ConsoView(LoginRequiredMixin, CreateView): Add some context variables in template such as page title """ context = super().get_context_data(**kwargs) - context['transaction_templates'] = TransactionTemplate.objects.all() \ - .order_by('template_type') + context['transaction_templates'] = TransactionTemplate.objects.filter(display=True) \ + .order_by('category') context['title'] = _("Consommations") # select2 compatibility diff --git a/templates/note/conso_form.html b/templates/note/conso_form.html index b121ad54d12f970a66f9572194d3b45d8a3376c8..10b06589cfd4434aa6bc79100307901d017b1547 100644 --- a/templates/note/conso_form.html +++ b/templates/note/conso_form.html @@ -7,7 +7,7 @@ {% block content %} {# Regroup buttons under categories #} - {% regroup transaction_templates by template_type as template_types %} + {% regroup transaction_templates by category as categories %} <form method="post" onsubmit="window.onbeforeunload=null"> {% csrf_token %} @@ -44,10 +44,10 @@ {# Tabs for button categories #} <div class="card-header"> <ul class="nav nav-tabs nav-fill card-header-tabs"> - {% for template_type in template_types %} + {% for category in categories %} <li class="nav-item"> - <a class="nav-link" data-toggle="tab" href="#{{ template_type.grouper|slugify }}"> - {{ template_type.grouper }} + <a class="nav-link" data-toggle="tab" href="#{{ category.grouper|slugify }}"> + {{ category.grouper }} </a> </li> {% endfor %} @@ -57,10 +57,10 @@ {# Tabs content #} <div class="card-body"> <div class="tab-content"> - {% for template_type in template_types %} - <div class="tab-pane" id="{{ template_type.grouper|slugify }}"> + {% for category in categories %} + <div class="tab-pane" id="{{ category.grouper|slugify }}"> <div class="d-inline-flex flex-wrap justify-content-center"> - {% for button in template_type.list %} + {% for button in category.list %} <button class="btn btn-outline-dark rounded-0 flex-fill" name="button" value="{{ button.name }}"> {{ button.name }} ({{ button.amount | pretty_money }})