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.
This commit is contained in:
John Jarvis
2013-01-16 17:44:19 -05:00
parent 44141b6a55
commit 52e387e029

View File

@@ -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)