浏览代码

Split vote in backend and public module

JoostSijm 6 年之前
父节点
当前提交
01ff9fe46c

+ 2 - 0
app/flaskr.py

@@ -13,6 +13,7 @@ from app.modules.vote import Vote
 from app.modules.backend.modules.page import Backend_Page
 from app.modules.backend.modules.file import Backend_File
 from app.modules.backend.modules.user import Backend_User
+from app.modules.backend.modules.vote import Backend_Vote
 
 app.register_blueprint(Auth)
 app.register_blueprint(Static)
@@ -20,6 +21,7 @@ app.register_blueprint(Backend, url_prefix='/backend')
 app.register_blueprint(Backend_Page, url_prefix='/backend/page')
 app.register_blueprint(Backend_File, url_prefix='/backend/file')
 app.register_blueprint(Backend_User, url_prefix='/backend/user')
+app.register_blueprint(Backend_Vote, url_prefix='/backend/vote')
 app.register_blueprint(Vote, url_prefix='/vote')
 
 

+ 1 - 1
app/models.py

@@ -181,7 +181,7 @@ class Ballot(db.Model):
         today = datetime.today()
         if self.start_at <= today <= self.end_at:
             return True
-        return False
+        return True
 
 
 class Priority(db.Model):

+ 6 - 0
app/modules/backend/modules/vote/__init__.py

@@ -0,0 +1,6 @@
+
+"""
+Website login page
+"""
+
+from .app import BLUEPRINT as Backend_Vote

+ 130 - 0
app/modules/backend/modules/vote/app.py

@@ -0,0 +1,130 @@
+
+"""
+Backend vote module
+"""
+
+import hashlib
+import hmac
+
+from datetime import datetime
+from flask_login import login_required, current_user
+from flask_menu import register_menu
+from flask import render_template, request, flash, Blueprint, redirect, url_for
+from app.models import User, Ballot, Priority, Question, Option, Code
+from app import db
+
+
+BLUEPRINT = Blueprint(
+    'backend_vote',
+    __name__,
+    template_folder='templates'
+)
+
+
+@register_menu(BLUEPRINT, 'vote', 'Vote')
+@BLUEPRINT.route("/")
+@login_required
+def main():
+    """Ballots overview"""
+    ballots = Ballot.query.all()
+
+    return render_template(
+        'main.j2',
+        ballots=ballots,
+    )
+
+
+@BLUEPRINT.route("/codes")
+@login_required
+def codes():
+    """codes overview"""
+    code = Code.query.order_by(Code.expire_date.desc()).first()
+    users = User.query.all()
+
+    return render_template(
+        'backend_vote/codes.j2',
+        users=users,
+        code=code,
+    )
+
+
+@BLUEPRINT.route('/create', methods=["GET", "POST"])
+@login_required
+def create():
+    """Creating ballot"""
+    if request.method == 'POST':
+        ballot = Ballot()
+        print(request.form)
+        ballot.name = request.form['name']
+        ballot.description = request.form['description']
+        ballot.user_id = current_user.id
+
+        start_at = "%s %s" % (request.form['start_at_date'], request.form['start_at_time'])
+        ballot.start_at = datetime.strptime(start_at, "%Y-%m-%d %H:%M")
+        end_at = "%s %s" % (request.form['end_at_date'], request.form['end_at_time'])
+        ballot.end_at = datetime.strptime(end_at, "%Y-%m-%d %H:%M")
+
+        db.session.add(ballot)
+        db.session.commit()
+
+        flash('Page "%s" successfully created' % ballot.name, 'success')
+        return redirect(url_for('vote.view', ballot_id=ballot.id))
+
+    priorities = Priority.query.all()
+
+    return render_template(
+        'backend_vote/create.j2',
+        priorities=priorities
+    )
+
+
+@BLUEPRINT.route('/<int:ballot_id>', methods=["GET", "POST"])
+@login_required
+def view(ballot_id):
+    """View ballot"""
+    ballot = Ballot.query.get(ballot_id)
+    if request.method == 'POST':
+        option = Option()
+        option.question_id = request.form['question_id']
+        option.name = request.form['name']
+
+        db.session.add(option)
+        db.session.commit()
+
+    return render_template(
+        'backend_vote/view.j2',
+        ballot=ballot,
+    )
+
+
+@BLUEPRINT.route('/<int:ballot_id>/add_question', methods=["GET", "POST"])
+@login_required
+def add_question(ballot_id):
+    """Add question to ballot"""
+    ballot = Ballot.query.get(ballot_id)
+    if request.method == 'POST':
+        question = Question()
+        question.ballot_id = ballot.id
+        question.name = request.form['name']
+        question.description = request.form['description']
+        question.combined_approval_voting = 'combined_approval_voting' in request.form
+
+        db.session.add(question)
+        db.session.commit()
+
+        if question.combined_approval_voting:
+            options = ['Voor', 'Tegen', 'Onthouden']
+            for option_name in options:
+                option = Option()
+                option.question_id = question.id
+                option.name = option_name
+
+                db.session.add(option)
+
+            db.session.commit()
+        return redirect(url_for('vote.view', ballot_id=ballot.id))
+
+    return render_template(
+        'backend_vote/add_question.j2',
+        ballot=ballot,
+    )

+ 0 - 0
app/modules/vote/templates/vote/add_question.j2 → app/modules/backend/modules/vote/templates/backend_vote/add_question.j2


+ 0 - 0
app/modules/vote/templates/vote/codes.j2 → app/modules/backend/modules/vote/templates/backend_vote/codes.j2


+ 0 - 0
app/modules/vote/templates/vote/create.j2 → app/modules/backend/modules/vote/templates/backend_vote/create.j2


+ 83 - 0
app/modules/backend/modules/vote/templates/backend_vote/view.j2

@@ -0,0 +1,83 @@
+{% extends "layout/backend.j2" %}
+{% block content %}
+<div class="row">
+	<div class="col-12 col-md">
+		<h1>Vote: {{ ballot.name }}</h1>
+	</div>
+	<div class="col-auto mb-3 text-right">
+		<a href="{{ url_for('backend_vote.add_question', ballot_id=ballot.id) }}"><button class="btn btn-secondary btn-sm">Add question</button></a>
+	</div>
+</div>
+<table class="table table-sm">
+	<tr>
+		<th scope="row">Description</th>
+		<td>{{ ballot.description }}</td>
+	</tr>
+	<tr>
+		<th scope="row">Start</th>
+		<td>{{ ballot.start_at }}</td>
+	</tr>
+	<tr>
+		<th scope="row">End</th>
+		<td>{{ ballot.end_at }}</td>
+	</tr>
+	{% if ballot.active() %}
+    <tr>
+        <th scope="row">Te gaan</th>
+        <td class="countdown" date="{{ ballot.end_at }}"><span class="hours">00</span>:<span class="minutes">00</span>:<span class="seconds">00</span></td>
+    </tr>
+    {% endif %}
+	<tr>
+		<th scope="row">User</th>
+		<td>{{ ballot.user.name }}</td>
+	</tr>
+	<tr>
+		<th scope="row">Priority</th>
+		<td>{{ ballot.priority.name }}</td>
+	</tr>
+</table>
+<div class="row">
+	{% for question in ballot.questions %}
+	<div class="col-md-6 mb-4">
+		<div class="card">
+			<div class="card-body">
+			    <h5 class="card-title">{{ question.name }}</h5>
+				{% if question.description %}
+			    <p class="card-text">{{ question.description }}</p>
+			    {% endif %}
+			    {% if question.combined_approval_voting %}
+			    <p class="card-text">Score: {{ question.score() }}</p>
+			    {% else %}
+			    <p class="card-text">Meeste stemmen: {{ question.score() }}</p>
+			    {% endif %}
+			</div>
+			{% if question.options.all() | count %}
+			<ul class="list-group list-group-flush">
+				{% for option in question.options %}
+				<li class="list-group-item d-flex justify-content-between align-items-center">
+					{{ option.name }}
+					<span class="badge badge-primary badge-pill">{{ option.votes.all() | count }}</span>
+				</li>
+				{% endfor %}
+			</ul>
+			{% else %}
+			<hr>
+			{% endif %}
+			{% if not question.combined_approval_voting %}
+			<div class="card-body">
+				<form class="row" method="post">
+					<input type="hidden" name="question_id" value="{{ question.id }}">
+					<div class="col">
+				    	<input type="text" class="form-control" name="name" placeholder="Option" required>
+					</div>
+					<div class="col-auto">
+					    <button type="submit" class="btn btn-primary">Add</button>
+					</div>
+				</form>
+			</div>
+			{% endif %}
+		</div>
+	</div>
+	{% endfor %}
+</div>
+{% endblock %}

+ 44 - 0
app/modules/backend/modules/vote/templates/main.j2

@@ -0,0 +1,44 @@
+{% extends "layout/backend.j2" %}
+{% block content %}
+<h1>Votes</h1>
+<div class="row">
+    <div class="col-sm">
+        <div class="card">
+            <div class="card-header">
+                Votes
+                <div class="float-right">
+                    <a href="{{ url_for('backend_vote.create') }}" class="btn btn-secondary btn-sm">Create</a>
+                </div>
+            </div>
+            <div class="card-body table-responsive">
+                <table class="table table-striped table-sm">
+                    <thead>
+                        <tr>
+                            <th></th>
+                            <th>Name</th>
+                            <th>Start</th>
+                            <th>End</th>
+                            <th>Priority</th>
+                            <th>Author</th>
+                        </tr>
+                    </thead>
+                    <tbody>
+                        {% for ballot in ballots %}
+                        <tr>
+                            <td>
+                                <a href="{{ url_for('backend_vote.view', ballot_id=ballot.id) }}"><button class="btn btn-secondary btn-sm">View</button></a>
+                            </td>
+                            <td>{{ ballot.name }}</td>
+                            <td>{{ ballot.start_at }}</td>
+                            <td>{{ ballot.end_at }}</td>
+                            <td>{{ ballot.priority.name }}</td>
+                            <td>{{ ballot.user.name }}</td>
+                        </tr>
+                        {%- endfor -%}
+                    </tbody>
+                </table>
+            </div>
+        </div>
+    </div>
+</div>
+{% endblock %}

+ 6 - 120
app/modules/vote/app.py

@@ -3,14 +3,8 @@
 Authentication module
 """
 
-import hashlib
-import hmac
-
-from datetime import datetime
-from flask_login import login_required, current_user
-from flask_menu import Menu, register_menu
 from flask import render_template, request, flash, Blueprint, redirect, url_for
-from app.models import User, Page, Ballot, Priority, Question, Option, Vote, Code
+from app.models import User, Ballot, Question, Option, Vote, Code
 from app import db
 
 
@@ -20,127 +14,19 @@ BLUEPRINT = Blueprint(
     template_folder='templates'
 )
 
-@register_menu(BLUEPRINT, 'vote', 'Vote')
-@BLUEPRINT.route("/")
-@login_required
-def main():
-    """Ballots overview"""
-    ballots = Ballot.query.all()
-
-    return render_template(
-        'main.j2',
-        ballots=ballots,
-    )
-
-
-@BLUEPRINT.route("/codes")
-@login_required
-def codes():
-    """codes overview"""
-    code = Code.query.order_by(Code.expire_date.desc()).first()
-    users = User.query.all()
-
-    return render_template(
-        'vote/codes.j2',
-        users=users,
-        code=code,
-    )
-
-
-@BLUEPRINT.route('/create', methods=["GET", "POST"])
-@login_required
-def create():
-    """Creating ballot"""
-    if request.method == 'POST':
-        ballot = Ballot()
-        print(request.form)
-        ballot.name = request.form['name']
-        ballot.description = request.form['description']
-        ballot.user_id = current_user.id
-
-        start_at = "%s %s" % (request.form['start_at_date'], request.form['start_at_time'])
-        ballot.start_at = datetime.strptime(start_at, "%Y-%m-%d %H:%M")
-        end_at = "%s %s" % (request.form['end_at_date'], request.form['end_at_time'])
-        ballot.end_at = datetime.strptime(end_at, "%Y-%m-%d %H:%M")
-
-        db.session.add(ballot)
-        db.session.commit()
-
-        flash('Page "%s" successfully created' % ballot.name, 'success')
-        return redirect(url_for('vote.view', ballot_id=ballot.id))
-
-    priorities = Priority.query.all()
-
-    return render_template(
-        'vote/create.j2',
-        priorities=priorities
-    )
-
-
-@BLUEPRINT.route('/<int:ballot_id>', methods=["GET", "POST"])
-@login_required
-def view(ballot_id):
-    """View ballot"""
-    ballot = Ballot.query.get(ballot_id)
-    if request.method == 'POST':
-        option = Option()
-        option.question_id = request.form['question_id']
-        option.name = request.form['name']
-
-        db.session.add(option)
-        db.session.commit()
-
-    return render_template(
-        'vote/view.j2',
-        ballot=ballot,
-    )
-
-
-@BLUEPRINT.route('/<int:ballot_id>/add_question', methods=["GET", "POST"])
-@login_required
-def add_question(ballot_id):
-    """Add question to ballot"""
-    ballot = Ballot.query.get(ballot_id)
-    if request.method == 'POST':
-        question = Question()
-        question.ballot_id = ballot.id
-        question.name = request.form['name']
-        question.description = request.form['description']
-        question.combined_approval_voting = 'combined_approval_voting' in request.form
-
-        db.session.add(question)
-        db.session.commit()
-
-        if question.combined_approval_voting:
-            options = ['Voor', 'Tegen', 'Onthouden']
-            for option_name in options:
-                option = Option()
-                option.question_id = question.id
-                option.name = option_name
-
-                db.session.add(option)
-
-            db.session.commit()
-        return redirect(url_for('vote.view', ballot_id=ballot.id))
-
-    return render_template(
-        'vote/add_question.j2',
-        ballot=ballot,
-    )
 
-
-@BLUEPRINT.route('/public/')
+@BLUEPRINT.route('/')
 def public_index():
     """View list of votes"""
     ballots = Ballot.query.all()
 
     return render_template(
-        'vote/public/index.j2',
+        'vote/index.j2',
         ballots=ballots,
     )
 
 
-@BLUEPRINT.route('/public/<int:ballot_id>', methods=["GET", "POST"])
+@BLUEPRINT.route('/<int:ballot_id>', methods=["GET", "POST"])
 def public_view(ballot_id):
     """Vote and view results of ballot"""
     ballot = Ballot.query.get(ballot_id)
@@ -160,7 +46,7 @@ def public_view(ballot_id):
                 question = Question.query.get(question_id)
                 if question.has_voten(user_id):
                     flash('Je hebt al gestemd.', 'warning')
-                    return redirect(url_for('vote.view', ballot_id=ballot.id))
+                    return redirect(url_for('backend_backend_vote.view', ballot_id=ballot.id))
 
                 option = question.options.filter(Option.id == option_id).first()
 
@@ -175,6 +61,6 @@ def public_view(ballot_id):
             flash('Fout in veiligheids code.', 'warning')
 
     return render_template(
-        'vote/public/view.j2',
+        'vote/view.j2',
         ballot=ballot,
     )

+ 0 - 0
app/modules/vote/templates/vote/public/index.j2 → app/modules/vote/templates/vote/index.j2


+ 0 - 106
app/modules/vote/templates/vote/public/view.j2

@@ -1,106 +0,0 @@
-{% extends "layout/public.j2" %}
-{% block head %}
-<title>{{ ballot.name }} - Democratic Assembly</title>
-{% endblock %}
-{% block content %}
-{% with messages = get_flashed_messages(with_categories=true) %}
-{% if messages %}
-{% for category, message in messages %}
-<div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
-    {{ message }}
-    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
-        <span aria-hidden="true">&times;</span>
-    </button>
-</div>
-{% endfor %}
-{% endif %}
-{% endwith %}
-<h1>{{ ballot.name }}</h1>
-<table class="table table-sm">
-    {% if ballot.description %}
-    <tr>
-        <th scope="row">Description</th>
-        <td>{{ ballot.description }}</td>
-    </tr>
-    {% endif %}
-    <tr>
-        <th scope="row">Start</th>
-        <td>{{ ballot.start_at }}</td>
-    </tr>
-    <tr>
-        <th scope="row">Eindigt</th>
-        <td>{{ ballot.end_at }}</td>
-    </tr>
-    {% if ballot.active() %}
-    <tr>
-        <th scope="row">Te gaan</th>
-        <td class="countdown" date="{{ ballot.end_at }}"><span class="hours">00</span>:<span class="minutes">00</span>:<span class="seconds">00</span></td>
-    </tr>
-    {% endif %}
-    <tr>
-        <th scope="row">Aangemaakt door</th>
-        <td>{{ ballot.user.name }}</td>
-    </tr>
-    {% if ballot.priority %}
-    <tr>
-        <th scope="row">Priority</th>
-        <td>{{ ballot.priority.name }}</td>
-    </tr>
-    {% endif %}
-</table>
-{% if ballot.active() %}
-<form method="post">
-    <div class="card mb-4">
-        <div class="card-body">
-            <h5 class="card-title">Controle code</h5>
-            <input type="text" class="form-control" name="security_code" placeholder="code" required>
-        </div>
-    </div>
-    {% for question in ballot.questions %}
-    <div class="card mb-4">
-        <div class="card-body">
-            <h5 class="card-title">{{ question.name }}</h5>
-            {% if question.description %}
-            <p class="card-text">{{ question.description }}</p>
-            {% endif %}
-            {% for option in question.options %}
-            <div class="form-check">
-                <input class="form-check-input" type="radio" name="{{ question.id }}" id="{{ "option_%s" % option.id }}" value="{{ option.id }}">
-                <label class="form-check-label" for="{{ "option_%s" % option.id }}">
-                    {{ option.name }}
-                </label>
-            </div>
-            {% endfor %}
-        </div>
-    </div>
-    {% endfor %}
-    <div class="form-group pull-right">
-        <button class="btn btn-primary" type="submit">Opslaan</button>
-    </div>
-</form>
-{% else %}
-{% for question in ballot.questions %}
-<div class="card mb-4">
-    <div class="card-body">
-        <h5 class="card-title">{{ question.name }}</h5>
-        {% if question.description %}
-        <p class="card-text">{{ question.description }}</p>
-        {% endif %}
-        {% if question.combined_approval_voting %}
-        <p class="card-text">Score: {{ question.score() }}</p>
-        {% else %}
-        <p class="card-text">Meeste stemmen: {{ question.score() }}</p>
-        {% endif %}
-    </div>
-    <ul class="list-group list-group-flush">
-        {% for option in question.options %}
-        <li class="list-group-item d-flex justify-content-between align-items-center">
-            {{ option.name }}
-            <span class="badge badge-primary badge-pill">{{ option.votes.all() | count }}</span>
-        </li>
-        {% endfor %}
-    </ul>
-</div>
-{% endfor %}
-{% endif %}
-{% endblock %}

+ 95 - 72
app/modules/vote/templates/vote/view.j2

@@ -1,83 +1,106 @@
-{% extends "layout/backend.j2" %}
+{% extends "layout/public.j2" %}
+{% block head %}
+<title>{{ ballot.name }} - Democratic Assembly</title>
+{% endblock %}
 {% block content %}
-<div class="row">
-	<div class="col-12 col-md">
-		<h1>Vote: {{ ballot.name }}</h1>
-	</div>
-	<div class="col-auto mb-3 text-right">
-		<a href="{{ url_for('vote.add_question', ballot_id=ballot.id) }}"><button class="btn btn-secondary btn-sm">Add question</button></a>
-	</div>
+{% with messages = get_flashed_messages(with_categories=true) %}
+{% if messages %}
+{% for category, message in messages %}
+<div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
+    {{ message }}
+    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
+        <span aria-hidden="true">&times;</span>
+    </button>
 </div>
+{% endfor %}
+{% endif %}
+{% endwith %}
+<h1>{{ ballot.name }}</h1>
 <table class="table table-sm">
-	<tr>
-		<th scope="row">Description</th>
-		<td>{{ ballot.description }}</td>
-	</tr>
-	<tr>
-		<th scope="row">Start</th>
-		<td>{{ ballot.start_at }}</td>
-	</tr>
-	<tr>
-		<th scope="row">End</th>
-		<td>{{ ballot.end_at }}</td>
-	</tr>
-	{% if ballot.active() %}
+    {% if ballot.description %}
+    <tr>
+        <th scope="row">Description</th>
+        <td>{{ ballot.description }}</td>
+    </tr>
+    {% endif %}
+    <tr>
+        <th scope="row">Start</th>
+        <td>{{ ballot.start_at }}</td>
+    </tr>
+    <tr>
+        <th scope="row">Eindigt</th>
+        <td>{{ ballot.end_at }}</td>
+    </tr>
+    {% if ballot.active() %}
     <tr>
         <th scope="row">Te gaan</th>
         <td class="countdown" date="{{ ballot.end_at }}"><span class="hours">00</span>:<span class="minutes">00</span>:<span class="seconds">00</span></td>
     </tr>
     {% endif %}
-	<tr>
-		<th scope="row">User</th>
-		<td>{{ ballot.user.name }}</td>
-	</tr>
-	<tr>
-		<th scope="row">Priority</th>
-		<td>{{ ballot.priority.name }}</td>
-	</tr>
+    <tr>
+        <th scope="row">Aangemaakt door</th>
+        <td>{{ ballot.user.name }}</td>
+    </tr>
+    {% if ballot.priority %}
+    <tr>
+        <th scope="row">Priority</th>
+        <td>{{ ballot.priority.name }}</td>
+    </tr>
+    {% endif %}
 </table>
-<div class="row">
-	{% for question in ballot.questions %}
-	<div class="col-md-6 mb-4">
-		<div class="card">
-			<div class="card-body">
-			    <h5 class="card-title">{{ question.name }}</h5>
-				{% if question.description %}
-			    <p class="card-text">{{ question.description }}</p>
-			    {% endif %}
-			    {% if question.combined_approval_voting %}
-			    <p class="card-text">Score: {{ question.score() }}</p>
-			    {% else %}
-			    <p class="card-text">Meeste stemmen: {{ question.score() }}</p>
-			    {% endif %}
-			</div>
-			{% if question.options.all() | count %}
-			<ul class="list-group list-group-flush">
-				{% for option in question.options %}
-				<li class="list-group-item d-flex justify-content-between align-items-center">
-					{{ option.name }}
-					<span class="badge badge-primary badge-pill">{{ option.votes.all() | count }}</span>
-				</li>
-				{% endfor %}
-			</ul>
-			{% else %}
-			<hr>
-			{% endif %}
-			{% if not question.combined_approval_voting %}
-			<div class="card-body">
-				<form class="row" method="post">
-					<input type="hidden" name="question_id" value="{{ question.id }}">
-					<div class="col">
-				    	<input type="text" class="form-control" name="name" placeholder="Option" required>
-					</div>
-					<div class="col-auto">
-					    <button type="submit" class="btn btn-primary">Add</button>
-					</div>
-				</form>
-			</div>
-			{% endif %}
-		</div>
-	</div>
-	{% endfor %}
+{% if ballot.active() %}
+<form method="post">
+    <div class="card mb-4">
+        <div class="card-body">
+            <h5 class="card-title">Controle code</h5>
+            <input type="text" class="form-control" name="security_code" placeholder="code" required>
+        </div>
+    </div>
+    {% for question in ballot.questions %}
+    <div class="card mb-4">
+        <div class="card-body">
+            <h5 class="card-title">{{ question.name }}</h5>
+            {% if question.description %}
+            <p class="card-text">{{ question.description }}</p>
+            {% endif %}
+            {% for option in question.options %}
+            <div class="form-check">
+                <input class="form-check-input" type="radio" name="{{ question.id }}" id="{{ "option_%s" % option.id }}" value="{{ option.id }}">
+                <label class="form-check-label" for="{{ "option_%s" % option.id }}">
+                    {{ option.name }}
+                </label>
+            </div>
+            {% endfor %}
+        </div>
+    </div>
+    {% endfor %}
+    <div class="form-group pull-right">
+        <button class="btn btn-primary" type="submit">Opslaan</button>
+    </div>
+</form>
+{% else %}
+{% for question in ballot.questions %}
+<div class="card mb-4">
+    <div class="card-body">
+        <h5 class="card-title">{{ question.name }}</h5>
+        {% if question.description %}
+        <p class="card-text">{{ question.description }}</p>
+        {% endif %}
+        {% if question.combined_approval_voting %}
+        <p class="card-text">Score: {{ question.score() }}</p>
+        {% else %}
+        <p class="card-text">Meeste stemmen: {{ question.score() }}</p>
+        {% endif %}
+    </div>
+    <ul class="list-group list-group-flush">
+        {% for option in question.options %}
+        <li class="list-group-item d-flex justify-content-between align-items-center">
+            {{ option.name }}
+            <span class="badge badge-primary badge-pill">{{ option.votes.all() | count }}</span>
+        </li>
+        {% endfor %}
+    </ul>
 </div>
+{% endfor %}
+{% endif %}
 {% endblock %}