Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.order_by(
Lower(Concat('relatedstudent__user__fullname',
'relatedstudent__user__shortname')))
examinerqueryset = Examiner.objects\
.select_related('relatedexaminer__user')\
.only(
'relatedexaminer',
'assignmentgroup',
'relatedexaminer__automatic_anonymous_id',
'relatedexaminer__user__shortname',
'relatedexaminer__user__fullname',
)\
.order_by(
Lower(Concat('relatedexaminer__user__fullname',
'relatedexaminer__user__shortname')))
queryset = coremodels.AssignmentGroup.objects\
.filter_examiner_has_access(user=self.request.user)\
.filter(parentnode=assignment)\
.prefetch_related(
models.Prefetch('candidates',
queryset=candidatequeryset))\
.prefetch_related(
models.Prefetch('examiners',
queryset=examinerqueryset)) \
.annotate_with_is_waiting_for_feedback_count()\
.annotate_with_is_waiting_for_deliveries_count()\
.annotate_with_is_corrected_count() \
.annotate_with_number_of_private_groupcomments_from_user(user=self.request.user) \
.annotate_with_number_of_private_imageannotationcomments_from_user(user=self.request.user)\
.distinct()\
.select_related('cached_data__last_published_feedbackset',
'cached_data__last_feedbackset',
def get_role_query_set(self):
"""
Returns role queryset for student role
Returns:
:class:`~devilry_group.GroupComment` queryset
"""
assignment_group_queryset = AssignmentGroup.objects.filter_student_has_access(user=self.request.user)
return GroupComment.objects.filter(feedback_set__group__in=assignment_group_queryset,
comment_type=GroupComment.COMMENT_TYPE_GROUPCOMMENT,
visibility=GroupComment.VISIBILITY_VISIBLE_TO_EVERYONE)\
.select_related('feedback_set__group__parentnode', 'user')
def get_queryset(self):
return AssignmentGroup.objects.filter_examiner_has_access(self.request.user)
def _get_group(self):
try:
return AssignmentGroup.objects\
.filter_student_has_access(self.request.user)\
.select_related(
'last_deadline',
'parentnode', # Assignment
'parentnode__parentnode', # Period
'parentnode__parentnode__parentnode', # Subject
)\
.get(id=self.kwargs['id'])
except AssignmentGroup.DoesNotExist:
raise Http404()
def get_queryset(self):
return AssignmentGroup.objects.filter_examiner_has_access(self.request.user)
def get_queryset_for_role(self, role):
assignment = role
candidatequeryset = Candidate.objects\
.select_related('relatedstudent__user')\
.order_by(
Lower(Concat('relatedstudent__user__fullname',
'relatedstudent__user__shortname')))
examinerqueryset = Examiner.objects\
.select_related('relatedexaminer__user')\
.order_by(
Lower(Concat('relatedexaminer__user__fullname',
'relatedexaminer__user__shortname')))
return AssignmentGroup.objects\
.filter(parentnode=assignment)\
.prefetch_related(
models.Prefetch('candidates',
queryset=candidatequeryset))\
.prefetch_related(
models.Prefetch('examiners',
queryset=examinerqueryset))\
.annotate_with_is_waiting_for_feedback_count()\
.annotate_with_is_waiting_for_deliveries_count()\
.annotate_with_is_corrected_count() \
.annotate_with_number_of_private_groupcomments_from_user(user=self.request.user) \
.annotate_with_number_of_private_imageannotationcomments_from_user(user=self.request.user)\
.distinct() \
.select_related('cached_data__last_published_feedbackset',
'cached_data__last_feedbackset',
'cached_data__first_feedbackset',
def _user_is_candidate_in_group(self, assignment_group, user):
group_queryset = AssignmentGroup.objects.filter(id=assignment_group.id).filter_user_is_candidate(user=user)
if group_queryset.count() == 0:
return False
return True
def get_assignment_groups_without_any_examiners(self):
return AssignmentGroup.objects.filter(parentnode=self.request.cradmin_role, examiners__isnull=True)
def get_queryset(self):
return AssignmentGroup.objects.filter_student_has_access(self.request.user) \
.select_related(
'parentnode', # Assignment
'parentnode__parentnode', # Period
'parentnode__parentnode__parentnode') # Subject