From 93cb146eb3c141f4fcc53a1b61d1aa3b0a837522 Mon Sep 17 00:00:00 2001 From: Kevin Alberts Date: Tue, 12 Nov 2019 13:58:30 +0100 Subject: [PATCH] Fix graph layout --- tapperssleutel/views.py | 4 ++++ templates/detail.html | 9 ++++++--- templates/home.html | 5 ++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tapperssleutel/views.py b/tapperssleutel/views.py index 85f97d9..3943f71 100644 --- a/tapperssleutel/views.py +++ b/tapperssleutel/views.py @@ -32,6 +32,7 @@ class HomePage(CreateView): dates = Kwijtgeraakt.objects.all().order_by('date') context['tapperlist'] = [x.name for x in Tapper.objects.all()] + context['datelist'] = [x.date.strftime("%Y-%m-%d") for x in dates] context['tappersdata'] = {} current_counts = {tapper.name: 0 for tapper in Tapper.objects.all()} for date in dates: @@ -59,9 +60,12 @@ class DetailPage(FormView): context['tappers'] = Tapper.objects.all().annotate(amount=Count('kwijtgeraakt')) context['detailform'] = form + context['start_date'] = form.cleaned_data['start_date'] + context['end_date'] = form.cleaned_data['end_date'] dates = Kwijtgeraakt.objects.filter(date__gte=form.cleaned_data['start_date'], date__lte=form.cleaned_data['end_date']).order_by('date') context['tapperlist'] = [x.name for x in Tapper.objects.all()] + context['datelist'] = [x.date.strftime("%Y-%m-%d") for x in dates] context['tappersdata'] = {} current_counts = {tapper.name: 0 for tapper in Tapper.objects.all()} for date in dates: diff --git a/templates/detail.html b/templates/detail.html index 18e67c3..db38c60 100644 --- a/templates/detail.html +++ b/templates/detail.html @@ -54,10 +54,12 @@ {{ tapperlist|json_script:"tapperlist" }} + {{ datelist|json_script:"datelist" }} {{ tappersdata|json_script:"tapperdata" }} {{ tapperlist|json_script:"tapperlist" }} + {{ datelist|json_script:"datelist" }} {{ tappersdata|json_script:"tapperdata" }}