Skip to content
This repository has been archived by the owner on Apr 14, 2019. It is now read-only.

Commit

Permalink
ENH: #152 Add webpage for viewing missing data.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Cipollini committed Feb 10, 2016
1 parent 7378611 commit f6f72a3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
6 changes: 4 additions & 2 deletions disclosure/templates/homepage.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<a href='/missing-data/'>View missing data report.</a>
<br />
<a href='/admin/'>View / edit data.</a>
<br />
<a href='/docs/'>Check out the API Documentation</a>
<br/>
<a href='/admin/'>View the admin interface / database data.</a>
<br />

{% if cronjobs %}
<h2>Cron Status:</h2>
Expand Down
8 changes: 8 additions & 0 deletions disclosure/templates/missing-ballot-data.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% if bad_ballots %}
<h2>Unedited, auto-generated ballots:</h2>
<ul>
{% for bad_ballot in bad_ballots %}
<li><a href="/admin/ballot/ballot/{{ bad_ballot.id }}/">{{ bad_ballot }}</a></li>
{% endfor %}
</ul>
{% endif %}
1 change: 1 addition & 0 deletions disclosure/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
Expand Down
16 changes: 16 additions & 0 deletions disclosure/views.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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))

0 comments on commit f6f72a3

Please sign in to comment.