From 5af38e73db5ac3793f7c157f18a46b5661e9ab0e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Thu, 21 Nov 2013 22:29:05 +0100 Subject: [PATCH] Allow for assignment to submissions filtered by not having an attachment --- wtem/management/commands/wtem_assign_submissions.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wtem/management/commands/wtem_assign_submissions.py b/wtem/management/commands/wtem_assign_submissions.py index fad2d3e..afb99ca 100644 --- a/wtem/management/commands/wtem_assign_submissions.py +++ b/wtem/management/commands/wtem_assign_submissions.py @@ -16,6 +16,11 @@ class Command(BaseCommand): dest='attachments_only', default=False, help='Take into account only submissions with attachments'), + make_option('--without-attachments-only', + action='store_true', + dest='no_attachments_only', + default=False, + help='Take into account only submissions without attachments'), ) def handle(self, *args, **options): @@ -29,9 +34,11 @@ class Command(BaseCommand): submissions = submissions_query \ .filter(examiners_count__lt=2).exclude(answers = None) + with_attachment_ids = Attachment.objects.values_list('submission_id', flat=True).all() if options['attachments_only']: - with_attachment_ids = Attachment.objects.values_list('submission_id', flat=True).all() submissions = submissions.filter(id__in = with_attachment_ids) + if options['no_attachments_only']: + submissions = submissions.exclude(id__in = with_attachment_ids) for submission in submissions.order_by('id')[0:how_many]: submission.examiners.add(*users) -- 2.20.1