Basic election details display
This commit is contained in:
parent
3fc98c8a36
commit
a3652e40de
@ -35,8 +35,12 @@ class Ballot(EmbeddedObject):
|
|||||||
|
|
||||||
class Voter(EmbeddedObject):
|
class Voter(EmbeddedObject):
|
||||||
_id = UUIDField()
|
_id = UUIDField()
|
||||||
|
name = StringField()
|
||||||
ballots = EmbeddedObjectListField()
|
ballots = EmbeddedObjectListField()
|
||||||
|
|
||||||
|
class EmailVoter(Voter):
|
||||||
|
email = StringField()
|
||||||
|
|
||||||
class Question(EmbeddedObject):
|
class Question(EmbeddedObject):
|
||||||
prompt = StringField()
|
prompt = StringField()
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ from eos.psr.mixnet import *
|
|||||||
from eos.psr.workflow import *
|
from eos.psr.workflow import *
|
||||||
|
|
||||||
import eos.core.hashing
|
import eos.core.hashing
|
||||||
|
import eosweb
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
@ -49,11 +50,12 @@ def setup_test_election():
|
|||||||
# Set election details
|
# Set election details
|
||||||
election.name = 'Test Election'
|
election.name = 'Test Election'
|
||||||
|
|
||||||
for i in range(3):
|
|
||||||
voter = Voter()
|
voter = Voter()
|
||||||
election.voters.append(voter)
|
election.voters.append(Voter(name='Alice'))
|
||||||
|
election.voters.append(Voter(name='Bob'))
|
||||||
|
election.voters.append(Voter(name='Charlie'))
|
||||||
|
|
||||||
election.mixing_trustees.append(MixingTrustee())
|
election.mixing_trustees.append(MixingTrustee(name='Eos Voting'))
|
||||||
|
|
||||||
election.sk = EGPrivateKey.generate()
|
election.sk = EGPrivateKey.generate()
|
||||||
election.public_key = election.sk.public_key
|
election.public_key = election.sk.public_key
|
||||||
@ -76,7 +78,7 @@ def setup_test_election():
|
|||||||
|
|
||||||
@app.context_processor
|
@app.context_processor
|
||||||
def inject_globals():
|
def inject_globals():
|
||||||
return {'eos': eos, 'SHA256': eos.core.hashing.SHA256}
|
return {'eos': eos, 'eosweb': eosweb, 'SHA256': eos.core.hashing.SHA256}
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
@ -93,3 +95,31 @@ def using_election(func):
|
|||||||
@using_election
|
@using_election
|
||||||
def election_view(election):
|
def election_view(election):
|
||||||
return flask.render_template('election/view.html', election=election)
|
return flask.render_template('election/view.html', election=election)
|
||||||
|
|
||||||
|
@app.route('/election/<election_id>/booth')
|
||||||
|
@using_election
|
||||||
|
def election_booth(election):
|
||||||
|
return flask.render_template('election/booth.html', election=election)
|
||||||
|
|
||||||
|
@app.route('/election/<election_id>/view/questions')
|
||||||
|
@using_election
|
||||||
|
def election_view_questions(election):
|
||||||
|
return flask.render_template('election/questions.html', election=election)
|
||||||
|
|
||||||
|
@app.route('/election/<election_id>/view/ballots')
|
||||||
|
@using_election
|
||||||
|
def election_view_ballots(election):
|
||||||
|
return flask.render_template('election/ballots.html', election=election)
|
||||||
|
|
||||||
|
@app.route('/election/<election_id>/view/trustees')
|
||||||
|
@using_election
|
||||||
|
def election_view_trustees(election):
|
||||||
|
return flask.render_template('election/trustees.html', election=election)
|
||||||
|
|
||||||
|
# === Model-Views ===
|
||||||
|
|
||||||
|
model_view_map = {}
|
||||||
|
|
||||||
|
# TODO: Make more modular
|
||||||
|
from . import modelview
|
||||||
|
model_view_map.update(modelview.model_view_map)
|
||||||
|
30
eosweb/core/modelview.py
Normal file
30
eosweb/core/modelview.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Eos - Verifiable elections
|
||||||
|
# Copyright © 2017 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from eos.base.election import *
|
||||||
|
from eos.psr.election import *
|
||||||
|
|
||||||
|
model_view_map = {
|
||||||
|
ApprovalQuestion: {
|
||||||
|
'view': 'question/approval/view.html'
|
||||||
|
},
|
||||||
|
Election: {
|
||||||
|
'tabs': 'election/core/tabs.html'
|
||||||
|
},
|
||||||
|
PSRElection: {
|
||||||
|
'tabs': 'election/psr/tabs.html'
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,7 @@
|
|||||||
{% block basecontent %}
|
{% block basecontent %}
|
||||||
<div class="ui fixed inverted menu" style="margin-right: 1.5em;">
|
<div class="ui fixed inverted menu" style="margin-right: 1.5em;">
|
||||||
<div class="ui container">
|
<div class="ui container">
|
||||||
<a href="#" class="header item">Eos Voting</a>
|
<a href="/" class="header item">Eos Voting</a>
|
||||||
<a href="#" class="item right">Log in</a>
|
<a href="#" class="item right">Log in</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
42
eosweb/core/templates/election/ballots.html
Normal file
42
eosweb/core/templates/election/ballots.html
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{% extends 'election/base.html' %}
|
||||||
|
|
||||||
|
{#
|
||||||
|
Eos - Verifiable elections
|
||||||
|
Copyright © 2017 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#}
|
||||||
|
|
||||||
|
{% block electioncontent %}
|
||||||
|
<table class="ui celled table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Voter</th>
|
||||||
|
<th>Ballot fingerprint</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for voter in election.voters %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ voter.name }}</td>
|
||||||
|
{% if voter.ballot|length > 0 %}
|
||||||
|
<td class="hash">{{ SHA256().update_obj(voter.ballot[-1]).hash_as_b64() }}</td>
|
||||||
|
{% else %}
|
||||||
|
<td class="hash"></td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock %}
|
@ -20,13 +20,17 @@
|
|||||||
|
|
||||||
{% block title %}{{ election.name }}{% endblock %}
|
{% block title %}{{ election.name }}{% endblock %}
|
||||||
|
|
||||||
|
{% macro tab(name, view) %}
|
||||||
|
<a href="{{ url_for(view, election_id=election._id) }}" class="election-tab-ajax item{% if request.endpoint == view %} active{% endif %}">{{ name }}</a>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{{ election.name }}</h1>
|
<h1>{{ election.name }}</h1>
|
||||||
|
|
||||||
<p><small><b>Election fingerprint:</b> <span class="hash">{{ SHA256().update_obj(election).hash_as_b64() }}</span></small></p>
|
<p><small><b>Election fingerprint:</b> <span class="hash">{{ SHA256().update_obj(election).hash_as_b64() }}</span></small></p>
|
||||||
|
|
||||||
<div class="ui secondary pointing menu" id="election-tab-menu">
|
<div class="ui secondary pointing menu" id="election-tab-menu">
|
||||||
<a href="#" class="election-tab-ajax item active">Overview</a>
|
{% include eosweb.core.main.model_view_map[election.__class__]['tabs'] %}
|
||||||
</div>
|
</div>
|
||||||
<div class="ui container" id="election-tab-content">
|
<div class="ui container" id="election-tab-content">
|
||||||
{% block electioncontent %}
|
{% block electioncontent %}
|
||||||
|
27
eosweb/core/templates/election/booth.html
Normal file
27
eosweb/core/templates/election/booth.html
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{#
|
||||||
|
Eos - Verifiable elections
|
||||||
|
Copyright © 2017 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#}
|
||||||
|
|
||||||
|
{% block title %}{{ election.name }} – Voting booth{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>{{ election.name }}</h1>
|
||||||
|
|
||||||
|
<p><small><b>Election fingerprint:</b> <span class="hash">{{ SHA256().update_obj(election).hash_as_b64() }}</span></small></p>
|
||||||
|
{% endblock %}
|
23
eosweb/core/templates/election/core/tabs.html
Normal file
23
eosweb/core/templates/election/core/tabs.html
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{#
|
||||||
|
Eos - Verifiable elections
|
||||||
|
Copyright © 2017 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#}
|
||||||
|
|
||||||
|
{% block tabs %}
|
||||||
|
{{ tab('Overview', 'election_view') }}
|
||||||
|
{{ tab('Questions', 'election_view_questions') }}
|
||||||
|
{{ tab('Voters and ballots', 'election_view_ballots') }}
|
||||||
|
{% endblock %}
|
24
eosweb/core/templates/election/psr/tabs.html
Normal file
24
eosweb/core/templates/election/psr/tabs.html
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{% extends 'election/core/tabs.html' %}
|
||||||
|
|
||||||
|
{#
|
||||||
|
Eos - Verifiable elections
|
||||||
|
Copyright © 2017 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#}
|
||||||
|
|
||||||
|
{% block tabs %}
|
||||||
|
{{ super() }}
|
||||||
|
{{ tab('Trustees', 'election_view_trustees') }}
|
||||||
|
{% endblock %}
|
26
eosweb/core/templates/election/questions.html
Normal file
26
eosweb/core/templates/election/questions.html
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{% extends 'election/base.html' %}
|
||||||
|
|
||||||
|
{#
|
||||||
|
Eos - Verifiable elections
|
||||||
|
Copyright © 2017 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#}
|
||||||
|
|
||||||
|
{% block electioncontent %}
|
||||||
|
{% for question in election.questions %}
|
||||||
|
<h2>{{ loop.index }}. {{ question.prompt }}</h2>
|
||||||
|
{% include eosweb.core.main.model_view_map[question.__class__]['view'] %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock %}
|
28
eosweb/core/templates/election/trustees.html
Normal file
28
eosweb/core/templates/election/trustees.html
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{% extends 'election/base.html' %}
|
||||||
|
|
||||||
|
{#
|
||||||
|
Eos - Verifiable elections
|
||||||
|
Copyright © 2017 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#}
|
||||||
|
|
||||||
|
{% block electioncontent %}
|
||||||
|
<h2>Mixing trustees</h2>
|
||||||
|
<ol class="ui list">
|
||||||
|
{% for trustee in election.mixing_trustees %}
|
||||||
|
<li>{{ trustee.name or 'Unnamed trustee' }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ol>
|
||||||
|
{% endblock %}
|
@ -23,7 +23,11 @@
|
|||||||
{% block electioncontent %}
|
{% block electioncontent %}
|
||||||
{% if election.workflow.get_task('eos.base.workflow.TaskConfigureElection').status == Status.EXITED %}
|
{% if election.workflow.get_task('eos.base.workflow.TaskConfigureElection').status == Status.EXITED %}
|
||||||
{% if election.workflow.get_task('eos.base.workflow.TaskOpenVoting').status == Status.EXITED %}
|
{% if election.workflow.get_task('eos.base.workflow.TaskOpenVoting').status == Status.EXITED %}
|
||||||
<p><a href="#" class="ui huge primary button">Click here to vote in this election</a></p>
|
{% if election.workflow.get_task('eos.base.workflow.TaskCloseVoting').status == Status.EXITED %}
|
||||||
|
<p><button class="ui huge button">Voting in this election has closed</button></p>
|
||||||
|
{% else %}
|
||||||
|
<p><a href="{{ url_for('election_booth', election_id=election._id) }}" class="ui huge primary button">Click here to vote in this election</a></p>
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p><button class="ui huge button">Voting in this election has not yet opened</button></p>
|
<p><button class="ui huge button">Voting in this election has not yet opened</button></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
23
eosweb/core/templates/question/approval/view.html
Normal file
23
eosweb/core/templates/question/approval/view.html
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{#
|
||||||
|
Eos - Verifiable elections
|
||||||
|
Copyright © 2017 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#}
|
||||||
|
|
||||||
|
<ul class="ui list">
|
||||||
|
{% for choice in question.choices %}
|
||||||
|
<li>{{ choice }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
Loading…
Reference in New Issue
Block a user