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


Python models.Task类代码示例

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


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

示例1: test_task_fromdict_dependencies_dont_exist_yet

    def test_task_fromdict_dependencies_dont_exist_yet(self):
        user = self.create_user()
        task1_info = {'description': 'foobar',
                      'uuid': '1234abc',
                      'entry': '1234',
                      'project': 'test',
                      'user': user,
                      'status': 'pending',
                      }

        task2_info = {'description': 'baz',
                      'uuid': 'aaaaaa',
                      'entry': '1237',
                      'depends': '1234abc',
                      'user': user,
                      'status': 'pending',
                      'annotation_123456': 'some note'
                      }

        task2 = Task.fromdict(task2_info)
        task1 = Task.fromdict(task1_info)

        task2_info.pop('user')
        task1_info.pop('user')
        self.assertEqual(task1.todict(), task1_info)
        self.assertEqual(task2.todict(), task2_info)
开发者ID:campbellr,项目名称:taskweb,代码行数:26,代码来源:tests.py

示例2: post_taskdb

def post_taskdb(request, filename):
    if filename not in TASK_FNAMES:
        return HttpResponseForbidden('Forbidden!')

    user = request.user
    data = request.raw_post_data

    if filename in ['pending.data', 'completed.data']:
        parsed = [decode_task(line) for line in data.splitlines()]
        if filename == 'pending.data':
            tasks = Task.objects.filter(status='pending', user=user)
        elif filename == 'completed.data':
            tasks = Task.objects.filter(status__in=['completed', 'deleted'])

        tasks.delete()

        for task in parsed:
            task.update({'user': user})
            Task.fromdict(task)

    elif filename == 'undo.data':
        Undo.objects.all().delete()
        parsed = parse_undo(data)
        for undo_dict in parsed:
            undo_dict.update({'user': user})
            Undo.fromdict(undo_dict)
    else:
        return HttpResponseNotFound()

    return HttpResponse()
开发者ID:campbellr,项目名称:taskweb,代码行数:30,代码来源:views.py

示例3: test_mark_task_done

 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,代码行数:7,代码来源:tests.py

示例4: post

    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,代码行数:27,代码来源:views.py

示例5: test_create_task_undo

 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,代码行数:8,代码来源:tests.py

示例6: test_task_saving_without_data_change

 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,代码行数:9,代码来源:tests.py

示例7: test_pending_tasks

    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,代码行数:9,代码来源:tests.py

示例8: test_create_task_with_uuid

 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,代码行数:9,代码来源:tests.py

示例9: test_task_tags_single_tag

    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,代码行数:10,代码来源:tests.py

示例10: index

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,代码行数:10,代码来源:views.py

示例11: test_create_task_no_uuid

 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,代码行数:10,代码来源:tests.py

示例12: test_task_is_dirty

 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,代码行数:11,代码来源:tests.py

示例13: test_task_tags_multiple_tags

    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,代码行数:11,代码来源:tests.py

示例14: test_edit_task_undo

 def test_edit_task_undo(self):
     user = self.create_user()
     task = Task(description='foobar', user=user)
     task.save()
     task.annotate('annotation')
     self.assertEqual(len(Undo.objects.all()), 2)
     self.assertIn('old', Undo.serialize())
     # 'old' shouldn't have an annotation
     new_undo = Undo.objects.get(pk=2)
     self.assertNotIn('annotation_', new_undo.old)
     self.assertEqual(len(Undo.serialize().splitlines()), 7)
     self.assertNotIn('annotation_', Undo.serialize().splitlines()[4])
开发者ID:campbellr,项目名称:taskweb,代码行数:12,代码来源:tests.py

示例15: new_task

def new_task(request):
    name = unicode.strip(request.POST.get('name'))
    description = unicode.strip(request.POST.get('description'))
    pk = request.POST.get('pk')
    if pk:
        task = Task.objects.get(pk=pk)
        task.name = name
        task.description = description
    else:
        task = Task(name=name, description=description)
    task.save()
    return HttpResponseRedirect(reverse('tasks'))
开发者ID:macro,项目名称:git-it-done,代码行数:12,代码来源:views.py


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