Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ class Command(BaseCommand):
dest='noop',
default=False,
help="Don't grade or add certificate requests to the queue"),
make_option('--insecure',
action='store_true',
dest='insecure',
default=False,
help="Don't use https for the callback url to the LMS, useful in http test environments"),
make_option('-c', '--course',
metavar='COURSE_ID',
dest='course',
Expand Down Expand Up @@ -52,6 +57,8 @@ def handle(self, *args, **options):
if not options['noop']:
# Add the certificate request to the queue
xq = XQueueCertInterface()
if options['insecure']:
xq.use_https = False
ret = xq.regen_cert(student, course_id, course=course)
print '{0} - {1}'.format(student, ret)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class Command(BaseCommand):
dest='noop',
default=False,
help="Don't add certificate requests to the queue"),
make_option('--insecure',
action='store_true',
dest='insecure',
default=False,
help="Don't use https for the callback url to the LMS, useful in http test environments"),
make_option('-c', '--course',
metavar='COURSE_ID',
dest='course',
Expand Down Expand Up @@ -83,6 +88,8 @@ def handle(self, *args, **options):
"groups").order_by('username')

xq = XQueueCertInterface()
if options['insecure']:
xq.use_https = False
total = enrolled_students.count()
count = 0
start = datetime.datetime.now(UTC)
Expand Down
10 changes: 8 additions & 2 deletions lms/djangoapps/certificates/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def __init__(self, request=None):
)
self.whitelist = CertificateWhitelist.objects.all()
self.restricted = UserProfile.objects.filter(allow_certificate=False)
self.use_https = True

def regen_cert(self, student, course_id, course=None):
"""(Re-)Make certificate for a particular student in a particular course
Expand Down Expand Up @@ -216,9 +217,14 @@ def add_cert(self, student, course_id, course=None):

def _send_to_xqueue(self, contents, key):

if self.use_https:
proto = "https"
else:
proto = "http"

xheader = make_xheader(
'https://{0}/update_certificate?{1}'.format(
settings.SITE_NAME, key), key, settings.CERT_QUEUE)
'{0}://{1}/update_certificate?{2}'.format(
proto, settings.SITE_NAME, key), key, settings.CERT_QUEUE)

(error, msg) = self.xqueue_interface.send_to_queue(
header=xheader, body=json.dumps(contents))
Expand Down