本文整理汇总了Python中tasks.models.Task.title方法的典型用法代码示例。如果您正苦于以下问题:Python Task.title方法的具体用法?Python Task.title怎么用?Python Task.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tasks.models.Task
的用法示例。
在下文中一共展示了Task.title方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import title [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()
示例2: create
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import title [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
示例3: update
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import title [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
示例4: test_task_create_filled
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import title [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)
示例5: add_task
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import title [as 别名]
def add_task(request):
user = request.user
if not request.method == 'POST':
return HttpResponseForbidden()
hidden_task = False
if 'hidden_task' in request.POST:
hidden_task = True
try:
course_id = int(request.POST['course_id'])
task_title = request.POST['task_title'].strip()
task_text = request.POST['task_text'].strip()
max_score = int(request.POST['max_score'])
course = get_object_or_404(Course, id = course_id)
if course.contest_integrated:
contest_id = int(request.POST['contest_id'])
problem_id = request.POST['problem_id'].strip()
task_group_id = request.POST['task_group_id']
group_id = request.POST['group_id']
if task_group_id == "":
group_id = None
else:
group_id = int(task_group_id)
parent_id = request.POST['parent_id']
if not parent_id or parent_id == 'null':
parent_id = None
else:
parent_id = int(parent_id)
except ValueError: #not int
return HttpResponseForbidden()
group = None
if group_id is not None:
group = get_object_or_404(Group, id = group_id)
parent = None
if parent_id is not None:
parent = get_object_or_404(Task, id = parent_id)
if not course.user_can_edit_course(user):
return HttpResponseForbidden()
max_weight_query = Task.objects.filter(course=course)
if group:
max_weight_query = max_weight_query.filter(group=group)
if parent:
max_weight_query = max_weight_query.filter(parent_task=parent)
tasks = max_weight_query.aggregate(Max('weight'))
_, max_weight = tasks.items()[0]
if max_weight is None:
max_weight = 0
max_weight += 1
task = Task()
task.course = course
task.group = group
task.parent_task = parent
task.weight = max_weight
task.title = task_title
task.task_text = task_text
task.score_max = max_score
if course.contest_integrated:
task.contest_id = contest_id
task.problem_id = problem_id
task.is_hidden = hidden_task
task.updated_by = user
task.save()
return HttpResponse("OK")