From f6f72a3216663a3dab540244a17680cefe951c84 Mon Sep 17 00:00:00 2001 From: Ben Cipollini Date: Wed, 10 Feb 2016 13:46:58 -0500 Subject: [PATCH] ENH: #152 Add webpage for viewing missing data. --- disclosure/templates/homepage.html | 6 ++++-- disclosure/templates/missing-ballot-data.html | 8 ++++++++ disclosure/urls.py | 1 + disclosure/views.py | 16 ++++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 disclosure/templates/missing-ballot-data.html diff --git a/disclosure/templates/homepage.html b/disclosure/templates/homepage.html index 52f7cd6c..4a3a2abd 100644 --- a/disclosure/templates/homepage.html +++ b/disclosure/templates/homepage.html @@ -1,7 +1,9 @@ +View missing data report. +
+View / edit data. +
Check out the API Documentation
-View the admin interface / database data. -
{% if cronjobs %}

Cron Status:

diff --git a/disclosure/templates/missing-ballot-data.html b/disclosure/templates/missing-ballot-data.html new file mode 100644 index 00000000..27bd5128 --- /dev/null +++ b/disclosure/templates/missing-ballot-data.html @@ -0,0 +1,8 @@ +{% if bad_ballots %} +

Unedited, auto-generated ballots:

+ +{% endif %} diff --git a/disclosure/urls.py b/disclosure/urls.py index 7735f0c1..41d77fee 100644 --- a/disclosure/urls.py +++ b/disclosure/urls.py @@ -17,6 +17,7 @@ # Non-API views url(r'^$', views.homepage_view), + url(r'^missing-data/$', views.missing_data_view), # inclusions url(r'', include('ballot.urls')), diff --git a/disclosure/views.py b/disclosure/views.py index 31642075..9e825596 100644 --- a/disclosure/views.py +++ b/disclosure/views.py @@ -1,6 +1,7 @@ import os from django.conf import settings +from django.contrib.auth.decorators import login_required from django.db.models import F, Q, Sum from django.http import HttpResponse from django.shortcuts import get_object_or_404 @@ -170,6 +171,7 @@ def opposing(self, request, candidate_id): def homepage_view(request): + """Relevant links and potential issues.""" template = loader.get_template('homepage.html') template_context = {} if settings.CRON_LOGS_DIR: @@ -186,3 +188,17 @@ def homepage_view(request): with open(cronlog_filepath, 'r') as f: template_context['cronjobs'] += [f.read()] return HttpResponse(template.render(template_context, request)) + + +@login_required +def missing_data_view(request): + """Report on which ballot data are missing. + + * Ballot - dates should be set (None by default) + * Beneficiary - what is their position (support/oppose), on which BallotItemSelection? + * + """ + template = loader.get_template('missing-ballot-data.html') + template_context = { + 'bad_ballots': Ballot.objects.filter(date=None)} + return HttpResponse(template.render(template_context, request))