本文整理汇总了Python中tasks.models.Task.save方法的典型用法代码示例。如果您正苦于以下问题:Python Task.save方法的具体用法?Python Task.save怎么用?Python Task.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tasks.models.Task
的用法示例。
在下文中一共展示了Task.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_project_task
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save [as 别名]
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'))
示例2: create_analysis_tasks
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save [as 别名]
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
示例3: create
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save [as 别名]
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('/')
示例4: create_task
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save [as 别名]
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
}))
示例5: assign_tasks
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save [as 别名]
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)
示例6: run_task
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save [as 别名]
def run_task(request):
if request.method == 'GET':
print(request.GET)
if 'action' in request.GET:
action = request.GET['action']
file_id = request.GET['file_id']
file = File.get_object_or_404(pk=file_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()
return redirect('files-index')
示例7: test_tasks
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save [as 别名]
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))
示例8: setUp
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save [as 别名]
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()
示例9: handle
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save [as 别名]
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()
示例10: post
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save [as 别名]
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
示例11: create
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save [as 别名]
def create(self, request, task_id):
if 'title' not in request.POST:
return rc.BAD_REQUEST
task = Task()
task.title = request.POST.get('title')
task.priority = int(request.POST.get('priority')) if request.POST.get('priority') else 0
task.user = request.user
task.save()
return rc.CREATED
示例12: create
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save [as 别名]
def create(self, request):
task = Task()
task.summary = request.POST.get('summary')
task.detail = request.POST.get('detail')
task.creator = request.user
task.save()
return task
示例13: update
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save [as 别名]
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
示例14: add_task
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save [as 别名]
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)
示例15: test_task_create_filled
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import save [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)