diff options
-rw-r--r-- | models.py | 6 | ||||
-rw-r--r-- | templates/changepw/change_other.html | 34 | ||||
-rw-r--r-- | views.py | 27 |
3 files changed, 65 insertions, 2 deletions
@@ -1,4 +1,3 @@ -from django.db import models from django import forms import re @@ -33,5 +32,8 @@ case letter and one lower case letter in your password.') if not re.search('[,.\[\]!@#$%^&*?_\(\)-]', new_password): raise forms.ValidationError('You need at least one special \ character i.e. ,.][!@#$%^&*?_()-') - return cleaned_data + + +class ChangeOtherForm(forms.Form): + new_attrib = forms.Textarea()
\ No newline at end of file diff --git a/templates/changepw/change_other.html b/templates/changepw/change_other.html new file mode 100644 index 0000000..492e98c --- /dev/null +++ b/templates/changepw/change_other.html @@ -0,0 +1,34 @@ +{% extends "base.html" %} +{% block js %} +{% endblock %} +{% block title %}Change other{% endblock %} +{% block content %} +<h2>Change other</h2> +{% if form %} + <p class="error"> + {{ form.non_field_errors }} + </p> + <form action="{% url changeother %}" method="post" autocomplete="off">{% csrf_token %} + <table> + {% for field in form %} + <tr> + <td class="fielderrors">{{ field.errors }}</td> + </tr> + <tr> + <th class="formlabel">{{ field.label_tag }}:</th><td class="formfield">{{ field }}</td><td><span class="password_strength"></span></td> + </tr> + {% endfor %} + </table> + <input type="submit" value="Submit" /> + </form> +{% else %} + <p>Something went wrong. Please contact an administrator.</p> + <p>Return code: {{ return_value }}</p> +{% endif %} + +<p> + <a href="{% url index %}">Back</a><br /> + <a href="{% url logout %}">Log out</a> +</p> +{% endblock %} + @@ -17,6 +17,15 @@ def _reset_password(request, user, new_password): ''' # ret = your_pw_change_module.reset_password(user, new_password) return 0 + +def _change_other(request): + ''' + 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) + return 0 def _get_username(request): ''' @@ -89,3 +98,21 @@ def reset_password(request): return render_to_response('changepw/reset_password.html', {'username': username, 'return_value': None}, context_instance=RequestContext(request)) + +@login_required(login_url='/sso/accounts/login/') +def change_other(request): + ''' + 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 render_to_response('changepw/change_other.html', + {'username': username, 'return_value': return_value}, + context_instance=RequestContext(request)) + else: + form = ChangePasswordForm() + return render_to_response('changepw/change_other.html', + {'username': username, 'return_value': None, + 'form': form}, + context_instance=RequestContext(request)) |