Commit 45ed4a41 by Brian Talbot

resolving merge conflict around test_center_register.html template

parents 3bd8f408 2788ad86
...@@ -675,13 +675,18 @@ def _do_create_or_update_test_center_user(post_vars): ...@@ -675,13 +675,18 @@ def _do_create_or_update_test_center_user(post_vars):
try: try:
testcenter_user.save() testcenter_user.save()
except IntegrityError, ie: except IntegrityError, ie:
message = "%s" % ie js = {'success': False}
context = {'course': course, error_msg = unicode(ie);
'user': user, # attempt to find a field name to signal
'message': message, for fieldname in TestCenterUser.user_provided_fields():
'testcenteruser': testcenter_user, if error_msg.find(fieldname) >= 0:
} js['value'] = error_msg
return render_to_response('test_center_register.html', context) js['field'] = fieldname
return HttpResponse(json.dumps(js))
# otherwise just return the error message
js['value'] = error_msg
js['field'] = "General Error"
return HttpResponse(json.dumps(js))
# create and save the registration: # create and save the registration:
needs_saving = False needs_saving = False
...@@ -715,13 +720,7 @@ def _do_create_or_update_test_center_user(post_vars): ...@@ -715,13 +720,7 @@ def _do_create_or_update_test_center_user(post_vars):
try: try:
registration.save() registration.save()
except IntegrityError, ie: except IntegrityError, ie:
message = "%s" % ie raise
context = {'course': course,
'user': user,
'message': message,
'testcenteruser': testcenter_user,
}
return render_to_response('test_center_register.html', context)
return (user, testcenter_user, registration) return (user, testcenter_user, registration)
...@@ -743,14 +742,14 @@ def create_test_registration(request, post_override=None): ...@@ -743,14 +742,14 @@ def create_test_registration(request, post_override=None):
js['field'] = a js['field'] = a
return HttpResponse(json.dumps(js)) return HttpResponse(json.dumps(js))
# Confirm appropriate fields are there. # Confirm appropriate fields are filled in with something for now
for a in ['first_name', 'last_name', 'address_1', 'city', 'country']: for a in ['first_name', 'last_name', 'address_1', 'city', 'country']:
if len(post_vars[a]) < 2: if len(post_vars[a]) < 2:
error_str = {'first_name': 'First name must be minimum of two characters long.', error_str = {'first_name': 'First name must be minimum of two characters long.',
'last_name': 'Last name must be minimum of two characters long.', 'last_name': 'Last name must be minimum of two characters long.',
'address_1': 'Last name must be minimum of two characters long.', 'address_1': 'Address must be minimum of two characters long.',
'city': 'Last name must be minimum of two characters long.', 'city': 'City must be minimum of two characters long.',
'country': 'Last name must be minimum of two characters long.', 'country': 'Country must be minimum of two characters long.',
} }
js['value'] = error_str[a] js['value'] = error_str[a]
js['field'] = a js['field'] = a
...@@ -789,9 +788,8 @@ def create_test_registration(request, post_override=None): ...@@ -789,9 +788,8 @@ def create_test_registration(request, post_override=None):
# TODO: enable appropriate stat # TODO: enable appropriate stat
# statsd.increment("common.student.account_created") # statsd.increment("common.student.account_created")
# js = {'success': True} js = {'success': True}
# return HttpResponse(json.dumps(js), mimetype="application/json") return HttpResponse(json.dumps(js), mimetype="application/json")
return HttpResponseRedirect(reverse('dashboard'))
def get_random_post_override(): def get_random_post_override():
""" """
......
...@@ -15,19 +15,13 @@ ...@@ -15,19 +15,13 @@
<script type="text/javascript"> <script type="text/javascript">
(function() { (function() {
$(".unenroll").click(function(event) { $(document).on('ajax:success', '#test_register_form', function(data, json, xhr) {
$("#unenroll_course_id").val( $(event.target).data("course-id") );
$("#unenroll_course_number").text( $(event.target).data("course-number") );
});
$(document).delegate('#unenroll_form', 'ajax:success', function(data, json, xhr) {
if(json.success) { if(json.success) {
location.href="${reverse('dashboard')}"; location.href="${reverse('dashboard')}";
} else { } else {
if($('#unenroll_error').length == 0) { $(".field.error").removeClass('error');
$('#unenroll_form').prepend('<div id="unenroll_error" class="modal-form-error"></div>'); $('#register_error').html(json.value).stop().css("display", "block");
} $("[data-field='"+json.field+"']").addClass('field-error')
$('#unenroll_error').text(json.error).stop().css("display", "block");
} }
}); });
...@@ -147,7 +141,6 @@ exam_info = course.testcenter_info ...@@ -147,7 +141,6 @@ exam_info = course.testcenter_info
</div> </div>
<!-- NOTE: BT - registration error message --> <!-- NOTE: BT - registration error message -->
<!-- provide mechanism for error messages to appear -->
% if message: % if message:
<div class="message message-status submission-error"> <div class="message message-status submission-error">
<p class="message-copy">${message}</p> <p class="message-copy">${message}</p>
...@@ -327,7 +320,7 @@ exam_info = course.testcenter_info ...@@ -327,7 +320,7 @@ exam_info = course.testcenter_info
if registration.upload_status == 'Accepted': if registration.upload_status == 'Accepted':
regstatus = "Registration approved by Pearson" regstatus = "Registration approved by Pearson"
elif registration.upload_status == 'Error': elif registration.upload_status == 'Error':
regstatus = "rRgistration rejected by Pearson: %s" % registration.upload_error_message regstatus = "Registration rejected by Pearson: %s" % registration.upload_error_message
elif len(registration.accommodation_request) > 0 and registration.accommodation_code == '': elif len(registration.accommodation_request) > 0 and registration.accommodation_code == '':
regstatus = "Pending approval of accommodation request" regstatus = "Pending approval of accommodation request"
%> %>
...@@ -365,7 +358,7 @@ exam_info = course.testcenter_info ...@@ -365,7 +358,7 @@ exam_info = course.testcenter_info
% endif % endif
</p> </p>
</div> </div>
<div class="details details-registration"> <div class="details details-registration">
<!-- NOTE: showing test details --> <!-- NOTE: showing test details -->
<h4>Pearson VUE Test Details</h4> <h4>Pearson VUE Test Details</h4>
......
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