Merge branch 'feature/apenney/pearson-merge' of github.com:MITx/mitx into feature/apenney/pearson-merge
This commit is contained in:
@@ -71,6 +71,12 @@ class Command(BaseCommand):
|
|||||||
dest='ignore_registration_dates',
|
dest='ignore_registration_dates',
|
||||||
help='find exam info for course based on exam_series_code, even if the exam is not active.'
|
help='find exam info for course based on exam_series_code, even if the exam is not active.'
|
||||||
),
|
),
|
||||||
|
make_option(
|
||||||
|
'--create_dummy_exam',
|
||||||
|
action='store_true',
|
||||||
|
dest='create_dummy_exam',
|
||||||
|
help='create dummy exam info for course, even if course exists'
|
||||||
|
),
|
||||||
)
|
)
|
||||||
args = "<student_username course_id>"
|
args = "<student_username course_id>"
|
||||||
help = "Create or modify a TestCenterRegistration entry for a given Student"
|
help = "Create or modify a TestCenterRegistration entry for a given Student"
|
||||||
@@ -99,6 +105,7 @@ class Command(BaseCommand):
|
|||||||
raise CommandError("User \"{}\" does not have an existing demographics record".format(username))
|
raise CommandError("User \"{}\" does not have an existing demographics record".format(username))
|
||||||
|
|
||||||
# check to see if a course_id was specified, and use information from that:
|
# check to see if a course_id was specified, and use information from that:
|
||||||
|
create_dummy_exam = 'create_dummy_exam' in our_options and our_options['create_dummy_exam']
|
||||||
try:
|
try:
|
||||||
course = course_from_id(course_id)
|
course = course_from_id(course_id)
|
||||||
if 'ignore_registration_dates' in our_options:
|
if 'ignore_registration_dates' in our_options:
|
||||||
@@ -107,6 +114,9 @@ class Command(BaseCommand):
|
|||||||
else:
|
else:
|
||||||
exam = course.current_test_center_exam
|
exam = course.current_test_center_exam
|
||||||
except ItemNotFoundError:
|
except ItemNotFoundError:
|
||||||
|
create_dummy_exam = True
|
||||||
|
|
||||||
|
if exam is None and create_dummy_exam:
|
||||||
# otherwise use explicit values (so we don't have to define a course):
|
# otherwise use explicit values (so we don't have to define a course):
|
||||||
exam_name = "Dummy Placeholder Name"
|
exam_name = "Dummy Placeholder Name"
|
||||||
exam_info = { 'Exam_Series_Code': our_options['exam_series_code'],
|
exam_info = { 'Exam_Series_Code': our_options['exam_series_code'],
|
||||||
@@ -120,7 +130,7 @@ class Command(BaseCommand):
|
|||||||
our_options['eligibility_appointment_date_last'] = strftime("%Y-%m-%d", exam.last_eligible_appointment_date)
|
our_options['eligibility_appointment_date_last'] = strftime("%Y-%m-%d", exam.last_eligible_appointment_date)
|
||||||
|
|
||||||
if exam is None:
|
if exam is None:
|
||||||
raise CommandError("Exam for course_id {%s} does not exist".format(course_id))
|
raise CommandError("Exam for course_id {} does not exist".format(course_id))
|
||||||
|
|
||||||
exam_code = exam.exam_series_code
|
exam_code = exam.exam_series_code
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,10 @@ class Command(BaseCommand):
|
|||||||
with dog_stats_api.timer('pearson.{0}'.format(mode), tags='s3'):
|
with dog_stats_api.timer('pearson.{0}'.format(mode), tags='s3'):
|
||||||
try:
|
try:
|
||||||
for filename in os.listdir(files_from):
|
for filename in os.listdir(files_from):
|
||||||
upload_file_to_s3(bucket, files_from, filename)
|
source_file = os.path.join(files_from, filename)
|
||||||
|
# use mode as name of directory into which to write files
|
||||||
|
dest_file = os.path.join(mode, filename)
|
||||||
|
upload_file_to_s3(bucket, source_file, dest_file)
|
||||||
if deleteAfterCopy:
|
if deleteAfterCopy:
|
||||||
os.remove(files_from + '/' + filename)
|
os.remove(files_from + '/' + filename)
|
||||||
except:
|
except:
|
||||||
@@ -119,7 +122,7 @@ class Command(BaseCommand):
|
|||||||
's3 archiving failed')
|
's3 archiving failed')
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def upload_file_to_s3(bucket, source_dir, filename):
|
def upload_file_to_s3(bucket, source_file, dest_file):
|
||||||
"""
|
"""
|
||||||
Upload file to S3
|
Upload file to S3
|
||||||
"""
|
"""
|
||||||
@@ -128,8 +131,8 @@ class Command(BaseCommand):
|
|||||||
from boto.s3.key import Key
|
from boto.s3.key import Key
|
||||||
b = s3.get_bucket(bucket)
|
b = s3.get_bucket(bucket)
|
||||||
k = Key(b)
|
k = Key(b)
|
||||||
k.key = "{filename}".format(filename=filename)
|
k.key = "{filename}".format(filename=dest_file)
|
||||||
k.set_contents_from_filename(os.path.join(source_dir, filename))
|
k.set_contents_from_filename(source_file)
|
||||||
|
|
||||||
def export_pearson():
|
def export_pearson():
|
||||||
options = { 'dest-from-settings' : True }
|
options = { 'dest-from-settings' : True }
|
||||||
|
|||||||
@@ -655,7 +655,7 @@ class CourseDescriptor(SequenceDescriptor):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def registration_end_date_text(self):
|
def registration_end_date_text(self):
|
||||||
return time.strftime("%b %d, %Y", self.registration_end_date)
|
return time.strftime("%b %d, %Y at %H:%M UTC", self.registration_end_date)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_test_center_exam(self):
|
def current_test_center_exam(self):
|
||||||
|
|||||||
@@ -466,7 +466,7 @@
|
|||||||
<span class="label">Last Eligible Appointment Date:</span> <span class="value">${exam_info.last_eligible_appointment_date_text}</span>
|
<span class="label">Last Eligible Appointment Date:</span> <span class="value">${exam_info.last_eligible_appointment_date_text}</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<span class="label">Registration End Date:</span> <span class="value">${exam_info.registration_end_date_text}</span>
|
<span class="label">Registration Ends:</span> <span class="value">${exam_info.registration_end_date_text}</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
% endif
|
% endif
|
||||||
|
|||||||
Reference in New Issue
Block a user