Enable Mark Done from task_detail
This commit is contained in:
parent
0992c43d8b
commit
c03bc3579c
2 changed files with 10 additions and 4 deletions
|
@ -8,8 +8,7 @@ from django.core.mail import send_mail
|
|||
from django.http import HttpResponse
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
|
||||
from todo.models import Item, TaskList, Comment
|
||||
from todo.models import Item, Comment
|
||||
|
||||
|
||||
def check_user_allowed(user: User) -> HttpResponse:
|
||||
|
@ -25,7 +24,10 @@ def check_user_allowed(user: User) -> HttpResponse:
|
|||
|
||||
|
||||
def toggle_done(request, items):
|
||||
# Check for items in the mark_done POST array. If present, change status to complete.
|
||||
"""Check for items in the mark_done POST array. If present, change status to complete.
|
||||
Takes a list of task IDs. No return value.
|
||||
"""
|
||||
|
||||
for item in items:
|
||||
i = Item.objects.get(id=item)
|
||||
old_state = "completed" if i.completed else "incomplete"
|
||||
|
|
|
@ -194,11 +194,15 @@ def task_detail(request, task_id: int) -> HttpResponse:
|
|||
if form.is_valid():
|
||||
form.save()
|
||||
messages.success(request, "The task has been edited.")
|
||||
|
||||
return redirect('todo:list_detail', list_id=task.task_list.id, list_slug=task.task_list.slug)
|
||||
else:
|
||||
form = AddEditItemForm(request.user, instance=task, initial={'task_list': task.task_list})
|
||||
|
||||
# Mark complete
|
||||
if request.POST.get('toggle_done'):
|
||||
toggle_done(request, [task.id, ])
|
||||
return redirect('todo:task_detail', task_id=task.id,)
|
||||
|
||||
if task.due_date:
|
||||
thedate = task.due_date
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue