From 96bdd03406896746db38f1daabfc80a1a44a5b6a Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Fri, 12 Oct 2012 09:54:47 -0400 Subject: [PATCH] re-enable email change functionality --- lms/templates/dashboard.html | 119 ++++++++++++++++++++++++++++++----- lms/urls.py | 2 +- 2 files changed, 104 insertions(+), 17 deletions(-) diff --git a/lms/templates/dashboard.html b/lms/templates/dashboard.html index 6be72277cc..9b59dc2cd9 100644 --- a/lms/templates/dashboard.html +++ b/lms/templates/dashboard.html @@ -16,19 +16,46 @@ $(".unenroll").click(function(event) { $("#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) { - location.href="${reverse('dashboard')}"; - } else { - if($('#unenroll_error').length == 0) { - $('#unenroll_form').prepend(''); - } - $('#unenroll_error').text(json.error).stop().css("display", "block"); - } - }); + $(document).delegate('#unenroll_form', 'ajax:success', function(data, json, xhr) { + if(json.success) { + location.href="${reverse('dashboard')}"; + } else { + if($('#unenroll_error').length == 0) { + $('#unenroll_form').prepend(''); + } + $('#unenroll_error').text(json.error).stop().css("display", "block"); + } + }); + + $('#pwd_reset_button').click(function() { + $.post('${reverse("password_reset")}', + {"email" : $('#id_email').val()}, + function(data){ + $("#password_reset_complete_link").click(); + }); + }); + + $("#change_email_form").submit(function(){ + var new_email = $('#new_email_field').val(); + var new_password = $('#new_email_password').val(); + + $.post('${reverse("change_email")}', + {"new_email" : new_email, "password" : new_password}, + function(data) { + if (data.success) { + $("#change_email_title").html("Please verify your new email"); + $("#change_email_body").html("

You'll receive a confirmation in your " + + "in-box. Please click the link in the " + + "email to confirm the email change.

"); + } else { + $("#change_email_error").html(data.error); + } + }); + return false; + }); + })(this) @@ -48,10 +75,17 @@
@@ -121,13 +155,11 @@ - - + + + diff --git a/lms/urls.py b/lms/urls.py index 662e41235e..ac61b85248 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -19,7 +19,7 @@ urlpatterns = ('', # (specifically missing get parameters in certain cases) url(r'^debug_request$', 'util.views.debug_request'), - url(r'^change_email$', 'student.views.change_email_request'), + url(r'^change_email$', 'student.views.change_email_request', name="change_email"), url(r'^email_confirm/(?P[^/]*)$', 'student.views.confirm_email_change'), url(r'^change_name$', 'student.views.change_name_request'), url(r'^accept_name_change$', 'student.views.accept_name_change'),