Commit 666828f7 by John Jarvis

Command for certificate whitelist

parent 7e033d02
from django.core.management.base import BaseCommand, CommandError
import os
from optparse import make_option
from student.models import UserProfile
from certificates.models import CertificateWhitelist
from django.contrib.auth.models import User
class Command(BaseCommand):
help = """
......@@ -59,7 +58,8 @@ class Command(BaseCommand):
else:
user = User.objects.get(username=user_str)
cert_whitelist, created = CertificateWhitelist.objects.get_or_create(
cert_whitelist, created = \
CertificateWhitelist.objects.get_or_create(
user=user, course_id=course_id)
if options['add']:
cert_whitelist.whitelist = True
......@@ -69,5 +69,6 @@ class Command(BaseCommand):
whitelist = CertificateWhitelist.objects.all()
print "User whitelist for course {0}:\n{1}".format(course_id,
'\n'.join([ "{0} {1} {2}".format(u.user.username, u.user.email, u.whitelist) for u in whitelist]))
'\n'.join(["{0} {1} {2}".format(
u.user.username, u.user.email, u.whitelist)
for u in whitelist]))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment