From 7e55437db6685f0e8c494159fa9cf4cedbb45810 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 5 Oct 2015 14:52:04 -0400 Subject: [PATCH] Allow retry_failed_photo_verifications to take a list of receipt_ids to retry --- .../retry_failed_photo_verifications.py | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py b/lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py index c2f525d0fe..502185d25d 100644 --- a/lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py +++ b/lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py @@ -11,13 +11,31 @@ class Command(BaseCommand): This method finds those PhotoVerifications with a status of MUST_RETRY and attempts to verify them. """ - help = 'Retries SoftwareSecurePhotoVerifications that are in a state of \'must_retry\'' + args = "" + help = ( + "Retries SoftwareSecurePhotoVerifications passed as " + "arguments, or if no arguments are supplied, all that " + "are in a state of 'must_retry'" + ) def handle(self, *args, **options): - attempts_to_retry = SoftwareSecurePhotoVerification.objects.filter(status='must_retry') + if args: + attempts_to_retry = SoftwareSecurePhotoVerification.objects.filter( + receipt_id__in=args + ) + force_must_retry = True + else: + attempts_to_retry = SoftwareSecurePhotoVerification.objects.filter(status='must_retry') + force_must_retry = False + print("Attempting to retry {0} failed PhotoVerification submissions".format(len(attempts_to_retry))) for index, attempt in enumerate(attempts_to_retry): print("Retrying submission #{0} (ID: {1}, User: {2})".format(index, attempt.id, attempt.user)) + + # Set the attempts status to 'must_retry' so that we can re-submit it + if force_must_retry: + attempt.status = 'must_retry' + attempt.submit(copy_id_photo_from=attempt.copy_id_photo_from) print("Retry result: {0}".format(attempt.status)) print("Done resubmitting failed photo verifications")