Private tasks ok

This commit is contained in:
Justine Pelletreau 2022-11-18 17:33:11 +01:00
parent 8531c141d7
commit e96ae59b7e
3 changed files with 31 additions and 10 deletions

View File

@ -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)

View File

@ -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)

View File

@ -28,6 +28,11 @@
<summary>Click to expand.</summary>
<p>
{{ npers }}
<hr>
<h2 class="separator">Private and done</h2>
<hr>
{{ ndone_pers }}
</p>
</details>
<hr>