本文整理汇总了Python中tasks.models.Task.is_hidden方法的典型用法代码示例。如果您正苦于以下问题:Python Task.is_hidden方法的具体用法?Python Task.is_hidden怎么用?Python Task.is_hidden使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tasks.models.Task
的用法示例。
在下文中一共展示了Task.is_hidden方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_task_create_filled
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import is_hidden [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)
示例2: task_create_or_edit
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import is_hidden [as 别名]
def task_create_or_edit(request, course, task_id=None):
params = get_task_params(request, course.issue_status_system.has_accepted_after_deadline())
lang = request.user.get_profile().language
changed_score_after_deadline = False
if task_id:
task = get_object_or_404(Task, id=task_id)
task_text = task.is_text_json()
if task_text:
task_title = json.loads(task.title, strict=False)
task_title[lang] = params['attrs']['title']
task_text[lang] = params['attrs']['task_text']
params['attrs']['title'] = json.dumps(task_title, ensure_ascii=False)
params['attrs']['task_text'] = json.dumps(task_text, ensure_ascii=False)
changed_score_after_deadline = task.score_after_deadline != params['attrs']['score_after_deadline']
params['attrs']['nb_assignment_name'] = task.nb_assignment_name
else:
task = Task()
task.course = course
for attr_name, attr_value in params['attrs'].items():
setattr(task, attr_name, attr_value)
if task.parent_task:
if task.parent_task.is_hidden:
task.is_hidden = True
task.save()
for subtask in Task.objects.filter(parent_task=task):
subtask.is_hidden = task.is_hidden
subtask.save()
children = params['children']
for course_task in Task.objects.filter(course=course):
if children and course_task.id in map(int, children):
course_task.parent_task = task
course_task.save()
elif course_task.parent_task == task:
course_task.parent_task = None
course_task.save()
task_groups = params['groups']
task.groups = task_groups
task.set_position_in_new_group(task_groups)
if task_id and changed_score_after_deadline and task.parent_task:
student_ids = User.objects.filter(group__in=task_groups).values_list('id', flat=True)
for student_id in student_ids:
parent_issue, created = Issue.objects.get_or_create(task_id=task.parent_task.id, student_id=student_id)
total_mark = Issue.objects \
.filter(task=task, student_id=student_id) \
.exclude(task__is_hiddne=True) \
.exclude(
task__score_after_deadline=False,
status_field__tag=IssueStatus.STATUS_ACCEPTED_AFTER_DEADLINE) \
.aggregate(Sum('mark'))['mark__sum'] or 0
if task.score_after_deadline:
parent_issue.mark += total_mark
else:
parent_issue.mark -= total_mark
parent_issue.set_status_seminar()
if task.type == task.TYPE_SEMINAR:
student_ids = User.objects.filter(group__in=task_groups).values_list('id', flat=True)
for student_id in student_ids:
issue, created = Issue.objects.get_or_create(task_id=task.id, student_id=student_id)
issue.mark = Issue.objects \
.filter(task__parent_task=task, student_id=student_id) \
.exclude(task__is_hidden=True) \
.exclude(
task__score_after_deadline=False,
status_field__tag=IssueStatus.STATUS_ACCEPTED_AFTER_DEADLINE) \
.aggregate(Sum('mark'))['mark__sum'] or 0
issue.set_status_seminar()
task.save()
reversion.set_user(request.user)
if task_id:
reversion.set_comment("Edit task")
else:
reversion.set_comment("Create task")
return HttpResponse(json.dumps({'page_title': task.get_title(lang) + ' | ' + course.name + ' | ' + str(course.year),
'redirect_page': '/task/edit/' + str(task.id) if not task_id else None}),
content_type="application/json")
示例3: add_task
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import is_hidden [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")
示例4: tasks_list_many_task_many_group
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import is_hidden [as 别名]
def tasks_list_many_task_many_group(request, course, get_context=False):
user = request.user
user_is_attended = False
user_is_attended_special_course = False
course.can_edit = course.user_can_edit_course(user)
group_x_student_x_task_takens = OrderedDict()
group_x_task_list = {}
group_x_max_score = {}
task = Task()
task.is_shown = None
task.is_hidden = None
for group in course.groups.all().order_by('name'):
student_x_task_x_task_takens = {}
group_x_task_list[group] = Task.objects.filter(course=course).filter(group=group).order_by('weight')
group_x_max_score.setdefault(group, 0)
for task in group_x_task_list[group]:
task.add_user_properties(user)
if not task.is_hidden:
group_x_max_score[group] += task.score_max
if task.task_text is None:
task.task_text = ''
for student in group.students.filter(is_active=True):
if user == student:
user_is_attended = True
task_list = group_x_task_list[group]
student_task_takens = TaskTaken.objects.filter(task__in=group_x_task_list[group]).filter(user=student)
task_x_task_taken = {}
student_summ_scores = 0
for task_taken in student_task_takens:
task_x_task_taken[task_taken.task.id] = task_taken
if not task_taken.task.is_hidden:
student_summ_scores += task_taken.score
student_x_task_x_task_takens[student] = (task_x_task_taken, student_summ_scores)
group_x_student_x_task_takens[group] = student_x_task_x_task_takens
group_x_student_information = OrderedDict()
for group,student_x_task_x_task_takens in group_x_student_x_task_takens.iteritems():
group_x_student_information.setdefault(group, [])
for student in sorted(student_x_task_x_task_takens.keys(), key=lambda x: u"{0} {1}".format(x.last_name, x.first_name)):
if user == student:
user_is_attended = True
elif not course.user_can_see_transcript(user, student):
continue
group_x_student_information[group].append((student, student_x_task_x_task_takens[student][0], student_x_task_x_task_takens[student][1]))
extern_max_score = 0
extern_student_x_task_takens = {}
extern_tasks = Task.objects.filter(course=course).filter(group=None).order_by('weight')
for task in extern_tasks:
task.add_user_properties(user)
if not task.is_hidden:
extern_max_score += task.score_max
if task.task_text is None:
task.task_text = ''
task_takens = TaskTaken.objects.filter(task__in=extern_tasks)
for student in course.students.all():
if user == student:
user_is_attended = True
user_is_attended_special_course = True
elif not course.user_can_see_transcript(user, student):
continue
task_x_task_taken = {}
student_summ_scores = 0
student_task_takens = filter(lambda x: x.user == student, task_takens)
for task_taken in student_task_takens:
task_x_task_taken[task_taken.task.id] = task_taken
if not task_taken.task.is_hidden:
student_summ_scores += task_taken.score
extern_student_x_task_takens[student] = (task_x_task_taken, student_summ_scores)
extern_student_information = []
for student in sorted(extern_student_x_task_takens.keys(), key=lambda x: u"{0} {1}".format(x.last_name, x.first_name)):
if user == student:
user_is_attended = True
extern_student_information.append((student, extern_student_x_task_takens[student][0], extern_student_x_task_takens[student][1]))
#.........这里部分代码省略.........
示例5: tasklist_shad_cpp
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import is_hidden [as 别名]
def tasklist_shad_cpp(request, course):
user = request.user
user_is_attended = False
user_is_attended_special_course = False
course.can_edit = course.user_can_edit_course(user)
if course.can_be_chosen_by_extern:
course.groups.add(course.group_with_extern)
group_x_student_x_task_takens = OrderedDict()
group_x_task_list = {}
group_x_max_score = {}
task = Task()
task.is_shown = None
task.is_hidden = None
events_with_mark = Event.objects.filter(field_id=8).filter(author__in=course.teachers.all()).order_by('issue','timestamp')
marks_for_issues = {}
for event in events_with_mark:
marks_for_issues[event.issue.id] = event.value
for group in course.groups.all().order_by('name'):
student_x_task_x_task_takens = {}
group_x_task_list[group] = Task.objects.filter(Q(course=course) & (Q(group=group) | Q(group=None))).order_by('weight')
group_x_max_score.setdefault(group, 0)
for task in group_x_task_list[group]:
task.add_user_properties(user)
if not task.is_hidden:
group_x_max_score[group] += task.score_max
if task.task_text is None:
task.task_text = ''
issues_students_in_group = Issue.objects.filter(task__in=group_x_task_list[group]).filter(student__group__in=[group]).order_by('student')
from collections import defaultdict
issues_x_student = defaultdict(list)
for issue in issues_students_in_group.all():
student_id = issue.student.id
issues_x_student[student_id].append(issue)
for student in group.students.filter(is_active=True):
if user == student:
user_is_attended = True
user_is_attended_special_course = True
task_list = group_x_task_list[group]
student_task_takens = issues_x_student[student.id]
task_x_task_taken = {}
student_summ_scores = 0
for task_taken in student_task_takens:
task_x_task_taken[task_taken.task.id] = task_taken
if not task_taken.task.is_hidden:
student_summ_scores += marks_for_issues[task_taken.id]
student_x_task_x_task_takens[student] = (task_x_task_taken, student_summ_scores)
group_x_student_x_task_takens[group] = student_x_task_x_task_takens
group_x_student_information = OrderedDict()
for group,student_x_task_x_task_takens in group_x_student_x_task_takens.iteritems():
group_x_student_information.setdefault(group, [])
for student in sorted(student_x_task_x_task_takens.keys(), key=lambda x: u"{0} {1}".format(x.last_name, x.first_name)):
if user == student:
user_is_attended = True
elif not course.user_can_see_transcript(user, student):
continue
group_x_student_information[group].append((student, student_x_task_x_task_takens[student][0], student_x_task_x_task_takens[student][1]))
extern_max_score = 0
extern_student_x_task_takens = {}
extern_tasks = Task.objects.filter(course=course).filter(group=None).order_by('weight')
for task in extern_tasks:
task.add_user_properties(user)
if not task.is_hidden:
extern_max_score += task.score_max
if task.task_text is None:
task.task_text = ''
task_takens = TaskTaken.objects.filter(task__in=extern_tasks)
for student in course.students.all():
if user == student:
user_is_attended = True
user_is_attended_special_course = True
elif not course.user_can_see_transcript(user, student):
continue
task_x_task_taken = {}
#.........这里部分代码省略.........