diff --git a/docs/user-stories.md b/docs/user-stories.md
index 7051c64..2a85cb6 100644
--- a/docs/user-stories.md
+++ b/docs/user-stories.md
@@ -2,10 +2,9 @@
- [X] As a user, I want to see a list of my to-do items to know what to work on.
- [ ] As a user, I want to submit a form to add new items to my list.
-- [ ] As a user, I want to filter the list of items to see completed tasks, uncompleted tasks, or all tasks.
-- [ ] As a user, I want to click a button to mark an item as done.
+- [X] As a user, I want to filter the list of items to see completed tasks, uncompleted tasks, or all tasks.
+- [ ] As a user, I want to click a button to mark an item as done.
- [ ] As a user, I want to delete a task in case I don't need to do it anymore.
- [ ] As a user, I want to edit a task description so I can change what I already entered.
- [ ] As an anonymous user, I want to register with an email and password so that I can login.
- [ ] As a logged in user, I want to see only my tasks to keep them private.
-
diff --git a/flasktodo/static/style.css b/flasktodo/static/style.css
index c96c787..f48e024 100644
--- a/flasktodo/static/style.css
+++ b/flasktodo/static/style.css
@@ -25,3 +25,8 @@ li.completed {
text-decoration: line-through;
}
+div.filter {
+ display: flex;
+ list-style: none;
+ justify-content: space-around;
+}
diff --git a/flasktodo/templates/index.html b/flasktodo/templates/index.html
index 3f89835..32bd041 100644
--- a/flasktodo/templates/index.html
+++ b/flasktodo/templates/index.html
@@ -2,11 +2,17 @@
{% block content %}
A simple to-do application
-
+
+
Completed
+
Uncompleted
+
All
{% for todo in todos %}
-
{{ todo['description'] }}
+
{% endfor %}
diff --git a/flasktodo/todos.py b/flasktodo/todos.py
index 40d871b..f4cea8a 100644
--- a/flasktodo/todos.py
+++ b/flasktodo/todos.py
@@ -1,11 +1,12 @@
-from flask import Blueprint, render_template
+from flask import (
+ Blueprint, flash, g, redirect, render_template, request, url_for
+)
from . import db
-
bp = Blueprint("todos", __name__)
-@bp.route("/")
+@bp.route("/", methods=('GET', 'POST'))
def index():
"""View for home page which shows list of to-do items."""
@@ -16,3 +17,47 @@ def index():
return render_template("index.html", todos=todos)
+@bp.route("/completed", methods=['GET', 'POST'])
+def completed():
+
+
+ cur = db.get_db().cursor()
+
+ cur.execute('SELECT * FROM todos WHERE completed = True')
+ todos = cur.fetchall()
+ cur.close()
+
+ return render_template("index.html", todos=todos)
+
+
+@bp.route("/uncompleted", methods=['GET'])
+def uncompleted():
+
+
+ cur = db.get_db().cursor()
+
+ cur.execute('SELECT * FROM todos WHERE completed = FALSE')
+ todos = cur.fetchall()
+ cur.close()
+
+ return render_template("index.html", todos=todos)
+
+
+@bp.route("/
/done", methods=('POST' ,))
+def done(id):
+ """This sets a task to completed"""
+ cur = db.get_db().cursor()
+
+ # Update the individual task and sets it to complete
+ cur.execute(
+ 'UPDATE todos SET completed = True'
+ ' WHERE id= %s ',
+ (id,)
+ )
+ g.db.commit()
+
+ cur.execute('SELECT * FROM todos')
+ todos = cur.fetchall()
+ cur.close()
+
+ return redirect(url_for('todos.index'))
diff --git a/setup.py b/setup.py
index 1c6e771..aa21aa6 100644
--- a/setup.py
+++ b/setup.py
@@ -7,9 +7,9 @@
setuptools.setup(
name="flasktodo",
version="0.0.1",
- author="Zach Fedor",
- author_email="zachfedor@gmail.com",
- url="https://github.com/ts-cset/flask-todo",
+ author="Lee Enck",
+ author_email="eaglesfootball33@gmail.com",
+ url="https://github.com/LeeEnck/flask-todo",
description="A simple to-do application",
long_description=long_description,
long_description_content_type="text/markdown",
@@ -18,4 +18,3 @@
tests_require=['pytest'],
python_requires='>=3.6',
)
-
diff --git a/tests/test_todos.py b/tests/test_todos.py
index ed94a73..c94c51a 100644
--- a/tests/test_todos.py
+++ b/tests/test_todos.py
@@ -10,3 +10,14 @@ def test_todo_list(client):
assert response.data.count(b'') == 2
assert response.data.count(b'') == 1
+def test_completed(client):
+ response = client.get('/completed')
+ assert b'clean room' not in response.data
+
+ assert response.data.count(b'') == 1
+
+def test_uncompleted(client):
+ response = client.get('/uncompleted')
+ assert b'clean room' not in response.data
+
+ assert response.data.count(b'') == 0