Improve home page display with lots of elections
This commit is contained in:
parent
ca084d3207
commit
3a89a164f0
@ -214,7 +214,26 @@ def tick_scheduler():
|
|||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
return flask.render_template('index.html')
|
elections = Election.get_all()
|
||||||
|
elections.sort(key=lambda e: e.name)
|
||||||
|
|
||||||
|
elections_open = [e for e in elections if e.workflow.get_task('eos.base.workflow.TaskCloseVoting').status == WorkflowTaskStatus.READY]
|
||||||
|
|
||||||
|
elections_soon = [e for e in elections if e.workflow.get_task('eos.base.workflow.TaskCloseVoting').status != WorkflowTaskStatus.EXITED and e.workflow.get_task('eos.base.workflow.TaskOpenVoting').get_entry_task().run_at]
|
||||||
|
elections_soon.sort(key=lambda e: e.workflow.get_task('eos.base.workflow.TaskOpenVoting').get_entry_task().run_at)
|
||||||
|
|
||||||
|
elections_closed = [e for e in elections if e.workflow.get_task('eos.base.workflow.TaskCloseVoting').status == WorkflowTaskStatus.EXITED]
|
||||||
|
elections_closed.sort(key=lambda e: e.workflow.get_task('eos.base.workflow.TaskCloseVoting').exited_at, reverse=True)
|
||||||
|
elections_closed = elections_closed[:5]
|
||||||
|
|
||||||
|
return flask.render_template('index.html', elections_open=elections_open, elections_soon=elections_soon, elections_closed=elections_closed)
|
||||||
|
|
||||||
|
@app.route('/elections')
|
||||||
|
def elections():
|
||||||
|
elections = Election.get_all()
|
||||||
|
elections.sort(key=lambda e: e.name)
|
||||||
|
|
||||||
|
return flask.render_template('elections.html', elections=elections)
|
||||||
|
|
||||||
def using_election(func):
|
def using_election(func):
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
|
33
eosweb/core/templates/elections.html
Normal file
33
eosweb/core/templates/elections.html
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{% 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#}
|
||||||
|
|
||||||
|
{% block title %}Elections{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>All elections: Eos Voting for {{ eosweb.app.config['ORG_NAME'] }}</h1>
|
||||||
|
|
||||||
|
<p>Please choose an election from the list below:</p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{% for election in elections %}
|
||||||
|
<li><a href="{{ url_for('election_view', election_id=election._id) }}">{{ election.name }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{#
|
{#
|
||||||
Eos - Verifiable elections
|
Eos - Verifiable elections
|
||||||
Copyright © 2017 RunasSudo (Yingtong Li)
|
Copyright © 2017-18 RunasSudo (Yingtong Li)
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -24,9 +24,33 @@
|
|||||||
<h1>Eos Voting for {{ eosweb.app.config['ORG_NAME'] }}</h1>
|
<h1>Eos Voting for {{ eosweb.app.config['ORG_NAME'] }}</h1>
|
||||||
|
|
||||||
<p>Please choose an election from the list below:</p>
|
<p>Please choose an election from the list below:</p>
|
||||||
|
|
||||||
|
{% if elections_open %}
|
||||||
|
<h2>Currently open</h2>
|
||||||
<ul>
|
<ul>
|
||||||
{% for election in eos.base.election.Election.get_all() %}
|
{% for election in elections_open %}
|
||||||
<li><a href="{{ url_for('election_view', election_id=election._id) }}">{{ election.name }}</a></li>
|
<li><a href="{{ url_for('election_view', election_id=election._id) }}">{{ election.name }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if elections_soon %}
|
||||||
|
<h2>Opening soon</h2>
|
||||||
|
<ul>
|
||||||
|
{% for election in elections_soon %}
|
||||||
|
<li><a href="{{ url_for('election_view', election_id=election._id) }}">{{ election.name }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if elections_closed %}
|
||||||
|
<h2>Recently closed</h2>
|
||||||
|
<ul>
|
||||||
|
{% for election in elections_closed %}
|
||||||
|
<li><a href="{{ url_for('election_view', election_id=election._id) }}">{{ election.name }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<a href="{{ url_for('elections') }}">Show all</a>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user