Reverification iOS support and refactor
* Delete reverification templates * Delete photocapture.js * Delete unused "name change" end-points * Rebuild the reverification views using Backbone sub-views * Stop passing template names to the JavaScript code * Avoid hard-coding the parent view ID in the webcam view (for getting the capture click sound URL)
This commit is contained in:
@@ -119,7 +119,6 @@ class ChooseModeView(View):
|
||||
"course_num": course.display_number_with_default,
|
||||
"chosen_price": chosen_price,
|
||||
"error": error,
|
||||
"can_audit": "audit" in modes,
|
||||
"responsive": True
|
||||
}
|
||||
if "verified" in modes:
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
"""
|
||||
Unit tests for change_name view of student.
|
||||
"""
|
||||
import json
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.test.client import Client
|
||||
from django.test import TestCase
|
||||
|
||||
from student.tests.factories import UserFactory
|
||||
from student.models import UserProfile
|
||||
import unittest
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
class TestChangeName(TestCase):
|
||||
"""
|
||||
Check the change_name view of student.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestChangeName, self).setUp()
|
||||
self.student = UserFactory.create(password='test')
|
||||
self.client = Client()
|
||||
|
||||
def test_change_name_get_request(self):
|
||||
"""Get requests are not allowed in this view."""
|
||||
change_name_url = reverse('change_name')
|
||||
resp = self.client.get(change_name_url)
|
||||
self.assertEquals(resp.status_code, 405)
|
||||
|
||||
def test_change_name_post_request(self):
|
||||
"""Name will be changed when provided with proper data."""
|
||||
self.client.login(username=self.student.username, password='test')
|
||||
change_name_url = reverse('change_name')
|
||||
resp = self.client.post(change_name_url, {
|
||||
'new_name': 'waqas',
|
||||
'rationale': 'change identity'
|
||||
})
|
||||
response_data = json.loads(resp.content)
|
||||
user = UserProfile.objects.get(user=self.student.id)
|
||||
meta = json.loads(user.meta)
|
||||
self.assertEquals(user.name, 'waqas')
|
||||
self.assertEqual(meta['old_names'][0][1], 'change identity')
|
||||
self.assertTrue(response_data['success'])
|
||||
|
||||
def test_change_name_without_name(self):
|
||||
"""Empty string for name is not allowed in this view."""
|
||||
self.client.login(username=self.student.username, password='test')
|
||||
change_name_url = reverse('change_name')
|
||||
resp = self.client.post(change_name_url, {
|
||||
'new_name': '',
|
||||
'rationale': 'change identity'
|
||||
})
|
||||
response_data = json.loads(resp.content)
|
||||
self.assertFalse(response_data['success'])
|
||||
|
||||
def test_unauthenticated(self):
|
||||
"""Unauthenticated user is not allowed to call this view."""
|
||||
change_name_url = reverse('change_name')
|
||||
resp = self.client.post(change_name_url, {
|
||||
'new_name': 'waqas',
|
||||
'rationale': 'change identity'
|
||||
})
|
||||
self.assertEquals(resp.status_code, 404)
|
||||
@@ -2078,66 +2078,6 @@ def confirm_email_change(request, key): # pylint: disable=unused-argument
|
||||
raise
|
||||
|
||||
|
||||
# TODO: DELETE AFTER NEW ACCOUNT PAGE DONE
|
||||
@ensure_csrf_cookie
|
||||
@require_POST
|
||||
def change_name_request(request):
|
||||
""" Log a request for a new name. """
|
||||
if not request.user.is_authenticated():
|
||||
raise Http404
|
||||
|
||||
try:
|
||||
pnc = PendingNameChange.objects.get(user=request.user.id)
|
||||
except PendingNameChange.DoesNotExist:
|
||||
pnc = PendingNameChange()
|
||||
pnc.user = request.user
|
||||
pnc.new_name = request.POST['new_name'].strip()
|
||||
pnc.rationale = request.POST['rationale']
|
||||
if len(pnc.new_name) < 2:
|
||||
return JsonResponse({
|
||||
"success": False,
|
||||
"error": _('Name required'),
|
||||
}) # TODO: this should be status code 400 # pylint: disable=fixme
|
||||
pnc.save()
|
||||
|
||||
# The following automatically accepts name change requests. Remove this to
|
||||
# go back to the old system where it gets queued up for admin approval.
|
||||
accept_name_change_by_id(pnc.id)
|
||||
|
||||
return JsonResponse({"success": True})
|
||||
|
||||
|
||||
# TODO: DELETE AFTER NEW ACCOUNT PAGE DONE
|
||||
def accept_name_change_by_id(uid):
|
||||
"""
|
||||
Accepts the pending name change request for the user represented
|
||||
by user id `uid`.
|
||||
"""
|
||||
try:
|
||||
pnc = PendingNameChange.objects.get(id=uid)
|
||||
except PendingNameChange.DoesNotExist:
|
||||
return JsonResponse({
|
||||
"success": False,
|
||||
"error": _('Invalid ID'),
|
||||
}) # TODO: this should be status code 400 # pylint: disable=fixme
|
||||
|
||||
user = pnc.user
|
||||
u_prof = UserProfile.objects.get(user=user)
|
||||
|
||||
# Save old name
|
||||
meta = u_prof.get_meta()
|
||||
if 'old_names' not in meta:
|
||||
meta['old_names'] = []
|
||||
meta['old_names'].append([u_prof.name, pnc.rationale, datetime.datetime.now(UTC).isoformat()])
|
||||
u_prof.set_meta(meta)
|
||||
|
||||
u_prof.name = pnc.new_name
|
||||
u_prof.save()
|
||||
pnc.delete()
|
||||
|
||||
return JsonResponse({"success": True})
|
||||
|
||||
|
||||
@require_POST
|
||||
@login_required
|
||||
@ensure_csrf_cookie
|
||||
|
||||
@@ -4,13 +4,9 @@ from django.utils.translation import ugettext as _
|
||||
from django.core.urlresolvers import reverse
|
||||
%>
|
||||
|
||||
<%block name="bodyclass">register verification-process step-select-track ${'is-upgrading' if upgrade else ''}</%block>
|
||||
<%block name="bodyclass">register verification-process step-select-track</%block>
|
||||
<%block name="pagetitle">
|
||||
% if upgrade:
|
||||
${_("Upgrade Your Enrollment for {} | Choose Your Track").format(course_name)}
|
||||
% else:
|
||||
${_("Enroll In {} | Choose Your Track").format(course_name)}
|
||||
%endif
|
||||
${_("Enroll In {} | Choose Your Track").format(course_name)}
|
||||
</%block>
|
||||
|
||||
<%block name="js_extra">
|
||||
@@ -65,7 +61,11 @@ from django.core.urlresolvers import reverse
|
||||
<section class="wrapper">
|
||||
<div class="wrapper-register-choose wrapper-content-main">
|
||||
<article class="register-choose content-main">
|
||||
<%include file="/verify_student/_verification_header.html" args="course_name=course_name" />
|
||||
<header class="page-header content-main">
|
||||
<h3 class="title">
|
||||
${_("Congratulations! You are now enrolled in {course_name}").format(course_name=course_name)}
|
||||
</h3>
|
||||
</header>
|
||||
|
||||
<form class="form-register-choose" method="post" name="enrollment_mode_form" id="enrollment_mode_form">
|
||||
% if "verified" in modes:
|
||||
@@ -129,36 +129,32 @@ from django.core.urlresolvers import reverse
|
||||
</div>
|
||||
% endif
|
||||
|
||||
% if not upgrade:
|
||||
% if "honor" in modes:
|
||||
<span class="deco-divider">
|
||||
<span class="copy">${_("or")}</span>
|
||||
</span>
|
||||
% if "honor" in modes:
|
||||
<span class="deco-divider">
|
||||
<span class="copy">${_("or")}</span>
|
||||
</span>
|
||||
|
||||
<div class="register-choice register-choice-audit">
|
||||
<div class="wrapper-copy">
|
||||
<span class="deco-ribbon"></span>
|
||||
<h4 class="title">${_("Audit This Course")}</h4>
|
||||
<div class="copy">
|
||||
<p>${_("Audit this course for free and have complete access to all the course material, activities, tests, and forums. If your work is satisfactory and you abide by the Honor Code, you'll receive a personalized Honor Code Certificate to showcase your achievement.")}</p>
|
||||
</div>
|
||||
<div class="register-choice register-choice-audit">
|
||||
<div class="wrapper-copy">
|
||||
<span class="deco-ribbon"></span>
|
||||
<h4 class="title">${_("Audit This Course")}</h4>
|
||||
<div class="copy">
|
||||
<p>${_("Audit this course for free and have complete access to all the course material, activities, tests, and forums. If your work is satisfactory and you abide by the Honor Code, you'll receive a personalized Honor Code Certificate to showcase your achievement.")}</p>
|
||||
</div>
|
||||
|
||||
<ul class="list-actions">
|
||||
<li class="action action-select">
|
||||
<input type="submit" name="honor_mode" value="${_('Audit This Course')}" />
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
% endif
|
||||
|
||||
<ul class="list-actions">
|
||||
<li class="action action-select">
|
||||
<input type="submit" name="honor_mode" value="${_('Audit This Course')}" />
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
% endif
|
||||
|
||||
<input type="hidden" name="csrfmiddlewaretoken" value="${ csrf_token }">
|
||||
</form>
|
||||
</article>
|
||||
</div> <!-- /wrapper-content-main -->
|
||||
|
||||
<%include file="/verify_student/_verification_support.html" />
|
||||
</section>
|
||||
</div>
|
||||
</%block>
|
||||
|
||||
Reference in New Issue
Block a user