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


Python Task.type方法代码示例

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


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

示例1: test_task_create_filled

# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import type [as 别名]
    def test_task_create_filled(self):
        year = Year.objects.create(start_year=2016)
        group = [Group.objects.create(name='name_groups', year=year)]
        course = Course.objects.create(name='course_name',
                                       year=year)
        course.groups = group
        course.save()

        parent_task = Task.objects.create(title='parent_task',
                                          course=course)

        deadline_time = datetime.now() + timedelta(days=5)

        task = Task()
        task.title = 'title'
        task.course = course
        task.weight = 1
        task.is_hidden = True
        task.parent_task = parent_task
        task.task_text = 'task_text'
        task.score_max = 10
        task.contest_integrated = True
        task.rb_integrated = True
        task.type = Task.TYPE_SIMPLE
        task.deadline_time = deadline_time
        task.contest_id = 1234
        task.problem_id = 'A'
        task.sended_notify = False
        task.one_file_upload = True
        task.save()
        task.groups = group
        task_id = task.id

        task = Task.objects.get(id=task_id)

        self.assertIsInstance(task, Task)
        self.assertEqual(task.title, 'title')
        self.assertEqual(task.course, course)
        self.assertItemsEqual(task.groups.all(), group)
        self.assertEqual(task.weight, 1)
        self.assertEqual(task.is_hidden, True)
        self.assertEqual(task.parent_task, parent_task)
        self.assertEqual(task.task_text, 'task_text')
        self.assertEqual(task.contest_integrated, True)
        self.assertEqual(task.rb_integrated, True)
        self.assertEqual(task.type, Task.TYPE_SIMPLE)
        self.assertEqual(task.deadline_time.replace(tzinfo=None), deadline_time - timedelta(hours=3))
        self.assertEqual(task.contest_id, 1234)
        self.assertEqual(task.problem_id, 'A')
        self.assertEqual(task.sended_notify, False)
        self.assertEqual(task.one_file_upload, True)
开发者ID:znick,项目名称:anytask,代码行数:53,代码来源:tests.py

示例2: bulk_action

# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import type [as 别名]
def bulk_action(request, project_id):

    if request.user.is_staff:
        project = get_object_or_404(Project, pk=project_id)
    else:
        project = get_object_or_404(Project, pk=project_id, user=request.user)

    if request.method == 'POST':
        
        action = request.POST['action']

        # print('POST', request.POST)

        model = request.POST['model']


        if model == 'files':
    
            files = request.POST.getlist('files')


            if action == 'analysis':

                request.session['files'] = files
                request.session['project_id'] = project_id
                
                return redirect('analysis-create')


            for file_id in files:
                file = File.objects.get(pk=file_id)
                if action == "delete":
                    file.delete()
                if action == "qc":
                    if file.file_type in ['fq', 'fastq', 'bam', 'vcf']:
                        task = Task()
                        task.name = 'QC ProjectFile %s' % (file.id)
                        task.type = 'qc'
                        task.action = 'qc'
                        task.status = 'new'
                        task.manifest = {
                            'input':file.location,
                            'project':project.id,
                            'file':file.id,
                            'type':'qc',
                        }
                        task.save()
                        run_qc.delay(task.id)
                if action == "check":
                   task_manifest = {}
                   task_manifest['file'] = file.id
                   task_manifest['action'] = action
                   task = Task(user=request.user)
                   task.manifest = task_manifest
                   task.status = 'new'
                   task.action = action
                   task.user = request.user
                   task.save()
                   check_file.delay(task.id)
                   file.status = 'scheduled'
                   file.save()







        if model == 'samples':
            samples = request.POST.getlist('samples')
            for sample_id in samples:
                sample = ProjectSample.objects.get(pk=sample_id)
                if action == "delete":
                    sample.delete()

            
    return redirect('projects-view', project_id=project_id)
开发者ID:raonyguimaraes,项目名称:mendelmd,代码行数:79,代码来源:views.py


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