From 4b5177e16b1436f3abed93e668eafad5b9027934 Mon Sep 17 00:00:00 2001 From: Yingtong Li Date: Thu, 11 Jan 2018 21:12:27 +0800 Subject: [PATCH] Add voter information page --- eosweb/core/main.py | 8 ++ eosweb/core/static/css/main.css | 6 ++ eosweb/core/templates/base.html | 2 +- .../core/templates/election/view/ballots.html | 16 ++-- .../core/templates/election/voter/view.html | 82 +++++++++++++++++++ 5 files changed, 106 insertions(+), 8 deletions(-) create mode 100644 eosweb/core/templates/election/voter/view.html diff --git a/eosweb/core/main.py b/eosweb/core/main.py index 679f1be..2492c14 100644 --- a/eosweb/core/main.py +++ b/eosweb/core/main.py @@ -44,6 +44,7 @@ import json import os import pytz import subprocess +import uuid app = flask.Flask(__name__, static_folder=None) @@ -244,6 +245,13 @@ def election_view_questions(election): def election_view_ballots(election): return flask.render_template('election/view/ballots.html', election=election) +@app.route('/election//voter/') +@using_election +def election_voter_view(election, voter_id): + voter_id = uuid.UUID(voter_id) + voter = next(voter for voter in election.voters if voter._id == voter_id) + return flask.render_template('election/voter/view.html', election=election, voter=voter) + @app.route('/election//view/trustees') @using_election def election_view_trustees(election): diff --git a/eosweb/core/static/css/main.css b/eosweb/core/static/css/main.css index c927b48..e2aa7e4 100644 --- a/eosweb/core/static/css/main.css +++ b/eosweb/core/static/css/main.css @@ -29,6 +29,7 @@ .monoout { font-family: monospace; white-space: pre-wrap; + word-break: break-all; overflow-y: scroll; padding: .78571429em 1em; @@ -60,6 +61,11 @@ time[title] { margin-left: 0 !important; } +/* Fix nested selectable tables */ +.ui.table.selectable tr > td.selectable:hover { + background: initial !important; +} + @media print { body, html { /* Default height: 100% causes blank pages */ diff --git a/eosweb/core/templates/base.html b/eosweb/core/templates/base.html index 706dff1..7d243a6 100644 --- a/eosweb/core/templates/base.html +++ b/eosweb/core/templates/base.html @@ -42,7 +42,7 @@ {% endif %} -
+
{% block content %} {% endblock content %}
diff --git a/eosweb/core/templates/election/view/ballots.html b/eosweb/core/templates/election/view/ballots.html index 7515946..3de2920 100644 --- a/eosweb/core/templates/election/view/ballots.html +++ b/eosweb/core/templates/election/view/ballots.html @@ -19,7 +19,7 @@ #} {% block electioncontent %} - +
@@ -29,13 +29,15 @@ {% for voter in election.voters %} - + {% set votes = voter.votes.get_all() %} - {% if votes|length > 0 %} - - {% else %} - - {% endif %} + {% endfor %} diff --git a/eosweb/core/templates/election/voter/view.html b/eosweb/core/templates/election/voter/view.html new file mode 100644 index 0000000..423e711 --- /dev/null +++ b/eosweb/core/templates/election/voter/view.html @@ -0,0 +1,82 @@ +{% extends 'base.html' %} + +{# + Eos - Verifiable elections + Copyright © 2017-18 RunasSudo (Yingtong Li) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +#} + +{# Big tables on this page #} +{% block mainContainerOpts %}style="max-width: 100% !important;"{% endblock %} + +{% block title %}{{ voter.name }} – {{ election.name }}{% endblock %} + +{% block content %} +

{{ election.name }}

+ +

{{ election.kind|title }} fingerprint: {{ SHA256().update_obj(election).hash_as_b64() }}

+ +

{{ voter.name }}

+ +

Votes cast

+ +
Voter
{{ voter.name }}{{ voter.name }}{{ SHA256().update_obj(votes[-1].ballot).hash_as_b64(True) }} + {% if votes|length > 0 %} + {{ SHA256().update_obj(votes[-1].ballot).hash_as_b64(True) }} + {% else %} +   + {% endif %} +
+ + + + + {% if session.user and session.user.is_admin() %} + + + {% else %} + + {% endif %} + + + + {% for vote in voter.votes.get_all() %} + + + + {% if session.user and session.user.is_admin() %} + + {% endif %} + + + {% endfor %} + +
Cast atCommentClientBallot fingerprint (Content/Actions )Ballot fingerprint (Content )
{{ vote.cast_at|pretty_date }}{% if vote.comment %}{{ vote.comment }}{% endif %} + {% if vote.cast_ip %}{{ vote.cast_ip }}{% if vote.cast_fingerprint %}
{% endif %}{% endif %} + {% if vote.cast_fingerprint %}{{ eos.core.hashing.SHA256().update_text(eos.core.objects.EosObject.to_json(vote.cast_fingerprint)).hash_as_b64(True) }}{% endif %} +
+
+
+ + {{ eos.core.hashing.SHA256().update_obj(vote).hash_as_b64(True) }} +
+
+
{% if session.user and session.user.is_admin() %}{{ eos.core.objects.EosObject.to_json(eos.core.objects.EosObject.serialise_and_wrap(vote)) }}{% else %}{{ eos.core.objects.EosObject.to_json(eos.core.objects.EosObject.serialise_and_wrap(vote, options=eos.core.objects.SerialiseOptions(should_protect=True))) }}{% endif %}
+
+
+
+{% endblock %} + +{% block basecontent %} + {{ super() }} + + +{% endblock %}