diff options
author | Johan Lundberg <lundberg@nordu.net> | 2011-05-25 11:34:30 +0200 |
---|---|---|
committer | Johan Lundberg <lundberg@nordu.net> | 2011-05-25 11:34:30 +0200 |
commit | a3f00bfc357b07d67f42a4234fa491623b004689 (patch) | |
tree | a8141f0128b32daf05c613ec299d40aea15da2e6 | |
parent | 886180ff618f9ee6ec62e13faba63c05a7c52118 (diff) |
Added *args to change_other. Changed default lenght of reset password to 10.
-rw-r--r-- | templates/changepw/change_other.html | 2 | ||||
-rw-r--r-- | urls.py | 1 | ||||
-rw-r--r-- | views.py | 18 |
3 files changed, 13 insertions, 8 deletions
diff --git a/templates/changepw/change_other.html b/templates/changepw/change_other.html index c3fa637..2131ea4 100644 --- a/templates/changepw/change_other.html +++ b/templates/changepw/change_other.html @@ -11,7 +11,7 @@ <td class="formlabel">Input:</td> </tr> <tr> - <td class="formfield"><input type="textarea" name="input" /></td> + <td class="formfield"><textarea name="input" cols="50" rows="10"></textarea></td> </tr> <tr> <td class="formbutton"><input type="submit" value="Submit" /></td> @@ -6,4 +6,5 @@ urlpatterns = patterns('apps.changepw.views', url(r'^/changepw$', 'change_password', name='changepw'), url(r'^/resetpw$', 'reset_password', name='resetpw'), url(r'^/changeother$', 'change_other', name='changeother'), + url(r'^/[-\w]+$', 'change_other'), ) @@ -1,4 +1,5 @@ from django.contrib.auth.decorators import login_required +from django.http import Http404 from apps.changepw.models import ChangePasswordForm from django.shortcuts import render_to_response from django.template import RequestContext @@ -18,13 +19,16 @@ def _reset_password(request, user, new_password): # ret = your_pw_change_module.reset_password(user, new_password) return 0 -def _change_other(request): +def _change_other(request, *args): ''' Use this to call your change function. ''' - # user = request.user - # ssh_key = request.POST.getattr('ssh_key') - # ret = your_ldap_module.change_public_ssh_key(user, ssh_key) + #if arg in args: + # user = request.user + # ssh_key = request.POST.getattr('ssh_key') + # ret = your_ldap_module.change_public_ssh_key(user, ssh_key) + #else: + # raise Http404 return 0 def _get_username(request): @@ -85,7 +89,7 @@ def reset_password(request): Resets password for the authenticated user to a random string. The function that actually sets the new password has to be provided as func. ''' - password_length = 8 # chars + password_length = 10 # chars username = _get_username(request) if request.method == 'POST': new_password = _generate_password(password_length) @@ -100,13 +104,13 @@ def reset_password(request): context_instance=RequestContext(request)) @login_required(login_url='/sso/accounts/login/') -def change_other(request): +def change_other(request, *args): ''' Just passes along the request so that something can be done for that user. ''' username = _get_username(request) if request.method == 'POST': - return_value = _change_other(request) + return_value = _change_other(request, *args) return render_to_response('changepw/change_other.html', {'username': username, 'return_value': return_value}, context_instance=RequestContext(request)) |