pearson registration - resolving merge conflict
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from optparse import make_option
|
||||
from time import strftime
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
@@ -6,6 +7,7 @@ from django.core.management.base import BaseCommand, CommandError
|
||||
from student.models import TestCenterUser, TestCenterRegistration, TestCenterRegistrationForm, get_testcenter_registration
|
||||
from student.views import course_from_id
|
||||
from xmodule.course_module import CourseDescriptor
|
||||
from xmodule.modulestore.exceptions import ItemNotFoundError
|
||||
|
||||
class Command(BaseCommand):
|
||||
option_list = BaseCommand.option_list + (
|
||||
@@ -91,14 +93,14 @@ class Command(BaseCommand):
|
||||
raise CommandError("User {%s} does not exist".format(student))
|
||||
|
||||
# check to see if a course_id was specified, and use information from that:
|
||||
course = course_from_id(course_id)
|
||||
if course is not None:
|
||||
try:
|
||||
course = course_from_id(course_id)
|
||||
if 'ignore_registration_dates' in our_options:
|
||||
examlist = [exam for exam in course.test_center_exams if exam.exam_series_code == our_options.get('exam_series_code')]
|
||||
exam = examlist[0] if len(examlist) > 0 else None
|
||||
else:
|
||||
exam = course.current_test_center_exam
|
||||
else:
|
||||
except ItemNotFoundError:
|
||||
# otherwise use explicit values (so we don't have to define a course):
|
||||
exam_name = "Dummy Placeholder Name"
|
||||
exam_info = { 'Exam_Series_Code': our_options['exam_series_code'],
|
||||
@@ -106,6 +108,10 @@ class Command(BaseCommand):
|
||||
'Last_Eligible_Appointment_Date' : our_options['eligibility_appointment_date_last'],
|
||||
}
|
||||
exam = CourseDescriptor.TestCenterExam(course_id, exam_name, exam_info)
|
||||
# update option values for date_first and date_last to use YYYY-MM-DD format
|
||||
# instead of YYYY-MM-DDTHH:MM
|
||||
our_options['eligibility_appointment_date_first'] = strftime("%Y-%m-%d", exam.first_eligible_appointment_date)
|
||||
our_options['eligibility_appointment_date_last'] = strftime("%Y-%m-%d", exam.last_eligible_appointment_date)
|
||||
|
||||
if exam is None:
|
||||
raise CommandError("Exam for course_id {%s} does not exist".format(course_id))
|
||||
@@ -167,6 +173,8 @@ class Command(BaseCommand):
|
||||
|
||||
# override internal values:
|
||||
change_internal = False
|
||||
if 'exam_series_code' in our_options:
|
||||
exam_code = our_options['exam_series_code']
|
||||
registration = get_testcenter_registration(student, course_id, exam_code)[0]
|
||||
for internal_field in [ 'upload_error_message', 'upload_status', 'authorization_id']:
|
||||
if internal_field in our_options:
|
||||
|
||||
@@ -13,16 +13,41 @@ class Command(BaseCommand):
|
||||
action='store',
|
||||
dest='first_name',
|
||||
),
|
||||
make_option(
|
||||
'--middle_name',
|
||||
action='store',
|
||||
dest='middle_name',
|
||||
),
|
||||
make_option(
|
||||
'--last_name',
|
||||
action='store',
|
||||
dest='last_name',
|
||||
),
|
||||
make_option(
|
||||
'--suffix',
|
||||
action='store',
|
||||
dest='suffix',
|
||||
),
|
||||
make_option(
|
||||
'--salutation',
|
||||
action='store',
|
||||
dest='salutation',
|
||||
),
|
||||
make_option(
|
||||
'--address_1',
|
||||
action='store',
|
||||
dest='address_1',
|
||||
),
|
||||
make_option(
|
||||
'--address_2',
|
||||
action='store',
|
||||
dest='address_2',
|
||||
),
|
||||
make_option(
|
||||
'--address_3',
|
||||
action='store',
|
||||
dest='address_3',
|
||||
),
|
||||
make_option(
|
||||
'--city',
|
||||
action='store',
|
||||
@@ -51,12 +76,34 @@ class Command(BaseCommand):
|
||||
dest='phone',
|
||||
help='Pretty free-form (parens, spaces, dashes), but no country code'
|
||||
),
|
||||
make_option(
|
||||
'--extension',
|
||||
action='store',
|
||||
dest='extension',
|
||||
),
|
||||
make_option(
|
||||
'--phone_country_code',
|
||||
action='store',
|
||||
dest='phone_country_code',
|
||||
help='Phone country code, just "1" for the USA'
|
||||
),
|
||||
make_option(
|
||||
'--fax',
|
||||
action='store',
|
||||
dest='fax',
|
||||
help='Pretty free-form (parens, spaces, dashes), but no country code'
|
||||
),
|
||||
make_option(
|
||||
'--fax_country_code',
|
||||
action='store',
|
||||
dest='fax_country_code',
|
||||
help='Fax country code, just "1" for the USA'
|
||||
),
|
||||
make_option(
|
||||
'--company_name',
|
||||
action='store',
|
||||
dest='company_name',
|
||||
),
|
||||
# internal values:
|
||||
make_option(
|
||||
'--client_candidate_id',
|
||||
|
||||
@@ -223,8 +223,6 @@ class TestCenterUser(models.Model):
|
||||
return self.user.email
|
||||
|
||||
def needs_update(self, dict):
|
||||
# needs_updating = any([__getattribute__(fieldname) != dict[fieldname]
|
||||
# for fieldname in TestCenterUser.user_provided_fields()])
|
||||
for fieldname in TestCenterUser.user_provided_fields():
|
||||
if fieldname in dict and self.__getattribute__(fieldname) != dict[fieldname]:
|
||||
return True
|
||||
@@ -275,6 +273,7 @@ class TestCenterUserForm(ModelForm):
|
||||
# create additional values here:
|
||||
new_user.user_updated_at = datetime.utcnow()
|
||||
new_user.save()
|
||||
log.info("Updated demographic information for user's test center exam registration: username \"{}\" ".format(new_user.username))
|
||||
|
||||
# add validation:
|
||||
|
||||
@@ -534,6 +533,7 @@ class TestCenterRegistrationForm(ModelForm):
|
||||
# create additional values here:
|
||||
registration.user_updated_at = datetime.utcnow()
|
||||
registration.save()
|
||||
log.info("Updated registration information for user's test center exam registration: username \"{}\" course \"{}\", examcode \"{}\"".format(registration.testcenter_user.username, registration.course_id, registration.exam_series_code))
|
||||
|
||||
# TODO: add validation code for values added to accommodation_code field.
|
||||
|
||||
|
||||
@@ -610,7 +610,7 @@ def exam_registration_info(user, course):
|
||||
|
||||
@login_required
|
||||
@ensure_csrf_cookie
|
||||
def begin_test_registration(request, course_id):
|
||||
def begin_exam_registration(request, course_id):
|
||||
""" Handles request to register the user for the current
|
||||
test center exam of the specified course. Called by form
|
||||
in dashboard.html.
|
||||
@@ -649,7 +649,7 @@ def begin_test_registration(request, course_id):
|
||||
return render_to_response('test_center_register.html', context)
|
||||
|
||||
@ensure_csrf_cookie
|
||||
def create_test_registration(request, post_override=None):
|
||||
def create_exam_registration(request, post_override=None):
|
||||
'''
|
||||
JSON call to create a test center exam registration.
|
||||
Called by form in test_center_register.html
|
||||
@@ -662,19 +662,19 @@ def create_test_registration(request, post_override=None):
|
||||
user = User.objects.get(username=username)
|
||||
course_id = post_vars['course_id']
|
||||
course = (course_from_id(course_id)) # assume it will be found....
|
||||
log.info("User {0} enrolled in course {1} clicked on enter/update demographic info for test registration".format(user.username, course_id))
|
||||
|
||||
try:
|
||||
testcenter_user = TestCenterUser.objects.get(user=user)
|
||||
needs_updating = testcenter_user.needs_update(post_vars)
|
||||
needs_updating = testcenter_user.needs_update(post_vars)
|
||||
log.info("User {0} enrolled in course {1} {2}updating demographic info for exam registration".format(user.username, course_id, "" if needs_updating else "not "))
|
||||
except TestCenterUser.DoesNotExist:
|
||||
# do additional initialization here:
|
||||
testcenter_user = TestCenterUser.create(user)
|
||||
needs_updating = True
|
||||
log.info("User {0} enrolled in course {1} creating demographic info for exam registration".format(user.username, course_id))
|
||||
|
||||
# perform validation:
|
||||
if needs_updating:
|
||||
log.info("User {0} enrolled in course {1} updating demographic info for test registration".format(user.username, course_id))
|
||||
# first perform validation on the user information
|
||||
# using a Django Form.
|
||||
form = TestCenterUserForm(instance=testcenter_user, data=post_vars)
|
||||
@@ -694,15 +694,19 @@ def create_test_registration(request, post_override=None):
|
||||
registrations = get_testcenter_registration(user, course_id, exam_code)
|
||||
if len(registrations) > 0:
|
||||
registration = registrations[0]
|
||||
# TODO: check to see if registration changed. Should check appointment dates too...
|
||||
# And later should check changes in accommodation_code.
|
||||
# But at the moment, we don't expect anything to cause this to change
|
||||
# because of the registration form.
|
||||
# NOTE: we do not bother to check here to see if the registration has changed,
|
||||
# because at the moment there is no way for a user to change anything about their
|
||||
# registration. They only provide an optional accommodation request once, and
|
||||
# cannot make changes to it thereafter.
|
||||
# It is possible that the exam_info content has been changed, such as the
|
||||
# scheduled exam dates, but those kinds of changes should not be handled through
|
||||
# this registration screen.
|
||||
|
||||
else:
|
||||
accommodation_request = post_vars.get('accommodation_request','')
|
||||
registration = TestCenterRegistration.create(testcenter_user, exam, accommodation_request)
|
||||
needs_saving = True
|
||||
log.info("User {0} enrolled in course {1} creating new exam registration".format(user.username, course_id))
|
||||
|
||||
if needs_saving:
|
||||
# do validation of registration. (Mainly whether an accommodation request is too long.)
|
||||
@@ -720,27 +724,25 @@ def create_test_registration(request, post_override=None):
|
||||
# only do the following if there is accommodation text to send,
|
||||
# and a destination to which to send it.
|
||||
# TODO: still need to create the accommodation email templates
|
||||
if 'accommodation_request' in post_vars and settings.MITX_FEATURES.get('ACCOMMODATION_EMAIL'):
|
||||
d = {'accommodation_request': post_vars['accommodation_request'] }
|
||||
|
||||
# composes accommodation email
|
||||
subject = render_to_string('emails/accommodation_email_subject.txt', d)
|
||||
# Email subject *must not* contain newlines
|
||||
subject = ''.join(subject.splitlines())
|
||||
message = render_to_string('emails/accommodation_email.txt', d)
|
||||
# if 'accommodation_request' in post_vars and 'TESTCENTER_ACCOMMODATION_REQUEST_EMAIL' in settings:
|
||||
# d = {'accommodation_request': post_vars['accommodation_request'] }
|
||||
#
|
||||
# # composes accommodation email
|
||||
# subject = render_to_string('emails/accommodation_email_subject.txt', d)
|
||||
# # Email subject *must not* contain newlines
|
||||
# subject = ''.join(subject.splitlines())
|
||||
# message = render_to_string('emails/accommodation_email.txt', d)
|
||||
#
|
||||
# try:
|
||||
# dest_addr = settings['TESTCENTER_ACCOMMODATION_REQUEST_EMAIL']
|
||||
# from_addr = user.email
|
||||
# send_mail(subject, message, from_addr, [dest_addr], fail_silently=False)
|
||||
# except:
|
||||
# log.exception(sys.exc_info())
|
||||
# response_data = {'success': False}
|
||||
# response_data['non_field_errors'] = [ 'Could not send accommodation e-mail.', ]
|
||||
# return HttpResponse(json.dumps(response_data), mimetype="application/json")
|
||||
|
||||
# skip if destination email address is not specified
|
||||
try:
|
||||
dest_addr = settings.MITX_FEATURES['ACCOMMODATION_EMAIL']
|
||||
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [dest_addr], fail_silently=False)
|
||||
except:
|
||||
log.exception(sys.exc_info())
|
||||
response_data = {'success': False}
|
||||
response_data['non_field_errors'] = [ 'Could not send accommodation e-mail.', ]
|
||||
return HttpResponse(json.dumps(response_data), mimetype="application/json")
|
||||
|
||||
# TODO: enable appropriate stat
|
||||
# statsd.increment("common.student.account_created")
|
||||
|
||||
js = {'success': True}
|
||||
return HttpResponse(json.dumps(js), mimetype="application/json")
|
||||
|
||||
@@ -222,7 +222,7 @@
|
||||
<%
|
||||
testcenter_exam_info = course.current_test_center_exam
|
||||
registration = exam_registrations.get(course.id)
|
||||
testcenter_register_target = reverse('begin_test_registration', args=[course.id])
|
||||
testcenter_register_target = reverse('begin_exam_registration', args=[course.id])
|
||||
%>
|
||||
% if testcenter_exam_info is not None:
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
<section class="content">
|
||||
<header>
|
||||
<h3 class="is-hidden">Registration Form</h3>
|
||||
</header>
|
||||
</header>
|
||||
<form id="testcenter_register_form" method="post" data-remote="true" action="/create_test_registration">
|
||||
|
||||
<!-- TODO: add logic for registration closed state (add class of disabled to <form>) -->
|
||||
|
||||
@@ -43,8 +43,8 @@ urlpatterns = ('',
|
||||
url(r'^create_account$', 'student.views.create_account'),
|
||||
url(r'^activate/(?P<key>[^/]*)$', 'student.views.activate_account', name="activate"),
|
||||
|
||||
url(r'^begin_test_registration/(?P<course_id>[^/]+/[^/]+/[^/]+)$', 'student.views.begin_test_registration', name="begin_test_registration"),
|
||||
url(r'^create_test_registration$', 'student.views.create_test_registration'),
|
||||
url(r'^begin_exam_registration/(?P<course_id>[^/]+/[^/]+/[^/]+)$', 'student.views.begin_exam_registration', name="begin_exam_registration"),
|
||||
url(r'^create_exam_registration$', 'student.views.create_exam_registration'),
|
||||
|
||||
url(r'^password_reset/$', 'student.views.password_reset', name='password_reset'),
|
||||
## Obsolete Django views for password resets
|
||||
|
||||
Reference in New Issue
Block a user