From 52e387e0294ca227f4ea8503eb3df1094056b701 Mon Sep 17 00:00:00 2001 From: John Jarvis Date: Wed, 16 Jan 2013 17:44:19 -0500 Subject: [PATCH] Add the force flag This will allow you to force the certificate generation for when certificate requests are lost and stuck in 'generating', this happens when we have xqueue issues. --- .../management/commands/ungenerated_certs.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/certificates/management/commands/ungenerated_certs.py b/lms/djangoapps/certificates/management/commands/ungenerated_certs.py index 78cbc28f22..47d64a7685 100644 --- a/lms/djangoapps/certificates/management/commands/ungenerated_certs.py +++ b/lms/djangoapps/certificates/management/commands/ungenerated_certs.py @@ -33,14 +33,25 @@ class Command(BaseCommand): default=False, help='Grade and generate certificates ' 'for a specific course'), + make_option('-f', '--force-gen', + metavar='STATUS', + dest='force', + default=False, + help='Will force generate a search for STATUS ' + '(cannot be downloadable)'), + ) def handle(self, *args, **options): # Will only generate a certificate if the current - # status is in this state + # status is in the unavailable state, can be set + # to something else with the force flag - VALID_STATUSES = [CertificateStatuses.unavailable] + if options['force']: + valid_statuses = getattr(CertificateStatuses, options['force']) + else: + valid_statuses = [CertificateStatuses.unavailable] # Print update after this many students @@ -83,7 +94,7 @@ class Command(BaseCommand): start = datetime.datetime.now() if certificate_status_for_student( - student, course_id)['status'] in VALID_STATUSES: + student, course_id)['status'] in valid_statuses: if not options['noop']: # Add the certificate request to the queue ret = xq.add_cert(student, course_id)