From 242067e46ca2e443ef8ae3eea6c50103f0b1da4c Mon Sep 17 00:00:00 2001 From: james1293 Date: Thu, 11 Jul 2019 16:28:46 -0400 Subject: [PATCH] Only set creator when creating task --- todo/models.py | 1 + todo/templates/todo/include/task_edit.html | 1 - todo/views/list_detail.py | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/todo/models.py b/todo/models.py index 60ab220..7b44e36 100644 --- a/todo/models.py +++ b/todo/models.py @@ -80,6 +80,7 @@ class Task(models.Model): null=True, related_name="todo_created_by", on_delete=models.CASCADE, + editable=False, ) assigned_to = models.ForeignKey( settings.AUTH_USER_MODEL, diff --git a/todo/templates/todo/include/task_edit.html b/todo/templates/todo/include/task_edit.html index 078d25d..1c8242f 100644 --- a/todo/templates/todo/include/task_edit.html +++ b/todo/templates/todo/include/task_edit.html @@ -44,7 +44,6 @@ -

diff --git a/todo/views/list_detail.py b/todo/views/list_detail.py index 4f9c337..6760fb9 100644 --- a/todo/views/list_detail.py +++ b/todo/views/list_detail.py @@ -51,6 +51,7 @@ def list_detail(request, list_id=None, list_slug=None, view_completed=False) -> if form.is_valid(): new_task = form.save(commit=False) + new_task.created_by = request.user new_task.created_date = timezone.now() new_task.note = bleach.clean(form.cleaned_data["note"], strip=True) form.save()