Rename Item model to Task

- With matching model, view, template changes
This commit is contained in:
Scot Hacker 2018-03-28 22:51:10 -07:00
parent a2d02b0a8c
commit d3d8d5e46c
15 changed files with 133 additions and 119 deletions

View file

@ -2,7 +2,7 @@ import pytest
from django.contrib.auth.models import Group
from todo.models import Item, TaskList
from todo.models import Task, TaskList
@pytest.fixture
@ -13,14 +13,14 @@ def todo_setup(django_user_model):
u1 = django_user_model.objects.create_user(username="u1", password="password", email="u1@example.com")
u1.groups.add(g1)
tlist1 = TaskList.objects.create(group=g1, name="Zip", slug="zip")
Item.objects.create(created_by=u1, title="Task 1", task_list=tlist1, priority=1)
Item.objects.create(created_by=u1, title="Task 2", task_list=tlist1, priority=2, completed=True)
Item.objects.create(created_by=u1, title="Task 3", task_list=tlist1, priority=3)
Task.objects.create(created_by=u1, title="Task 1", task_list=tlist1, priority=1)
Task.objects.create(created_by=u1, title="Task 2", task_list=tlist1, priority=2, completed=True)
Task.objects.create(created_by=u1, title="Task 3", task_list=tlist1, priority=3)
g2 = Group.objects.create(name="Workgroup Two")
u2 = django_user_model.objects.create_user(username="u2", password="password", email="u2@example.com")
u2.groups.add(g2)
tlist2 = TaskList.objects.create(group=g2, name="Zap", slug="zap")
Item.objects.create(created_by=u2, title="Task 1", task_list=tlist2, priority=1)
Item.objects.create(created_by=u2, title="Task 2", task_list=tlist2, priority=2, completed=True)
Item.objects.create(created_by=u2, title="Task 3", task_list=tlist2, priority=3)
Task.objects.create(created_by=u2, title="Task 1", task_list=tlist2, priority=1)
Task.objects.create(created_by=u2, title="Task 2", task_list=tlist2, priority=2, completed=True)
Task.objects.create(created_by=u2, title="Task 3", task_list=tlist2, priority=3)

View file

@ -2,7 +2,7 @@ import pytest
from django.core import mail
from todo.models import Item, Comment
from todo.models import Task, Comment
from todo.utils import toggle_done, toggle_deleted, send_notify_mail, send_email_to_thread_participants
@ -15,7 +15,7 @@ def email_backend_setup(settings):
def test_toggle_done(todo_setup):
"""Utility function takes an array of POSTed IDs and changes their `completed` status.
"""
u1_tasks = Item.objects.filter(created_by__username="u1")
u1_tasks = Task.objects.filter(created_by__username="u1")
completed = u1_tasks.filter(completed=True)
incomplete = u1_tasks.filter(completed=False)
@ -38,13 +38,13 @@ def test_toggle_done(todo_setup):
def test_toggle_deleted(todo_setup):
"""Unlike toggle_done, delete means delete, so it's not really a toggle.
"""
u1_tasks = Item.objects.filter(created_by__username="u1")
u1_tasks = Task.objects.filter(created_by__username="u1")
assert u1_tasks.count() == 3
t1 = u1_tasks.first()
t2 = u1_tasks.last()
toggle_deleted([t1.id, t2.id, ])
u1_tasks = Item.objects.filter(created_by__username="u1")
u1_tasks = Task.objects.filter(created_by__username="u1")
assert u1_tasks.count() == 1
@ -56,7 +56,7 @@ def test_send_notify_mail_not_me(todo_setup, django_user_model, email_backend_se
u1 = django_user_model.objects.get(username="u1")
u2 = django_user_model.objects.get(username="u2")
task = Item.objects.filter(created_by=u1).first()
task = Task.objects.filter(created_by=u1).first()
task.assigned_to = u2
task.save()
send_notify_mail(task)
@ -68,7 +68,7 @@ def test_send_notify_mail_myself(todo_setup, django_user_model, email_backend_se
"""
u1 = django_user_model.objects.get(username="u1")
task = Item.objects.filter(created_by=u1).first()
task = Task.objects.filter(created_by=u1).first()
task.assigned_to = u1
task.save()
send_notify_mail(task)
@ -80,7 +80,7 @@ def test_send_email_to_thread_participants(todo_setup, django_user_model, email_
Notification email should be sent to all three users."""
u1 = django_user_model.objects.get(username="u1")
task = Item.objects.filter(created_by=u1).first()
task = Task.objects.filter(created_by=u1).first()
u3 = django_user_model.objects.create_user(username="u3", password="zzz", email="u3@example.com")
u4 = django_user_model.objects.create_user(username="u4", password="zzz", email="u4@example.com")

View file

@ -3,7 +3,7 @@ import pytest
from django.contrib.auth.models import Group
from django.urls import reverse
from todo.models import Item, TaskList
from todo.models import Task, TaskList
"""
First the "smoketests" - do they respond at all for a logged in admin user?
@ -15,7 +15,7 @@ After that, view contents and behaviors.
@pytest.mark.django_db
def test_todo_setup(todo_setup):
assert Item.objects.all().count() == 6
assert Task.objects.all().count() == 6
def test_view_list_lists(todo_setup, admin_client):
@ -73,7 +73,7 @@ def test_view_add_list(todo_setup, admin_client):
def test_view_task_detail(todo_setup, admin_client):
task = Item.objects.first()
task = Task.objects.first()
url = reverse('todo:task_detail', kwargs={'task_id': task.id})
response = admin_client.get(url)
assert response.status_code == 200
@ -131,7 +131,7 @@ def test_view_list_not_mine(todo_setup, client):
def test_view_task_mine(todo_setup, client):
# Users can always view their own tasks
task = Item.objects.filter(created_by__username="u1").first()
task = Task.objects.filter(created_by__username="u1").first()
client.login(username="u1", password="password")
url = reverse('todo:task_detail', kwargs={'task_id': task.id})
response = client.get(url)
@ -147,7 +147,7 @@ def test_view_task_my_group(todo_setup, client, django_user_model):
u2.groups.add(g1)
# Now u2 should be able to view one of u1's tasks.
task = Item.objects.filter(created_by__username="u1").first()
task = Task.objects.filter(created_by__username="u1").first()
url = reverse('todo:task_detail', kwargs={'task_id': task.id})
client.login(username="u2", password="password")
response = client.get(url)
@ -157,7 +157,7 @@ def test_view_task_my_group(todo_setup, client, django_user_model):
def test_view_task_not_in_my_group(todo_setup, client):
# User canNOT view a task that isn't theirs if the two users are not in a shared group.
# For this we can use the fixture data as-is.
task = Item.objects.filter(created_by__username="u1").first()
task = Task.objects.filter(created_by__username="u1").first()
url = reverse('todo:task_detail', kwargs={'task_id': task.id})
client.login(username="u2", password="password")
response = client.get(url)