def setUp(self): self.user = User.objects.create_user('test', '*****@*****.**', 'test123') self.tasklist = Todo(description='hello this is testing', creator=self.user) self.tasklist.save() self.client.login(username='******', password='******')
def test_count_todos(self): self.assertEqual(self.todolist.count(), 1) new_todo = Todo(description='test', todolist_id=self.todolist.id, creator=self.user) new_todo.save() self.assertEqual(self.todolist.count(), 2)
def test_saving_and_retreiving_items(self): todo = Todo() todo.save() first_item = Item() first_item.text = 'The first (ever) list item' first_item.todo = todo first_item.save() second_item = Item() second_item.text = 'Item the second' second_item.todo = todo second_item.save() saved_todo = Todo.objects.first() self.assertEqual(saved_todo, todo) saved_items = Item.objects.all() self.assertEqual(saved_items.count(), 2) first_saved_item = saved_items[0] second_saved_item = saved_items[1] self.assertEqual(first_saved_item.text, 'The first (ever) list item') self.assertEqual(first_saved_item.todo, todo) self.assertEqual(second_saved_item.text, 'Item the second') self.assertEqual(second_saved_item.todo, todo)
def setUp(self): self.user = User.objects.create_user("test", "*****@*****.**", "test") self.todolist = TodoList(title="title", creator=self.user) self.todolist.save() self.todo = Todo( description="description", todolist_id=self.todolist.id, creator=self.user ) self.todo.save()
def setUp(self): self.user = User.objects.create_user('test', '*****@*****.**', 'test') self.todolist = TodoList(title='title', creator=self.user) self.todolist.save() self.todo = Todo(description='description', todolist_id=self.todolist.id, creator=self.user) self.todo.save()
def test_count_open_todos(self): self.assertEqual(self.todolist.count_open(), 1) new_todo = Todo( description="test", todolist_id=self.todolist.id, creator=self.user ) new_todo.save() self.assertEqual(self.todolist.count_open(), 2) new_todo.close() self.assertEqual(self.todolist.count_open(), 1)
def setUp(self): self.user = User.objects.create_user("test", "*****@*****.**", "test") self.todolist = TodoList(title="test title", creator=self.user) self.todolist.save() self.todo = Todo( description="save todo", todolist_id=self.todolist.id, creator=self.user ) self.todo.save() self.client.login(username="******", password="******")
def setUp(self): self.user = User.objects.create_user('test', '*****@*****.**', 'test') self.todolist = TodoList(title='test title', creator=self.user) self.todolist.save() self.todo = Todo(description='save todo', todolist_id=self.todolist.id, creator=self.user) self.todo.save() self.client.login(username='******', password='******')
def test_count_closed_todos(self): self.assertEqual(self.todolist.count_finished(), 0) new_todo = Todo(description='test', todolist_id=self.todolist.id, creator=self.user) new_todo.close() self.todo.close() self.assertEqual(self.todolist.count_finished(), 2) self.assertIsNotNone(new_todo.finished_at) self.todo.reopen() self.assertEqual(self.todolist.count_finished(), 1) self.assertIsNone(self.todo.finished_at)
def add_todo(request, todolist_id): if request.method == 'POST': form = TodoForm(request.POST) if form.is_valid(): user = request.user if request.user.is_authenticated else None todo = Todo(description=request.POST['description'], todolist_id=todolist_id, creator=user) todo.save() return redirect('lists:todolist', todolist_id=todolist_id) else: return render(request, 'lists/todolist.html', {'form': form}) return redirect('lists:index')
def add_todo(request, todolist_id): if request.method == "POST": form = TodoForm(request.POST) if form.is_valid(): user = request.user if request.user.is_authenticated else None todo = Todo( description=request.POST["description"], todolist_id=todolist_id, creator=user, ) todo.save() return redirect("lists:todolist", todolist_id=todolist_id) else: return render(request, "lists/todolist.html", {"form": form}) return redirect("lists:index")
def new_todolist(request): if request.method == 'POST': form = TodoForm(request.POST) if form.is_valid(): # create default todolist user = request.user if request.user.is_authenticated() else None todolist = TodoList(creator=user) todolist.save() todo = Todo(description=request.POST['description'], summary=request.POST['summary'], todolist_id=todolist.id, creator=user) todo.save() return redirect('lists:todolist', todolist_id=todolist.id) else: return render(request, 'lists/index.html', {'form': form}) return redirect('lists:index')
def add_todo(request, todolist_id): if request.method == 'POST': todolist = get_object_or_404(TodoList, pk=todolist_id) form = TodoForm(request.POST) if form.is_valid(): user = request.user due_date = form.cleaned_data['due_date'] todo = Todo(description=request.POST['description'], todolist_id=todolist_id, due_date=due_date, creator=user) todo.save() return redirect('lists:todolist', todolist_id=todolist_id) else: return render(request, 'lists/todolist.html', { 'form': form, 'todolist': todolist }) return redirect('lists:index')
def create_task(request): """function of creating task list with task title, task description and task level""" all_task_list = Todo.objects.all() form = TaskForm() if request.method == 'POST': form = TaskForm(request.POST) if form.is_valid(): # create default todolist user = request.user if request.user.is_authenticated else None task = Todo(description=request.POST['description'], content=request.POST['content'], tesk_medium=request.POST['tesk_medium'], creator=user) task.save() return redirect('lists:alllist') else: return render(request, 'lists/index.html', {'form': form}) context = {'form': form, 'taskli': all_task_list} return render(request, 'lists/create_task.html', context)