1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-21 01:48:21 +02:00

Merge branch 'master' into 'turbolinks'

# Conflicts:
#   apps/note/views.py
This commit is contained in:
erdnaxe
2020-02-22 11:09:45 +01:00
4 changed files with 98 additions and 47 deletions

View File

@ -12,7 +12,6 @@ urlpatterns = [
path('buttons/create/', views.TransactionTemplateCreateView.as_view(), name='template_create'),
path('buttons/update/<int:pk>/', views.TransactionTemplateUpdateView.as_view(), name='template_update'),
path('buttons/', views.TransactionTemplateListView.as_view(), name='template_list'),
path('consos/<str:template_type>/', views.ConsoView.as_view(), name='consos'),
path('consos/', views.ConsoView.as_view(), name='consos'),
# API for the note autocompleter

View File

@ -8,7 +8,7 @@ from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django.views.generic import CreateView, ListView, UpdateView
from .models import Transaction, TransactionCategory, TransactionTemplate, Alias
from .models import Transaction, TransactionTemplate, Alias
from .forms import TransactionForm, TransactionTemplateForm, ConsoForm
@ -138,21 +138,17 @@ class ConsoView(LoginRequiredMixin, CreateView):
Add some context variables in template such as page title
"""
context = super().get_context_data(**kwargs)
context['template_types'] = TransactionCategory.objects.all()
context['transaction_templates'] = TransactionTemplate.objects.all() \
.order_by('template_type')
context['title'] = _("Consommations")
# select2 compatibility
context['no_cache'] = True
if 'template_type' not in self.kwargs.keys():
return context
template_type = TransactionCategory.objects.filter(
name=self.kwargs.get('template_type')).get()
context['buttons'] = TransactionTemplate.objects.filter(
template_type=template_type)
context['title'] = template_type
return context
def get_success_url(self):
return reverse('note:consos',
args=(self.kwargs.get('template_type'), ))
"""
When clicking a button, reload the same page
"""
return reverse('note:consos')