diff --git a/lms/djangoapps/verify_student/urls.py b/lms/djangoapps/verify_student/urls.py index 15c2cc5f6b..843ebf9602 100644 --- a/lms/djangoapps/verify_student/urls.py +++ b/lms/djangoapps/verify_student/urls.py @@ -35,4 +35,15 @@ urlpatterns = patterns( name="verify_student_results_callback", ), + url( + r'^reverify$', + views.ReverifyView.as_view(), + name="verify_student_reverify" + ), + + url( + r'^reverification_confirmation$', + views.reverification_submission_confirmation, + name="verify_student_reverification_confirmation" + ), ) diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index 8fafc26834..673564e72c 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -267,3 +267,66 @@ def show_requirements(request, course_id): "upgrade": upgrade, } return render_to_response("verify_student/show_requirements.html", context) + + +class ReverifyView(View): + """ + The main reverification view. Under similar constraints as the main verification view. + Has to perform these functions: + - take new face photo + - take new id photo + - submit photos to photo verification service + + Does not need to be attached to a particular course. + Does not need to worry about pricing + """ + @method_decorator(login_required) + def get(self, request): + """ + display this view + """ + context = { + "user_full_name": request.user.profile.name, + "error": False, + } + + return render_to_response("verify_student/photo_reverification.html", context) + + @method_decorator(login_required) + def post(self, request): + """ + submits the reverification to SoftwareSecure + """ + + try: + attempt = SoftwareSecurePhotoVerification(user=request.user) + b64_face_image = request.POST['face_image'].split(",")[1] + b64_photo_id_image = request.POST['photo_id_image'].split(",")[1] + + attempt.upload_face_image(b64_face_image.decode('base64')) + attempt.upload_photo_id_image(b64_photo_id_image.decode('base64')) + attempt.mark_ready() + + # save this attempt + attempt.save() + # then submit it across + attempt.submit() + return HttpResponseRedirect(reverse('verify_student_reverification_confirmation')) + except Exception: + log.exception( + "Could not submit verification attempt for user {}".format(request.user.id) + ) + context = { + "user_full_name": request.user.profile.name, + "error": True, + } + return render_to_response("verify_student/photo_reverification.html", context) + + +@login_required +def reverification_submission_confirmation(_request): + """ + Shows the user a confirmation page if the submission to SoftwareSecure was successful + """ + + return render_to_response("verify_student/reverification_confirmation.html") diff --git a/lms/static/js/verify_student/photocapture.js b/lms/static/js/verify_student/photocapture.js index 0519767841..4db15e9d51 100644 --- a/lms/static/js/verify_student/photocapture.js +++ b/lms/static/js/verify_student/photocapture.js @@ -18,6 +18,23 @@ function initVideoCapture() { return !(navigator.getUserMedia == undefined); } +var submitReverificationPhotos = function() { + // add photos to the form + $('').attr({ + type: 'hidden', + name: 'face_image', + value: $("#face_image")[0].src, + }).appendTo("#reverify_form"); + $('').attr({ + type: 'hidden', + name: 'photo_id_image', + value: $("#photo_id_image")[0].src, + }).appendTo("#reverify_form"); + + $("#reverify_form").submit(); + +} + var submitToPaymentProcessing = function() { var contribution_input = $("input[name='contribution']:checked") var contribution = 0; @@ -255,10 +272,15 @@ $(document).ready(function() { submitToPaymentProcessing(); }); + $("#reverify_button").click(function() { + submitReverificationPhotos(); + }); + // prevent browsers from keeping this button checked $("#confirm_pics_good").prop("checked", false) $("#confirm_pics_good").change(function() { $("#pay_button").toggleClass('disabled'); + $("#reverify_button").toggleClass('disabled'); }); diff --git a/lms/templates/verify_student/photo_reverification.html b/lms/templates/verify_student/photo_reverification.html new file mode 100644 index 0000000000..764458b791 --- /dev/null +++ b/lms/templates/verify_student/photo_reverification.html @@ -0,0 +1,394 @@ +<%! from django.utils.translation import ugettext as _ %> +<%! from django.core.urlresolvers import reverse %> +<%inherit file="../main.html" /> +<%namespace name='static' file='/static_content.html'/> + +<%block name="bodyclass">register verification-process step-photos +<%block name="title">${_("Re-Verification")} + +<%block name="js_extra"> + + + + + + +<%block name="content"> + + + + + +%if error: +
+
+ +
+

${_("Error submitting your images")}

+
+

${_("Oops! Something went wrong. Please confirm your details again and try again.")}

+
+
+
+
+%endif + +
+
+ +
+
+

${_("Your Progress")}

+ + +
    +
  1. + 0 + ${_("Intro")} +
  2. + +
  3. + 1 + ${_("Current Step: ")}${_("Take Photo")} +
  4. + +
  5. + 2 + ${_("Take ID Photo")} +
  6. + +
  7. + 3 + ${_("Review")} +
  8. + +
  9. + 4 + ${_("Make Payment")} +
  10. + +
  11. + + + + ${_("Confirmation")} +
  12. +
+ + + + +
+
+ +
+
+ + +
+
+ +
+
+ +<%include file="_modal_editname.html" /> + diff --git a/lms/templates/verify_student/reverification_confirmation.html b/lms/templates/verify_student/reverification_confirmation.html new file mode 100644 index 0000000000..2ab639effc --- /dev/null +++ b/lms/templates/verify_student/reverification_confirmation.html @@ -0,0 +1,18 @@ + +<%! from django.utils.translation import ugettext as _ %> +<%! from django.core.urlresolvers import reverse %> +<%inherit file="../main.html" /> +<%namespace name='static' file='/static_content.html'/> + +<%block name="bodyclass">register verification-process step-photos +<%block name="title">${_("Verification Submission Confirmation")} + +<%block name="js_extra"> + + + +<%block name="content"> +

Successfully reverified!

+ +

Return to Dashboard

+