• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.Task类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: new

def new(request):
    resp = {}
    if request.method != 'POST':
        resp['status'] = 1
        resp['message'] = 'Wrong http method!'
        return HttpResponse(json.dumps(resp), content_type = 'application/json')
    approximate_fplace = request.POST['approximate_fplace']
    detailed_fplace = request.POST['detailed_fplace']
    pto = request.POST['pto']
    code = request.POST['code']
    fetch_btime = request.POST['fetch_btime']
    fetch_etime = request.POST['fetch_etime']
    owner = request.POST['owner']
    give_time = request.POST['give_time']
    curtime = datetime.datetime.now()
    user = User.objects.filter(id = owner)
    if not user.exists():
        resp['status'] = 1
        resp['message'] = 'No such user'
        return HttpResponse(json.dumps(resp), content_type = 'application/json')
    elif len(user) > 1:
        resp['status'] = 2
        resp['message'] = 'Too many user found, impossible!'
        return HttpResponse(json.dumps(resp), content_type = 'application/json')

    if user[0].status == 0:
        resp['status'] = 3
        resp['message'] = 'Not authenticated yet!'
        return HttpResponse(json.dumps(resp), content_type='application/json')

    if user[0].bonus <= 0:
        resp['status'] = 4
        resp['message'] = 'You do not have enough bonus!'
        return HttpResponse(json.dumps(resp), content_type='application/json')

    task = Task(approximate_fplace = approximate_fplace, detailed_fplace = detailed_fplace,
                pto = pto, code = code, fetch_btime = datetime.datetime.strptime(fetch_btime, '%Y-%m-%d %H:%M:%S'),
                fetch_etime = datetime.datetime.strptime(fetch_etime, '%Y-%m-%d %H:%M:%S'), owner = user[0],
                give_time = datetime.datetime.strptime(give_time, '%Y-%m-%d %H:%M:%S'), build_time = curtime)
    task.save()
    if task.id is None:
        resp['status'] = 4
        resp['message'] = 'create task error'
        return HttpResponse(json.dumps(resp), content_type = 'application/json')
    else:
        user[0].bonus -= 1
        user[0].save()
        resp['status'] = 0
        resp['message'] = 'Success'
        info = task.to_dict()
        info['owner'] = task.owner.to_dict()
        resp['data'] = info
        return HttpResponse(json.dumps(resp), content_type = 'application/json')
开发者ID:wyxpku,项目名称:pkucourier,代码行数:53,代码来源:views.py


示例17: get_taskdb

def get_taskdb(request, filename):
    if filename == 'pending.data':
        taskstr = Task.serialize('pending')
    elif filename == 'completed.data':
        taskstr = Task.serialize('completed')
    elif filename == 'undo.data':
        taskstr = Undo.serialize()
    else:
        return HttpResponseNotFound()

    response = HttpResponse(taskstr, mimetype='text/plain')
    response['Content-Length'] = len(taskstr)
    return response
开发者ID:campbellr,项目名称:taskweb,代码行数:13,代码来源:views.py


示例18: tasks_new_view

def tasks_new_view(request):
	#TODO - check permissions
	try:
		o = Task(	project=Project.objects.get(id=request.GET['project']),
					title=request.GET['title'],
					type=request.GET['type'],
					severity=request.GET['severity'],
					description=request.GET['description'],
					created_by=request.user)
		o.save()
	except:
		return HttpResponse("Something went wrong!")
	return HttpResponse("1")
开发者ID:keiouu,项目名称:Nirtha,代码行数:13,代码来源:views.py


示例19: create_task

def create_task(request):
	context_dict = {}
	employee = Employee.objects.get(pk=1)
	if request.user.is_authenticated():
		username = request.user.username
		employee = Employee.objects.get(user=request.user)
		context_dict['employee'] = employee
	if request.method == 'POST':
		title = request.POST['title']
		desc = request.POST['desc']
		date = request.POST['date']
		today = datetime.now().date()
		task = Task(owner=employee, date_published=today, date_due=date, title=title, description=desc, state=False)
		task.save()
	return render(request, 'task/create_task.html', context_dict)
开发者ID:lionlinekz,项目名称:project,代码行数:15,代码来源:views.py


示例20: test_task_fromdict_track

    def test_task_fromdict_track(self):
        user = self.create_user()
        data = {'description': 'foobar', 'uuid': 'sssssssss',
                'status': 'pending',
                'entry': '12345',
                'user': user,
                'annotation_1324076995': u'this is an annotation',
                'priority': 'H',
                }

        task = Task.fromdict(data, track=True)

        # ensure the data is in the db, not just the task
        # object from above
        task = Task.objects.all()[0]

        # see reasoning in the add_tasks_POST test
        self.assertEqual(Undo.objects.count(), 2)

        # this is a brand new task, the firts undo shouldn't
        # have an 'old' field.
        self.assertEqual(Undo.objects.all()[0].old, None)
        data.pop('user')
        self.assertEqual(data, task.todict())

        undo2 = Undo.objects.all()[1]
        self.assertNotEqual(undo2.old, undo2.new)
开发者ID:campbellr,项目名称:taskweb,代码行数:27,代码来源:tests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python FileSpec.FileSpec类代码示例发布时间:2022-05-27
下一篇:
Python task.ValidationException类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap