本文整理汇总了Python中models.Task.create方法的典型用法代码示例。如果您正苦于以下问题:Python Task.create方法的具体用法?Python Task.create怎么用?Python Task.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Task
的用法示例。
在下文中一共展示了Task.create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: view_launch
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import create [as 别名]
def view_launch(request, object_name):
"""Launches task associated with given Launchable object and redirects to
user's profile.
"""
try:
db_objects = get_current_solution(request).get_objects(BaseObject)
obj = db_objects.get(name=object_name)
except (ValueError, IndexError, ObjectDoesNotExist):
raise Http404()
obj = obj.cast()
if obj.get_category() != 'launch':
return HttpResponse('Unable to launch "%s"' % obj.get_category())
task = Task.create(get_current_solution(request), object_name)
task.run()
return HttpResponseRedirect('/profile')
示例2: task_add
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import create [as 别名]
def task_add(user):
app = default_app()
data = load_request_data(request)
errors = task_data_validator.validate(data, ignore_field_names=('owner', ))
if not errors:
data = dict(request.forms)
if data.get('deadline'):
data['deadline'] = convert_str_to_date(data['deadline'])
with db.transaction():
task = Task.create(owner=user, **data)
location = app.get_url('task_show', task_id=task.get_id())
data = {'id': task.get_id(), 'location': location}
response = HTTPResponse(data, status=201)
else:
data = {'errors': {'fields': errors}}
response = HTTPResponse(data, status=400)
return response
示例3: test_findAllFor
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import create [as 别名]
def test_findAllFor(self):
self.task = Task.create(**self.kwargs)
self.tasks = Task.findAllFor(self.project)
self.assertTrue(len(self.tasks) == 1)
示例4: test_init
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import create [as 别名]
def test_init(self):
self.task = Task.create(**self.kwargs)
self.assertTrue(self.task.title == 'test')