Exemple #1
0
 def get_contest_queryset(self):
     queryset = self.profile.current_contest.contest.contest_problems \
         .defer('problem__description').order_by('problem__code') \
         .order_by('order')
     queryset = TranslatedProblemForeignKeyQuerySet.add_problem_i18n_name(
         queryset, 'i18n_name', self.request.LANGUAGE_CODE, 'problem__name')
     return [{
         'id': p['problem_id'],
         'code': p['problem__code'],
         'name': p['problem__name'],
         'i18n_name': p['i18n_name'],
         'points': p['points'],
         'partial': p['partial'],
     } for p in
             queryset.values('problem_id', 'problem__code', 'problem__name',
                             'i18n_name', 'points', 'partial')]
 def get_contest_queryset(self):
     queryset = self.profile.current_contest.contest.contest_problems.select_related('problem__group') \
         .defer('problem__description').order_by('problem__code') \
         .annotate(user_count=Count('submission__participation', distinct=True)) \
         .order_by('order')
     queryset = TranslatedProblemForeignKeyQuerySet.add_problem_i18n_name(queryset, 'i18n_name',
                                                                          self.request.LANGUAGE_CODE,
                                                                          'problem__name')
     return [{
         'id': p['problem_id'],
         'code': p['problem__code'],
         'name': p['problem__name'],
         'i18n_name': p['i18n_name'],
         'group': {'full_name': p['problem__group__full_name']},
         'points': p['points'],
         'partial': p['partial'],
         'user_count': p['user_count'],
     } for p in queryset.values('problem_id', 'problem__code', 'problem__name', 'i18n_name',
                                'problem__group__full_name', 'points', 'partial', 'user_count')]