def rate(self): Rating.objects.filter(contest__end_time__range=(self.end_time, self._now)).delete() for contest in Contest.objects.filter( is_rated=True, end_time__range=(self.end_time, self._now), ).order_by('end_time'): rate_contest(contest)
def rate_all_view(self, request): if not request.user.has_perm('judge.contest_rating'): raise PermissionDenied() with transaction.atomic(): with connection.cursor() as cursor: cursor.execute('TRUNCATE TABLE `%s`' % Rating._meta.db_table) Profile.objects.update(rating=None) for contest in Contest.objects.filter(is_rated=True).order_by('end_time'): rate_contest(contest) return HttpResponseRedirect(reverse('admin:judge_contest_changelist'))
def rate_view(self, request, id): if not request.user.has_perm('judge.contest_rating'): raise PermissionDenied() contest = get_object_or_404(Contest, id=id) if not contest.is_rated: raise Http404() with transaction.atomic(): Rating.objects.filter(contest__end_time__gte=contest.end_time).delete() for contest in Contest.objects.filter(is_rated=True, end_time__gte=contest.end_time).order_by('end_time'): rate_contest(contest) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse('admin:judge_contest_changelist')))
def rate_all_view(self, request): if not request.user.has_perm('judge.contest_rating'): raise PermissionDenied() with transaction.atomic(): if connection.vendor == 'sqlite': Rating.objects.all().delete() else: cursor = connection.cursor() cursor.execute('TRUNCATE TABLE `%s`' % Rating._meta.db_table) cursor.close() Profile.objects.update(rating=None) for contest in Contest.objects.filter(is_rated=True).order_by('end_time'): rate_contest(contest) return HttpResponseRedirect(reverse('admin:judge_contest_changelist'))
def rate_view(self, request, id): if not request.user.has_perm("judge.contest_rating"): raise PermissionDenied() try: contest = Contest.objects.get(id=id) except ObjectDoesNotExist: raise Http404() if not contest.is_rated: raise Http404() with transaction.atomic(): Rating.objects.filter(contest__end_time__gte=contest.end_time).delete() for contest in Contest.objects.filter(is_rated=True, end_time__gte=contest.end_time).order_by("end_time"): rate_contest(contest) return HttpResponseRedirect(request.META.get("HTTP_REFERER", reverse("admin:judge_contest_changelist")))
def rate(self): Rating.objects.filter(contest__end_time__gte=self.end_time).delete() for contest in Contest.objects.filter( is_rated=True, end_time__gte=self.end_time).order_by('end_time'): rate_contest(contest)