当前位置: 首页>>代码示例>>Python>>正文


Python Task.save方法代码示例

本文整理汇总了Python中task.models.Task.save方法的典型用法代码示例。如果您正苦于以下问题:Python Task.save方法的具体用法?Python Task.save怎么用?Python Task.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在task.models.Task的用法示例。


在下文中一共展示了Task.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_mark_task_done

# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import save [as 别名]
 def test_mark_task_done(self):
     user = self.create_user()
     task = Task(description='test', user=user)
     task.save()
     self.assertEqual(task.status, 'pending')
     task.done()
     self.assertEqual(task.status, 'completed')
开发者ID:campbellr,项目名称:taskweb,代码行数:9,代码来源:tests.py

示例2: post

# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import save [as 别名]
    def post(self, request, *args, **kwargs):
        form = TaskAddForm(request.POST)
        user = request.user

        if form.is_valid():
            task = Task(
                name=form.cleaned_data["name"],
                task_status=form.cleaned_data["task_status"],
                start_date=form.cleaned_data["start_date"],
                start_time=form.cleaned_data["start_time"],
                # users=(user,)
            )
            try:
                task.save()
                task.users.add(user)
            except Exception as e:
                return HttpResponse(render(request, "task/task_list.html", {"form": form}))

            return HttpResponseRedirect(reverse("task_list"))
        else:
            tasks_list = user.task_set.all().order_by("-id")
            paginator = MyPaginator(tasks_list, per_page=5, max_range=3)
            tasks = paginator.page(1)
            return render(request, "task/task_list.html", {
                "form": form,
                "tasks": tasks,
            })
开发者ID:yancai,项目名称:woodpecker,代码行数:29,代码来源:views.py

示例3: test_task_fromdict_dependencies

# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import save [as 别名]
    def test_task_fromdict_dependencies(self):
        user = self.create_user()

        task1 = Task(user=user, description='test')
        task1.save(track=False)
        task2 = Task(user=user, description='test2')
        task2.save(track=False)

        data = {'description': 'foobar', 'uuid': 'sssssssss',
                'status': 'pending',
                'entry': '12345',
                'user': user,
                'annotation_1324076995': u'this is an annotation',
                'depends': u','.join([t.uuid for t in (task1, task2)]),
                'priority': '',
                }

        task = Task.fromdict(data)

        # ensure the data is in the db, not just the task
        # object from above
        task = Task.objects.get(description='foobar')
        self.assertEqual(list(Undo.objects.all()), [])
        data.pop('user')
        data.pop('priority')
        self.assertEqual(data, task.todict())
开发者ID:campbellr,项目名称:taskweb,代码行数:28,代码来源:tests.py

示例4: test_create_task_undo

# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import save [as 别名]
 def test_create_task_undo(self):
     user = self.create_user()
     task = Task(description='foobar', user=user)
     task.save()
     self.assertEqual(len(Undo.objects.all()), 1)
     self.assertNotIn('old', Undo.serialize())
     self.assertEqual(len(Undo.serialize().splitlines()), 3)
     task.delete()
开发者ID:campbellr,项目名称:taskweb,代码行数:10,代码来源:tests.py

示例5: test_task_is_dirty_foreign_key

# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import save [as 别名]
 def test_task_is_dirty_foreign_key(self):
     user = self.create_user()
     task = Task(description='foobar', user=user)
     self.assertTrue(task._is_dirty())
     task.save()
     self.assertFalse(task._is_dirty())
     task.priority = Priority.objects.get(weight=1)
     self.assertItemsEqual(task._get_dirty_fields().keys(), ['priority'])
     self.assertTrue(task._is_dirty())
开发者ID:campbellr,项目名称:taskweb,代码行数:11,代码来源:tests.py

示例6: test_create_task_with_uuid

# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import save [as 别名]
 def test_create_task_with_uuid(self):
     """ Verify that when instantiating a Task with a uuid specified,
         it uses that uuid.
     """
     user = self.create_user()
     uuid = 'foobar'
     task = Task(description='my description', uuid=uuid, user=user)
     task.save()
     self.assertEqual(task.uuid, uuid)
开发者ID:campbellr,项目名称:taskweb,代码行数:11,代码来源:tests.py

示例7: test_task_is_dirty_m2m

# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import save [as 别名]
 def test_task_is_dirty_m2m(self):
     user = self.create_user()
     task = Task(description='foobar', user=user)
     self.assertTrue(task._is_dirty())
     task.save()
     self.assertFalse(task._is_dirty())
     task.tags.add(Tag.objects.create(tag='foobar'))
     self.assertItemsEqual(task._get_dirty_fields().keys(), ['tags'])
     self.assertTrue(task._is_dirty())
开发者ID:campbellr,项目名称:taskweb,代码行数:11,代码来源:tests.py

示例8: test_pending_tasks

# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import save [as 别名]
    def test_pending_tasks(self):
        user = self.create_user()
        task = Task(description='test, test', user=user)
        task.save()
        self.assertEqual(len(Task.objects.all()), 1)

        response = self.client.get('/pending/')
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.context['datagrid'].rows), 1)
开发者ID:campbellr,项目名称:taskweb,代码行数:11,代码来源:tests.py

示例9: test_task_saving_without_data_change

# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import save [as 别名]
 def test_task_saving_without_data_change(self):
     """ Make sure that saving a task twice without
         a change in data doesn't create duplicate Undo's
     """
     user = self.create_user()
     task = Task(description='foobar', user=user)
     task.save()
     task.save()
     self.assertEqual(len(Undo.objects.all()), 1)
开发者ID:campbellr,项目名称:taskweb,代码行数:11,代码来源:tests.py

示例10: index

# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import save [as 别名]
def index(request):
	if request.method == 'GET':
		a = Task.objects.all().order_by('date').reverse()
		context ={'tasks':a}
		return render(request,'task/index.html',context)
	elif request.method == 'POST':
		t =  request.POST.get("task", "")
		a = Task(text=t,date=timezone.now())
		a.save()
		return redirect('/')
开发者ID:uday1201,项目名称:DjangoToDo,代码行数:12,代码来源:views.py

示例11: test_task_tags_single_tag

# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import save [as 别名]
    def test_task_tags_single_tag(self):
        user = self.create_user()
        task = Task(description='foobar', user=user)
        task.save()

        # single tag
        tag = Tag.objects.create(tag='django')
        task.tags.add(tag)
        task.save()
        self.assertEqual(list(task.tags.all()), [tag])
开发者ID:campbellr,项目名称:taskweb,代码行数:12,代码来源:tests.py

示例12: test_create_task_no_uuid

# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import save [as 别名]
 def test_create_task_no_uuid(self):
     """ Verify that a `Task`s uuid field is automatically populated
         when not specified.
     """
     # description and user are the only required field
     user = self.create_user()
     task = Task(description='foobar', user=user)
     task.save()
     self.assertTrue(hasattr(task, 'uuid'))
     self.assertNotEqual(task.uuid, None)
开发者ID:campbellr,项目名称:taskweb,代码行数:12,代码来源:tests.py

示例13: test_task_is_dirty

# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import save [as 别名]
 def test_task_is_dirty(self):
     user = self.create_user()
     task = Task(description='foobar', user=user)
     self.assertItemsEqual(task._get_dirty_fields().keys(), ['user', 'description'])
     self.assertTrue(task._is_dirty())
     task.save()
     self.assertFalse(task._is_dirty())
     self.assertItemsEqual(task._get_dirty_fields().keys(), [])
     task.description = 'foobar2'
     self.assertItemsEqual(task._get_dirty_fields().keys(), ['description'])
     self.assertTrue(task._is_dirty())
开发者ID:campbellr,项目名称:taskweb,代码行数:13,代码来源:tests.py

示例14: create_task

# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import save [as 别名]
 def create_task(self, type, application, document):
     task=Task()
     task.type = type
     task.application = application
     if type == 'createdocument':
         task.document = document
     elif type == 'classifydocument':
         task.classify = document
     else:
         raise Exception('Not a valid task type.')
     task.save()
开发者ID:Grungnie,项目名称:documentclassification,代码行数:13,代码来源:serializers.py

示例15: test_task_tags_multiple_tags

# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import save [as 别名]
    def test_task_tags_multiple_tags(self):
        user = self.create_user()
        task = Task(description='foobar', user=user)
        task.save()

        # multiple tags
        tag1 = Tag.objects.create(tag='spam')
        tag2 = Tag.objects.create(tag='eggs')
        task.tags.add(tag1, tag2)
        task.save()
        self.assertEqual(list(task.tags.all()), [tag1, tag2])
开发者ID:campbellr,项目名称:taskweb,代码行数:13,代码来源:tests.py


注:本文中的task.models.Task.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。