mirror of
https://github.com/DMOJ/online-judge.git
synced 2024-11-25 16:32:37 +08:00
Avoid passing models to celery tasks
This commit is contained in:
parent
30a2f3b092
commit
0a8e3cfe54
@ -1,4 +1,5 @@
|
||||
from celery import shared_task
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.cache import cache
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext as _
|
||||
@ -23,9 +24,10 @@ def apply_submission_filter(queryset, id_range, languages, results):
|
||||
|
||||
|
||||
@shared_task(bind=True)
|
||||
def rejudge_problem_filter(self, problem_id, id_range=None, languages=None, results=None, user=None):
|
||||
def rejudge_problem_filter(self, problem_id, id_range=None, languages=None, results=None, user_id=None):
|
||||
queryset = Submission.objects.filter(problem_id=problem_id)
|
||||
queryset = apply_submission_filter(queryset, id_range, languages, results)
|
||||
user = User.objects.get(id=user_id)
|
||||
|
||||
rejudged = 0
|
||||
with Progress(self, queryset.count()) as p:
|
||||
|
@ -90,7 +90,8 @@ class BaseRejudgeSubmissionsView(PermissionRequiredMixin, ManageProblemSubmissio
|
||||
|
||||
class RejudgeSubmissionsView(BaseRejudgeSubmissionsView):
|
||||
def generate_response(self, id_range, languages, results):
|
||||
status = rejudge_problem_filter.delay(self.object.id, id_range, languages, results, user=self.request.user)
|
||||
status = rejudge_problem_filter.delay(self.object.id, id_range, languages, results,
|
||||
user_id=self.request.user.id)
|
||||
return redirect_to_task_status(
|
||||
status, message=_('Rejudging selected submissions for %s...') % (self.object.name,),
|
||||
redirect=reverse('problem_submissions_rejudge_success', args=[self.object.code, status.id]),
|
||||
|
Loading…
Reference in New Issue
Block a user