From 6f28d2bb95b97c995fe5267eed6641f5f700b49f Mon Sep 17 00:00:00 2001 From: LeeEnck Date: Mon, 30 Mar 2020 14:24:43 -0400 Subject: [PATCH 1/7] I updated the setup.py --- setup.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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', ) - From 074b732ec32481686a913abd23426d6461eb6c6d Mon Sep 17 00:00:00 2001 From: LeeEnck Date: Tue, 31 Mar 2020 12:56:53 -0400 Subject: [PATCH 2/7] Added some css to the feature, and made a filter class in the index, also made the routing in todos.py --- flasktodo/static/style.css | 5 +++++ flasktodo/templates/index.html | 5 ++++- flasktodo/todos.py | 31 ++++++++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 4 deletions(-) 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..311ec9e 100644 --- a/flasktodo/templates/index.html +++ b/flasktodo/templates/index.html @@ -2,7 +2,10 @@ {% block content %}

A simple to-do application

- +
+
  • Completed
  • +
  • Uncompleted
  • +
  • All
    • {% for todo in todos %}
    • diff --git a/flasktodo/todos.py b/flasktodo/todos.py index 40d871b..03132b5 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 - +import datetime 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,27 @@ 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) From d06f32f58f7a701ffe8d5c5ca884a0c48e2c90d5 Mon Sep 17 00:00:00 2001 From: LeeEnck Date: Tue, 31 Mar 2020 13:18:45 -0400 Subject: [PATCH 3/7] fixed a few bugs in todos.py --- flasktodo/todos.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flasktodo/todos.py b/flasktodo/todos.py index 03132b5..e31283b 100644 --- a/flasktodo/todos.py +++ b/flasktodo/todos.py @@ -1,8 +1,8 @@ from flask import ( Blueprint, flash, g, redirect, render_template, request, url_for +) from . import db -import datetime bp = Blueprint("todos", __name__) @@ -17,7 +17,7 @@ def index(): return render_template("index.html", todos=todos) -@bp.route("/completed", methods=('GET', 'POST')) +@bp.route("/completed", methods=['GET', 'POST']) def completed(): @@ -30,7 +30,7 @@ def completed(): return render_template("index.html", todos=todos) -@bp.route("uncompleted", methods=('GET')) +@bp.route("/uncompleted", methods=['GET']) def uncompleted(): From e2c367fe826f2efe239f3ae70a12a161d35940a4 Mon Sep 17 00:00:00 2001 From: LeeEnck Date: Tue, 31 Mar 2020 14:14:33 -0400 Subject: [PATCH 4/7] Wrote a test for the filter feature --- tests/test_todos.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 From 5fba35a27042296baf096694329a925d9a217487 Mon Sep 17 00:00:00 2001 From: LeeEnck Date: Tue, 31 Mar 2020 16:07:19 -0400 Subject: [PATCH 5/7] I made a new brnach called --- flasktodo/templates/index.html | 1 + flasktodo/todos.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/flasktodo/templates/index.html b/flasktodo/templates/index.html index 311ec9e..6a6d0d5 100644 --- a/flasktodo/templates/index.html +++ b/flasktodo/templates/index.html @@ -10,6 +10,7 @@

      A simple to-do application

      {% for todo in todos %}
    • {{ todo['description'] }} + Done
    • {% endfor %}
    diff --git a/flasktodo/todos.py b/flasktodo/todos.py index e31283b..6bb2305 100644 --- a/flasktodo/todos.py +++ b/flasktodo/todos.py @@ -41,3 +41,23 @@ def uncompleted(): cur.close() return render_template("index.html", todos=todos) + + +@bp.route("//done", methods=('GET', '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 complete = True' + ' WHERE id= %s ', + (id,) + ) + g.db.commit() + + cur.execute('SELECT * FROM todos') + todos = cur.fetchall() + cur.close() + + return redirect(url_for('todos.index')) From cf65ff38a7fd36dc6a09e7f02a014ed773f5a4e6 Mon Sep 17 00:00:00 2001 From: LeeEnck Date: Tue, 31 Mar 2020 16:09:22 -0400 Subject: [PATCH 6/7] Made a branch called markitem and initialized a route in todos.py and made it so it will update a task and set it to complete --- docs/user-stories.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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. - From 0afd529551cd8f81f2e7ad6faf53217e366c2617 Mon Sep 17 00:00:00 2001 From: LeeEnck Date: Wed, 1 Apr 2020 14:55:40 -0400 Subject: [PATCH 7/7] Made a form for marking items, and a done button --- flasktodo/templates/index.html | 4 +++- flasktodo/todos.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/flasktodo/templates/index.html b/flasktodo/templates/index.html index 6a6d0d5..32bd041 100644 --- a/flasktodo/templates/index.html +++ b/flasktodo/templates/index.html @@ -10,7 +10,9 @@

    A simple to-do application

    {% for todo in todos %}
  • {{ todo['description'] }} - Done +
    + +
  • {% endfor %} diff --git a/flasktodo/todos.py b/flasktodo/todos.py index 6bb2305..f4cea8a 100644 --- a/flasktodo/todos.py +++ b/flasktodo/todos.py @@ -43,14 +43,14 @@ def uncompleted(): return render_template("index.html", todos=todos) -@bp.route("//done", methods=('GET', 'POST')) +@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 complete = True' + 'UPDATE todos SET completed = True' ' WHERE id= %s ', (id,) )