add functionality to disable users
add middleware to detect students with disabled accounts add tests
This commit is contained in:
@@ -569,6 +569,7 @@ MIDDLEWARE_CLASSES = (
|
||||
# Instead of AuthenticationMiddleware, we use a cached backed version
|
||||
#'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'cache_toolbox.middleware.CacheBackedAuthenticationMiddleware',
|
||||
'student.middleware.UserStandingMiddleware',
|
||||
'contentserver.middleware.StaticContentServer',
|
||||
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
<%! from django.utils.translation import ugettext as _ %>
|
||||
|
||||
<%inherit file="main.html" />
|
||||
|
||||
<%namespace name='static' file='static_content.html'/>
|
||||
|
||||
56
lms/templates/manage_user_standing.html
Normal file
56
lms/templates/manage_user_standing.html
Normal file
@@ -0,0 +1,56 @@
|
||||
<%inherit file="main.html" />
|
||||
|
||||
<%! from django.core.urlresolvers import reverse %>
|
||||
<%! from django.utils.translation import ugettext as _ %>
|
||||
|
||||
<h2>${_("Disable or Reenable student accounts")}</h2>
|
||||
<form action="${reverse('disable_account_ajax')}" method="post" data-remote="true" id="disable-form">
|
||||
<label for="username">${_("Username:")}</label>
|
||||
<input type="text" id="username" name="username" required="true">
|
||||
<br>
|
||||
<label for="account_action">${_("Disable Account")}</label>
|
||||
<input type="radio" name="account_action" value="disable" id="account_action">
|
||||
<br>
|
||||
<label for="account_action">${_("Reenable Account")}</label>
|
||||
<input type="radio" name="account_action" value="reenable" id="account_action">
|
||||
<br>
|
||||
<br>
|
||||
</form>
|
||||
|
||||
<button id="submit-form">${_("Submit")}</button>
|
||||
<br>
|
||||
<br>
|
||||
<p id="account-change-status"></p>
|
||||
<h2>${_("Students whose accounts have been disabled")}</h2>
|
||||
<p>${_("(reload your page to refresh)")}</p>
|
||||
<table id="account-table" border='1'>
|
||||
<tr>
|
||||
% for header in headers:
|
||||
<th>${header}</th>
|
||||
% endfor
|
||||
</tr>
|
||||
% for row in rows:
|
||||
<tr>
|
||||
% for cell in row:
|
||||
<td>${cell}</td>
|
||||
% endfor
|
||||
</tr>
|
||||
% endfor
|
||||
</table>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
var form = $("#disable-form");
|
||||
$("#submit-form").click(function(){
|
||||
$("#account-change-status").html(gettext("working..."));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: form.attr('action'),
|
||||
data: form.serialize(),
|
||||
success: function(response){
|
||||
$("#account-change-status").html(response.message);
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -30,6 +30,10 @@ urlpatterns = ('', # nopep8
|
||||
url(r'^t/(?P<template>[^/]*)$', 'static_template_view.views.index'), # TODO: Is this used anymore? What is STATIC_GRAB?
|
||||
|
||||
url(r'^accounts/login$', 'student.views.accounts_login', name="accounts_login"),
|
||||
url(r'^accounts/manage_user_standing', 'student.views.manage_user_standing',
|
||||
name='manage_user_standing'),
|
||||
url(r'^accounts/disable_account_ajax$', 'student.views.disable_account_ajax',
|
||||
name="disable_account_ajax"),
|
||||
|
||||
url(r'^login_ajax$', 'student.views.login_user', name="login"),
|
||||
url(r'^login_ajax/(?P<error>[^/]*)$', 'student.views.login_user'),
|
||||
|
||||
Reference in New Issue
Block a user