diff --git a/app/routes.py b/app/routes.py index a227d50..00a9c8e 100644 --- a/app/routes.py +++ b/app/routes.py @@ -25,11 +25,8 @@ def to_json_array(collection): @app.route("/") def index(): - # get all elections that have this status. pending - status = Status.query.get(1) - elections = Election.query.with_parent( - status).all() # all elections in the system - return render_template("index.html", title="Home Page", elections=elections) + + return render_template("index.html", title="Home Page") @app.route("/login-complete") @@ -58,11 +55,15 @@ def login_complete(): return redirect(url_for('dashboard')) -@app.route("/dashboard") +@app.route("/home") @login_required def dashboard(): - elections = current_user.elections.all() # all user elections - return render_template("dashboard.html", title="User Dashboard", elections=elections) + # get all elections that have this status. pending + status = Status.query.get(1) + elections = Election.query.with_parent( + status).all() # all elections in the system + user_elections = current_user.elections.all() # all user elections + return render_template("dashboard.html", title="User Home", elections=elections, user_elections=user_elections) @app.route("/elections/new", methods=['GET', 'POST']) diff --git a/app/static/css/styles.css b/app/static/css/styles.css new file mode 100644 index 0000000..e2ab167 --- /dev/null +++ b/app/static/css/styles.css @@ -0,0 +1,9 @@ +body { + /* color: grey; */ + background-color: #e1e1e1; +} + +header { + background-color: #5792cf !important; + color: white; +} diff --git a/app/templates/dashboard.html b/app/templates/dashboard.html index 9c45421..1ff6d45 100644 --- a/app/templates/dashboard.html +++ b/app/templates/dashboard.html @@ -2,20 +2,41 @@ {% block content %}
-

Hello, {{ current_user.get_name()[0].capitalize() }}

- +
+ +
+
-

Your elections

- - {% if elections %} - +

Your elections

+ {% if user_elections %} +
+ + + + {% for election in user_elections %} + {% include "partials/election_record.html" %} + {% endfor %} +
- Id + Name + + Status + Actions +
+ {% endif %} + +

Upcoming elections

+ + + + @@ -23,13 +44,12 @@

Your elections

Status {% for election in elections %} {% include "partials/election_record.html" %} {% endfor %}
Name - Actions + Action
- {% endif %} {% endblock %} \ No newline at end of file diff --git a/app/templates/index.html b/app/templates/index.html index cf6868c..5cbc644 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -1,31 +1,22 @@ {% extends "layouts/base.html" %} {% block content %} -
-

This is the home page!

+
+

EVoting

- {% if current_user.is_authenticated and elections %} -

Upcoming elections

+

+ Yarnnsss +

- - - - - - - - {% for election in elections %} - {% include "partials/election_record.html" %} - {% endfor %} -
- Id - - Name - - Status - - Action -
- {% endif %} +
+ {% if current_user.is_authenticated %} + + + + {% else %} + + {% endif %} + +
{% endblock %} \ No newline at end of file diff --git a/app/templates/layouts/base.html b/app/templates/layouts/base.html index 8060369..d6faf68 100644 --- a/app/templates/layouts/base.html +++ b/app/templates/layouts/base.html @@ -11,6 +11,12 @@ Welcome to E-Voting {% endif %} + + + + + {% endif %} - + + \ No newline at end of file diff --git a/app/templates/partials/election_record.html b/app/templates/partials/election_record.html index 4150535..e122262 100644 --- a/app/templates/partials/election_record.html +++ b/app/templates/partials/election_record.html @@ -1,18 +1,29 @@ - {{ election.id }} + + {{ election.name }} + + + + + {{ election.status.name }} + - {{ election.name }} - {{ election.status.name }} {%if election.owner.id == current_user.id %} - Edit + + + edit + + {% endif %} - View - {% if election.status.name == 'started' %} - Vote + + + {% endif %} \ No newline at end of file diff --git a/app/templates/partials/header.html b/app/templates/partials/header.html new file mode 100644 index 0000000..1a633b6 --- /dev/null +++ b/app/templates/partials/header.html @@ -0,0 +1,38 @@ +
+
+ {% if current_user.is_authenticated %} + +
+

+ Hi, {{ current_user.get_name()[0].capitalize() }} +

+ +
+ {% if current_user.is_anonymous %} +
+ +
+ {% else %} +
+ +
+ {% endif %} +
+
+ {% endif %} + + + +
+ +
+
\ No newline at end of file