Commit 2f11ee91 by David Ormsbee

Re-enable change name, and fix up change email styles

parent 123c0276
...@@ -672,9 +672,12 @@ def change_name_request(request): ...@@ -672,9 +672,12 @@ def change_name_request(request):
pnc.rationale = request.POST['rationale'] pnc.rationale = request.POST['rationale']
if len(pnc.new_name) < 2: if len(pnc.new_name) < 2:
return HttpResponse(json.dumps({'success': False, 'error': 'Name required'})) return HttpResponse(json.dumps({'success': False, 'error': 'Name required'}))
if len(pnc.rationale) < 2:
return HttpResponse(json.dumps({'success': False, 'error': 'Rationale required'}))
pnc.save() 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 HttpResponse(json.dumps({'success': True})) return HttpResponse(json.dumps({'success': True}))
...@@ -709,14 +712,9 @@ def reject_name_change(request): ...@@ -709,14 +712,9 @@ def reject_name_change(request):
return HttpResponse(json.dumps({'success': True})) return HttpResponse(json.dumps({'success': True}))
@ensure_csrf_cookie def accept_name_change_by_id(id):
def accept_name_change(request):
''' JSON: Name change process. Course staff clicks 'accept' on a given name change '''
if not request.user.is_staff:
raise Http404
try: try:
pnc = PendingNameChange.objects.get(id=int(request.POST['id'])) pnc = PendingNameChange.objects.get(id=id)
except PendingNameChange.DoesNotExist: except PendingNameChange.DoesNotExist:
return HttpResponse(json.dumps({'success': False, 'error': 'Invalid ID'})) return HttpResponse(json.dumps({'success': False, 'error': 'Invalid ID'}))
...@@ -735,3 +733,12 @@ def accept_name_change(request): ...@@ -735,3 +733,12 @@ def accept_name_change(request):
pnc.delete() pnc.delete()
return HttpResponse(json.dumps({'success': True})) return HttpResponse(json.dumps({'success': True}))
@ensure_csrf_cookie
def accept_name_change(request):
''' JSON: Name change process. Course staff clicks 'accept' on a given name change '''
if not request.user.is_staff:
raise Http404
return accept_name_change_by_id(int(request.POST['id']))
...@@ -46,16 +46,33 @@ ...@@ -46,16 +46,33 @@
function(data) { function(data) {
if (data.success) { if (data.success) {
$("#change_email_title").html("Please verify your new email"); $("#change_email_title").html("Please verify your new email");
$("#change_email_body").html("<p>You'll receive a confirmation in your " + $("#change_email_form").html("<p>You'll receive a confirmation in your " +
"in-box. Please click the link in the " + "in-box. Please click the link in the " +
"email to confirm the email change.</p>"); "email to confirm the email change.</p>");
} else { } else {
$("#change_email_error").html(data.error); $("#change_email_error").html(data.error).stop().css("display", "block");
} }
}); });
return false; return false;
}); });
$("#change_name_form").submit(function(){
var new_name = $('#new_name_field').val();
var rationale = $('#name_rationale_field').val();
$.post('${reverse("change_name")}',
{"new_name":new_name, "rationale":rationale},
function(data) {
if(data.success) {
location.reload();
// $("#change_name_body").html("<p>Name changed.</p>");
} else {
$("#change_name_error").html(data.error).stop().css("display", "block");
}
});
return false;
});
})(this) })(this)
</script> </script>
</%block> </%block>
...@@ -75,13 +92,13 @@ ...@@ -75,13 +92,13 @@
<section class="user-info"> <section class="user-info">
<ul> <ul>
<li> <li>
<span class="title"><div class="icon name-icon"></div>Full Name</span> <span class="data">${ user.profile.name | h }</span> <span class="title"><div class="icon name-icon"></div>Full Name (<a href="#apply_name_change" rel="leanModal" class="edit-name">edit</a>)</span> <span class="data">${ user.profile.name | h }</span>
</li> </li>
<li> <li>
<span class="title"><div class="icon email-icon"></div>Email (<a href="#change_email" rel="leanModal" class="edit-email">edit</a>)</span> <span class="data">${ user.email | h }</span> <span class="title"><div class="icon email-icon"></div>Email (<a href="#change_email" rel="leanModal" class="edit-email">edit</a>)</span> <span class="data">${ user.email | h }</span>
</li> </li>
<li> <li>
<span class="title"><a href="#" id="pwd_reset_button">Reset Password</a></span> <span class="title"><a href="#password_reset_complete" rel="leanModal" id="pwd_reset_button">Reset Password</a></span>
<form id="password_reset_form" method="post" data-remote="true" action="${reverse('password_reset')}"> <form id="password_reset_form" method="post" data-remote="true" action="${reverse('password_reset')}">
<input id="id_email" type="hidden" name="email" maxlength="75" value="${user.email}" /> <input id="id_email" type="hidden" name="email" maxlength="75" value="${user.email}" />
<!-- <input type="submit" id="pwd_reset_button" value="Reset Password" /> --> <!-- <input type="submit" id="pwd_reset_button" value="Reset Password" /> -->
...@@ -180,15 +197,16 @@ ...@@ -180,15 +197,16 @@
<section id="password_reset_complete" class="modal"> <section id="password_reset_complete" class="modal">
<div class="inner-wrapper"> <div class="inner-wrapper">
<a href="#password_reset_complete" rel="leanModal" id="password_reset_complete_link"></a> <header>
<h2>Password Reset Email Sent</h2>
<hr/>
</header>
<div> <div>
<header> <form> <!-- Here for styling reasons -->
<h2>Password Reset Email Sent</h2> <section>
<hr/> <p>An email has been sent to ${user.email}. Follow the link in the email to change your password.</p>
</header> </section>
<section> </form>
<p><span>An email has been sent to ${user.email}. Follow the link in the email to change your password.</span></p>
</section>
</div> </div>
<div class="close-modal"> <div class="close-modal">
<div class="inner"> <div class="inner">
...@@ -198,32 +216,60 @@ ...@@ -198,32 +216,60 @@
</div> </div>
</section> </section>
<!-- Haven't Adapted this Yet -->
<section id="change_email" class="modal"> <section id="change_email" class="modal">
<div class="inner-wrapper"> <div class="inner-wrapper">
<header> <header>
<h2><span id="change_email_title">Change e-mail</span></h2> <h2><span id="change_email_title">Change Email</span></h2>
<hr/> <hr/>
</header> </header>
<div id="apply_name_change_error"></div>
<div id="change_email_body"> <div id="change_email_body">
<form id="change_email_form"> <form id="change_email_form">
<div id="change_email_error"> </div> <div id="change_email_error" class="modal-form-error"> </div>
<fieldset> <fieldset>
<ul> <div class="input-group">
<li> <label>Please enter your new email address:</label>
<label>Please enter your new email address:</label> <input id="new_email_field" type="email" value="" />
<input id="new_email_field" type="email" value="" /> <label>Please confirm your password:</label>
</li> <input id="new_email_password" value="" type="password" />
<li> </div>
<label>Please confirm your password:</label>
<input id="new_email_password" value="" type="password" />
</li>
</ul>
<section> <section>
<p>We will send a confirmation to both ${user.email} and your new e-mail as part of the process.</p> <p>We will send a confirmation to both ${user.email} and your new email as part of the process.</p>
</section> </section>
<input type="submit" id="submit_email_change" /> <div class="submit">
<input type="submit" id="submit_email_change" value="Change Email"/>
</div>
</fieldset>
</form>
</div>
<div class="close-modal">
<div class="inner">
<p>&#10005;</p>
</div>
</div>
</div>
</section>
<section id="apply_name_change" class="modal">
<div class="inner-wrapper">
<header>
<h2>Change your name</h2>
<hr/>
</header>
<div id="change_name_body">
<form id="change_name_form">
<div id="change_name_error" class="modal-form-error"> </div>
<p>To uphold the credibility of edX certificates, all name changes will be logged and recorded.</p>
<br/>
<fieldset>
<div class="input-group">
<label>Enter your desired full name, as it will appear on the edX certificates: </label>
<input id="new_name_field" value="" type="text" />
<label>Reason for name change:</label>
<textarea id="name_rationale_field" value=""></textarea>
</div>
<div class="submit">
<input type="submit" id="submit" value="Change My Name">
</div>
</fieldset> </fieldset>
</form> </form>
</div> </div>
...@@ -234,3 +280,4 @@ ...@@ -234,3 +280,4 @@
</div> </div>
</div> </div>
</section> </section>
<h1>E-mail change successful!</h1> <h1>E-mail change successful!</h1>
<p> You should see your new name in your profile. <p>You should see your new name in your <a href="/dashboard">dashboard</a>.</p>
\ No newline at end of file
...@@ -21,7 +21,7 @@ urlpatterns = ('', ...@@ -21,7 +21,7 @@ urlpatterns = ('',
url(r'^change_email$', 'student.views.change_email_request', name="change_email"), url(r'^change_email$', 'student.views.change_email_request', name="change_email"),
url(r'^email_confirm/(?P<key>[^/]*)$', 'student.views.confirm_email_change'), url(r'^email_confirm/(?P<key>[^/]*)$', 'student.views.confirm_email_change'),
url(r'^change_name$', 'student.views.change_name_request'), url(r'^change_name$', 'student.views.change_name_request', name="change_name"),
url(r'^accept_name_change$', 'student.views.accept_name_change'), url(r'^accept_name_change$', 'student.views.accept_name_change'),
url(r'^reject_name_change$', 'student.views.reject_name_change'), url(r'^reject_name_change$', 'student.views.reject_name_change'),
url(r'^pending_name_changes$', 'student.views.pending_name_changes'), url(r'^pending_name_changes$', 'student.views.pending_name_changes'),
......
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