From e96ae59b7edd17bf44a73da942312286fe5127b1 Mon Sep 17 00:00:00 2001
From: Justine Pelletreau
Date: Fri, 18 Nov 2022 17:33:11 +0100
Subject: [PATCH] Private tasks ok
---
src/app.py | 12 ++++++------
src/funcs.py | 24 ++++++++++++++++++++----
src/templates/homepage.html | 5 +++++
3 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/src/app.py b/src/app.py
index 4f4888a..cd79a5e 100755
--- a/src/app.py
+++ b/src/app.py
@@ -32,13 +32,13 @@ def render():
#...or using their preferred theme if do have one
else:
csslink = request.cookies.get('csslink')
- resp = make_response(render_template("homepage.html", ntodo = todotasks(gettasks()), npers = personnaltasks(gettasks()), ndone = donetasks(gettasks()), csslink = csslink))
+ resp = make_response(render_template("homepage.html", ntodo = todotasks(gettasks()), npers = personnaltasks(gettasks()), ndone = donetasks(gettasks()), ndone_pers = donetasks_pers(gettasks()), csslink = csslink))
#Delete has been clicked
if request.args.get("delete") is not None:
todelete = request.args.get("delete")
deltask(int(todelete))
- resp = make_response(render_template("homepage.html", ntodo = todotasks(gettasks()), npers = personnaltasks(gettasks()), ndone = donetasks(gettasks()), csslink = csslink))
+ resp = make_response(render_template("homepage.html", ntodo = todotasks(gettasks()), npers = personnaltasks(gettasks()), ndone = donetasks(gettasks()), ndone_pers = donetasks_pers(gettasks()), csslink = csslink))
#Edit has been clicked
elif request.args.get("edit") is not None:
@@ -71,9 +71,9 @@ def render():
mytask = switchstatus(mytask)
deltask(toswitch)
addtask(mytask)
- resp = make_response(render_template("homepage.html", ntodo = todotasks(gettasks()), npers = personnaltasks(gettasks()), ndone = donetasks(gettasks()), csslink = csslink))
+ resp = make_response(render_template("homepage.html", ntodo = todotasks(gettasks()), npers = personnaltasks(gettasks()), ndone = donetasks(gettasks()), ndone_pers = donetasks_pers(gettasks()), csslink = csslink))
else:
- resp = make_response(render_template("homepage.html", ntodo = todotasks(gettasks()), npers = personnaltasks(gettasks()), ndone = donetasks(gettasks()), csslink = csslink))
+ resp = make_response(render_template("homepage.html", ntodo = todotasks(gettasks()), npers = personnaltasks(gettasks()), ndone = donetasks(gettasks()), ndone_pers = donetasks_pers(gettasks()), csslink = csslink))
return resp
@@ -104,7 +104,7 @@ def homepage():
except Exception as E:
print(f"!!!!!!!!!! {E} - {request.form}")
pass
- return render_template("homepage.html", ntodo = todotasks(gettasks()), npers = personnaltasks(gettasks()), ndone = donetasks(gettasks()), csslink = csslink)
+ return render_template("homepage.html", ntodo = todotasks(gettasks()), npers = personnaltasks(gettasks()), ndone = donetasks(gettasks()), ndone_pers = donetasks_pers(gettasks()), csslink = csslink)
#Export mode
@@ -161,7 +161,7 @@ def edit():
rightnow = int(time.time())
newtask = task(createtime=tasknumber, modtime=rightnow, title=tasktitle, text=tasktext, done=taskdone, priority=taskpriority, personnal = personnal)
addtask(newtask)
- return render_template("homepage.html", ntodo = todotasks(gettasks()), npers = personnaltasks(gettasks()), ndone = donetasks(gettasks()), csslink = csslink)
+ return render_template("homepage.html", ntodo = todotasks(gettasks()), npers = personnaltasks(gettasks()), ndone = donetasks(gettasks()), ndone_pers = donetasks_pers(gettasks()), csslink = csslink)
diff --git a/src/funcs.py b/src/funcs.py
index bbc2cf2..e2362c0 100644
--- a/src/funcs.py
+++ b/src/funcs.py
@@ -132,7 +132,7 @@ def switchstatus(task):
def todotasks(tasklist):
"""
- Sorts tasks in tasklist: Gives todotasks sorted by priority
+ Sorts tasks in tasklist: Gives todotasks that are not private sorted by priority
"""
buffer = []
finalstr = ""
@@ -148,7 +148,7 @@ def todotasks(tasklist):
def personnaltasks(tasklist):
"""
- Sorts tasks in tasklist: Gives todotasks sorted by priority
+ Sorts tasks in tasklist: Gives todotasks that are private sorted by priority
"""
buffer = []
finalstr = ""
@@ -164,12 +164,28 @@ def personnaltasks(tasklist):
def donetasks(tasklist):
"""
- Sorts tasks in tasklist: Gives done tasks sorted by modtime
+ Sorts tasks in tasklist: Gives public done tasks sorted by modtime
"""
buffer = []
finalstr = ""
for task in tasklist:
- if task.donemark == "✅":
+ if task.donemark == "✅" and not task.personnal:
+ buffer.append(task)
+
+ tasks = sorted(buffer, key=lambda task: task.modtime, reverse=True)
+ for task in tasks:
+ finalstr += task.flaskrender()
+
+ return finalstr
+
+def donetasks_pers(tasklist):
+ """
+ Sorts tasks in tasklist: Gives public done tasks sorted by modtime
+ """
+ buffer = []
+ finalstr = ""
+ for task in tasklist:
+ if task.donemark == "✅" and task.personnal:
buffer.append(task)
tasks = sorted(buffer, key=lambda task: task.modtime, reverse=True)
diff --git a/src/templates/homepage.html b/src/templates/homepage.html
index 8e871a0..dbc36e1 100644
--- a/src/templates/homepage.html
+++ b/src/templates/homepage.html
@@ -28,6 +28,11 @@
Click to expand.
{{ npers }}
+
+ Private and done
+
+ {{ ndone_pers }}
+