X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/5af38e73db5ac3793f7c157f18a46b5661e9ab0e..f56862502899964e670442b7628637f74ee8ef06:/wtem/management/commands/wtem_assign_submissions.py?ds=sidebyside diff --git a/wtem/management/commands/wtem_assign_submissions.py b/wtem/management/commands/wtem_assign_submissions.py index afb99ca..7ff1af2 100644 --- a/wtem/management/commands/wtem_assign_submissions.py +++ b/wtem/management/commands/wtem_assign_submissions.py @@ -24,15 +24,15 @@ class Command(BaseCommand): ) def handle(self, *args, **options): - how_many = int(args[0]) - examiner_names = args[1:] + limit_from = int(args[0]) + limit_to = int(args[1]) + examiner_names = args[2:] users = User.objects.filter(username__in = examiner_names) submissions_query = Submission.objects.annotate(examiners_count = Count('examiners')) - submissions = submissions_query \ - .filter(examiners_count__lt=2).exclude(answers = None) + submissions = submissions_query.exclude(answers = None) with_attachment_ids = Attachment.objects.values_list('submission_id', flat=True).all() if options['attachments_only']: @@ -40,7 +40,7 @@ class Command(BaseCommand): if options['no_attachments_only']: submissions = submissions.exclude(id__in = with_attachment_ids) - for submission in submissions.order_by('id')[0:how_many]: + for submission in submissions.order_by('id')[limit_from:limit_to]: submission.examiners.add(*users) submission.save() self.stdout.write('added to %s:%s' % (submission.id, submission.email))