diff --git a/eosweb/core/main.py b/eosweb/core/main.py index 68905ac..1d6d2bf 100644 --- a/eosweb/core/main.py +++ b/eosweb/core/main.py @@ -214,7 +214,26 @@ def tick_scheduler(): @app.route('/') 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): @functools.wraps(func) diff --git a/eosweb/core/templates/elections.html b/eosweb/core/templates/elections.html new file mode 100644 index 0000000..70049c9 --- /dev/null +++ b/eosweb/core/templates/elections.html @@ -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 . +#} + +{% block title %}Elections{% endblock %} + +{% block content %} +

All elections: Eos Voting for {{ eosweb.app.config['ORG_NAME'] }}

+ +

Please choose an election from the list below:

+ + +{% endblock %} diff --git a/eosweb/core/templates/index.html b/eosweb/core/templates/index.html index 2d0d63f..af8fa61 100644 --- a/eosweb/core/templates/index.html +++ b/eosweb/core/templates/index.html @@ -2,7 +2,7 @@ {# 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 it under the terms of the GNU Affero General Public License as published by @@ -24,9 +24,33 @@

Eos Voting for {{ eosweb.app.config['ORG_NAME'] }}

Please choose an election from the list below:

- + + {% if elections_open %} +

Currently open

+ + {% endif %} + + {% if elections_soon %} +

Opening soon

+ + {% endif %} + + {% if elections_closed %} +

Recently closed

+ + {% endif %} + + Show all {% endblock %}