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


Python models.Task类代码示例

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


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

示例1: test_tasks

 def test_tasks(self):
     s = Supplier()
     s.name = 'Joe'
     s.save()
     
     p = Property()
     p.save()
     l = Location(property = p)
     l.save()
     a = Asset(location = l)
     a.save()         
     t = Task(asset = a)
     t.name = 'Mop floors'
     t.frequency = 1
     t.save()
      
     q = Quote(supplier = s)
     q.amount = 4
     q.save()
     
     self.assertEqual(0, len(q.tasks.all()))
     
     q.tasks.add(t)
     self.assertEqual(1, len(q.tasks.all()))
       
     self.assertEqual
     self.assertEqual("$4.00 to Mop floors (Joe)", str(q))
开发者ID:ianfp,项目名称:property,代码行数:27,代码来源:models.py

示例2: create

def create(request):
    if request.method == 'POST':
        form = NewTaskForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            if len(data['title']) > 500:
                return returnErrors(request, 'Task title too long')
            
            elif len(data['description']) > 5000:
                return returnErrors(request, 'Task description too long')
            
            else:
                # makes a task with the submitted information and the current user
                task = Task(owner=request.user, title=data['title'], description=data['description'])
                task.save()
    
                # adds collaborators 1, 2 and 3 by finding the user associated with the submitted email
                for x in range(1, 4):
                    if User.objects.filter(username=data['collaborator' + str(x)]).exists():
                        task.collaborators.add(User.objects.get(username=data['collaborator' + str(x)]))
        
        else:
            return returnErrors(request, 'Fill out all task information')
            
    return HttpResponseRedirect('/')
开发者ID:jjf32897,项目名称:cpsc113-social-todo-django,代码行数:25,代码来源:views.py

示例3: create_task

def create_task(request):
    
    created_by = request.user
    assignable_users = User.objects.filter(is_active=True).order_by(User.USERNAME_FIELD)

    if request.method == 'POST':
        title = request.POST.get('task')
        submitter_mail = request.POST.get('submitter_mail')
        status = request.POST.get('status')
        priority = request.POST.get('priority')
        project_agreement = request.POST.get('project_agreement')
        table = request.POST.get('table')
        due_date = datetime.strptime(request.POST.get('due_date'), "%Y-%m-%d")
        created_date = datetime.strptime(request.POST.get('created_date'),"%Y-%m-%d")
        created_by = request.POST.get('created_by')
        assigned_to = request.POST.get('assigned_to')
        note = request.POST.get('note')

        task = Task(task=title, submitter_email=submitter_mail, status=status, priority=priority, 
            due_date=due_date, created_date=created_date,created_by_id=created_by, assigned_to_id=assigned_to, 
            project_agreement=project_agreement, table=table, note=note)
        task.save()
    form = form_data(request)

    tasks = Task.objects.all()
    return render_to_response('tasks/task_index.html',
        RequestContext(request, {
        	'tasks':Task.objects.all().order_by('created_date').reverse,
            'assignable_users': assignable_users,
            'created_by': created_by,
            'form': form
            
        }))
开发者ID:toladata,项目名称:TolaWork,代码行数:33,代码来源:views.py

示例4: assign_tasks

def assign_tasks(review_milestone, reviewer, routing_algorithm='random', tasks_to_assign=None, simulate=False, chunk_id_task_map={}):
	# if tasks_to_assign == None, set tasks_to_assign equal to number required by the milestone for the reviewer's role
	if tasks_to_assign == None:
		tasks_to_assign = get_num_tasks_for_user(review_milestone, reviewer, simulate=simulate)
	reviewer_role = None
	if simulate:
		reviewer_role = reviewer['membership__role']
	else:
		reviewer_role = reviewer.membership.get(semester=review_milestone.assignment.semester).role
	# get all the chunks that the reviewer can review in the order they should be assigned
	reviewable_chunks = get_reviewable_chunks(review_milestone, reviewer, reviewer_role, simulate=simulate, chunk_id_task_map=chunk_id_task_map)
	chunks_to_assign = apply_routing_algorithm(reviewable_chunks, tasks_to_assign, routing_algorithm=routing_algorithm)
	# if len(chunks_to_assign) < num_tasks_for_user, the reviewer will be assigned fewer
	# tasks than they should be and they will be assigned more tasks the next time they
	# log in if there are more tasks they can be assigned

	# create and save tasks if it's NOT a simulation
	if not simulate:
		# create tasks for the chunks in chunks_to_assign and save them
		for chunk in chunks_to_assign:
			# create a ChunkReview if one doesn't already exist
			chunk_review, created = ChunkReview.objects.get_or_create(chunk=chunk)
			# update the ChunkReview
			if reviewer_role == Member.STUDENT or reviewer_role == Member.VOLUNTEER:
				chunk_review.student_or_alum_reviewers += 1
			elif reviewer_role == Member.TEACHER:
				chunk_review.staff_reviewers += 1
			chunk_review.save()
			# create a task
			task = Task(reviewer=reviewer, chunk=chunk, milestone=review_milestone, submission=chunk.file.submission, chunk_review=chunk_review)
			task.save()
	return len(chunks_to_assign)
开发者ID:khobbs91,项目名称:caesar-web,代码行数:32,代码来源:random_routing.py

示例5: test_missing_contacts

    def test_missing_contacts(self):
        person = models.Person(
            legal_name = "Test Person",
            slug       = 'test-person'
        )
        person.save()
        
        self.assertItemsEqual(
            [ i.category.slug for i in Task.objects_for(person) ],
            ['find-missing-phone', 'find-missing-email', 'find-missing-address'],
        )

        # add a phone number and check that the tasks get updated
        phone = models.ContactKind(
            slug='phone', name='Phone',
        )
        phone.save()

        contact = models.Contact(
            content_type = ContentType.objects.get_for_model(person),
            object_id    = person.id,
            kind         = phone,
            value        = '07891 234 567',
        )
        contact.save()

        self.assertItemsEqual(
            [ i.category.slug for i in Task.objects_for(person) ],
            ['find-missing-email', 'find-missing-address'],
        )
开发者ID:supercool,项目名称:mzalendo,代码行数:30,代码来源:test_models.py

示例6: test_frequency_object

 def test_frequency_object(self):
     """
     Ensure that the .frequency setter works with Frequency objects, too.
     """
     t = Task()
     for value in [0, 1, 6, 12]:
         t.frequency = Frequency(value)
         self.assertEqual(value, t._frequency)
开发者ID:ianfp,项目名称:property,代码行数:8,代码来源:models.py

示例7: setUp

 def setUp(self):
     self.tasks_url = reverse('tasks')
     self.user = User.objects.create(username='user',
                                     email='[email protected]',
                                     is_staff=True, is_active=True)
     task = Task(title='task-1', description='description-of-task-1',
                 created_by=self.user)
     task.save()
开发者ID:IlianIliev,项目名称:pytraining,代码行数:8,代码来源:page_tests.py

示例8: handle

	def handle(self, *args, **options):
		Task.objects.all().delete()
		for i in range(100):
			task = Task()
			task.title = 'Task-%d'%i
			task.text = 'Text %d'%i
			task.save()

				
开发者ID:Pelagicore,项目名称:mock-dataprovider,代码行数:7,代码来源:createtasks.py

示例9: post

 def post(request):
     task = request.POST.get('task')
     new = Task()
     new.name = task
     new.status = Status.objects.get(name='New')
     new.save()
     response = HttpResponse()
     response.status_code = 201
     return response
开发者ID:ivegor,项目名称:trello,代码行数:9,代码来源:views.py

示例10: add_project_task

def add_project_task(request,slug):
    if request.user.is_authenticated():
        project = Project.objects.get(slug = slug)
        if request.POST:
            form = TaskForm(request.POST)
            if form.is_valid():
                data = form.cleaned_data
                td = data['end_date'] - data['start_date']
                if td.total_seconds()>0:
                    task = Task()
                    task.name = data['name']
                    task.description = data['description']
                    task.start_date = data['start_date']
                    task.end_date = data['end_date']
                    task.user = data['user']
                    task.project = project
                    task.save()
                else:
                    messages.add_message(request, messages.ERROR,
                        " end date is less than start date!")
                    return (redirect(reverse('Task:add_task')))
                return (redirect(reverse('Home:manager')))
            else:
                messages.add_message(request, messages.ERROR, 
                    "invalid form")
                return (redirect(reverse('Task:add_task')))
        else:
            form = TaskForm()
            send_dict={}
            context_instance=RequestContext(request)
            send_dict['project'] = project
            send_dict['form'] = form
            return render_to_response('tasks/add_task.html',send_dict,context_instance)
    else:
        return redirect(reverse('Login:login'))
开发者ID:Adikeshav,项目名称:intern,代码行数:35,代码来源:views.py

示例11: create_analysis_tasks

def create_analysis_tasks(analysis_id):
    print('analysis_id', analysis_id)
    # samples = []
    # print('hello!')
    #create analysis tasks
    # analysis = Analysis.objects.()
    analysis = Analysis.objects.get(pk=analysis_id)
    print(dir(analysis))
    params = analysis.params
    files = params['files']
    for file in files:
        task = Task(user=analysis.user)
        task.manifest = {}
        task.manifest['files'] = [file]
        task.manifest['analysis_types'] = params['analysis_types']
        task.status = 'new'
        task.analysis = analysis
        task.action = 'analysis'
        task.save()
        analysis.tasks.add(task)

    # if 'sample_groups' in  params:
    #     samples = Sample.objects.filter(samplegroup_members__in=params['sample_groups'])
    #     # sample = Sample.objects.first()
    #     # print(dir(sample))
    # for sample in samples:      
    #     print(sample)
    #     for file in sample.files.all():
    #         bam_size = 9223372036854775807
    #         if file.extension == 'bam':
    #             if file.size < bam_size:
    #                 bamfile = file
    #                 bam_size = file.size
    #     print('small bam', bamfile.size)
    # get smallest bam file
开发者ID:raonyguimaraes,项目名称:mendelmd,代码行数:35,代码来源:tasks.py

示例12: update

	def update(self, pk):
		try:
			task = Task.objects.get(pk=pk)
		except Task.DoesNotExist:
			task = Task()

		task.title = self.data['title']
		task.description = self.data['description']
		task.save()

		return task
开发者ID:fabiancabau,项目名称:task_admin,代码行数:11,代码来源:api.py

示例13: add_task

def add_task(request, group, meeting):
    """
    Adds a task to a minutes item.
    """
    item_number = request.POST['ajax_button'][9:]
    item_number = int(item_number)
    predecessors = Task.objects.filter(item_id=item_number)
    no_of_precessors = predecessors.count()
    new_task_number = no_of_precessors + 1
    new_task = Task(item_id=int(item_number), group=group, meeting=meeting,
                    task_no=new_task_number, status = 'Draft')
    new_task.save(group)
开发者ID:criptoverso,项目名称:econvenor,代码行数:12,代码来源:utils.py

示例14: task_set_view

def task_set_view(request, pk):  # zobrazenie sady ako zoznam
    task_set = get_object_or_404(TaskSet, pk=pk)

    if not TaskSet.can_see(task_set, request.user):
        raise Http404

    # vytvori sa alebo updatne aktualna sada
    act = Active.objects.get_or_create(user=request.user)
    a = act[0]
    a.task_set = task_set
    a.save()

    # zoznam uloh v sade; iba tie, ktorym moze vidiet zadania v zozname
    q = Task.objects.filter(task_set=task_set)
    q_ids = [o.id for o in q if Task.can_see(o, request.user, "t")]
    tasks = q.filter(id__in=q_ids)

    # zoznam sad do horneho menu; iba tie, ktore user moze vidiet
    q = TaskSet.objects.order_by("title")
    q_ids = [o.id for o in q if TaskSet.can_see(o, request.user)]
    sets = q.filter(id__in=q_ids)

    # roztriedenie uloh na kategorie (ci su vyriesene/precitane)
    # v tomto poradi sa mu aj zobrazuju
    task_cat = []
    task_cat.append({"tasks": [], "type": "act_sub"})  # 0
    task_cat.append({"tasks": [], "type": "act_read"})  # 1
    task_cat.append({"tasks": [], "type": "sol_sub"})  # 2
    task_cat.append({"tasks": [], "type": "sol_read"})  # 3
    for task in tasks:
        if Task.is_solved(task, request.user):
            if task.type == Task.SUBMIT:
                task_cat[2]["tasks"].append(task)
            elif task.type == Task.READ:
                task_cat[3]["tasks"].append(task)
        elif Task.is_enabled(task, request.user):
            if task.type == Task.SUBMIT:
                task_cat[0]["tasks"].append(task)
            elif task.type == Task.READ:
                task_cat[1]["tasks"].append(task)

    return render_to_response(
        "tasks/task_set.html",
        {
            "active_app": "tasks",  # kvoli havnemu menu
            "task_set": task_set,  # aktualna sada
            "sets": sets,  # viditelne sady v taboch
            "style": "list",  # styl zobrazovania sady
            "categories": task_cat,  # ulohy podla kategorii
            "tasks": tasks,  # danej sady
        },
        context_instance=RequestContext(request),
    )
开发者ID:kackoryba,项目名称:liahen,代码行数:53,代码来源:views.py

示例15: import_tasks

def import_tasks(request):
	""" View in the admin """
	if request.method == 'POST': 
		form = ImportForm(request.POST, request.FILES)
		if form.is_valid(): 
			try:
				Task.import_Tasks(form.files['file'], request.user)
                                messages.success(request, "The import was successfull.")
				return HttpResponseRedirect(urlresolvers.reverse('admin:tasks_task_changelist'))
			except Exception, e:
				from django.forms.utils import ErrorList
                                msg = "An Error occured. The import file was propably malformed.: %s" % str(e)
				form._errors["file"] = ErrorList([msg]) 			
开发者ID:lohner,项目名称:Praktomat,代码行数:13,代码来源:views.py


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