Added password changing for non-ldap user

This commit is contained in:
Sebastian Lohff 2011-10-21 03:05:07 +02:00
parent b458cfaead
commit eaf1551fa1
2 changed files with 29 additions and 4 deletions

View File

@ -3,7 +3,21 @@
{% block "content" %} {% block "content" %}
<div style="width:800px"> <div style="width:800px">
<h1>Passwort</h1> <h1>Passwort</h1>
Da die meisten der Nutzer dieses Systems &uuml;ber den LDAP der Freitagsrunde laufen, kann man hier sein Passwort nicht &auml;ndern. Wenn du dein Passwort trotzdem &auml;ndern m&ouml;chstest (und dieses System nicht &uuml;ber einen Freitagsrundenaccount benutzt), wende dich bitte an einen der Freitagsrunden-Admins. (lies: not implemented) <br />
{% if form %}
{% if password_success %}
{{ password_success }} <br />
{% endif %}
<table>
<form method="post" action="#">
{% csrf_token %}
{{ form }}
<tr><th align="center" colspan="2"><input type="submit" value="&Auml;ndern" /></th></tr>
</form>
</table>
{% else %}
Da du dich nicht &uuml;ber Django authentifizierst (sondern z.B. &uuml;ber LDAP) kannst du dein Passwort hier nicht &auml;ndern.
{% endif %}
</div> </div>
<div style="width:800px; margin-top: 25px"> <div style="width:800px; margin-top: 25px">
<h1>Pluginberechtigungen</h1> <h1>Pluginberechtigungen</h1>

View File

@ -5,7 +5,7 @@ from django.contrib.auth.decorators import login_required
from django.db.models import Count from django.db.models import Count
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from main.models import Plugin, PluginPermission from main.models import Plugin, PluginPermission
from django.contrib.auth.forms import PasswordChangeForm
from buyable.models import Purchase, Buyable, BuyableType from buyable.models import Purchase, Buyable, BuyableType
@login_required @login_required
@ -62,12 +62,23 @@ def getPluginDict(request):
unallowed = Plugin.objects.exclude(pluginpermission__user=request.user) unallowed = Plugin.objects.exclude(pluginpermission__user=request.user)
perms = PluginPermission.objects.filter(user=request.user) perms = PluginPermission.objects.filter(user=request.user)
return {'plugins': plugins, 'allowed': allowed, 'unallowed': unallowed, 'permissions': perms} form = None
if request.user.has_usable_password():
form = PasswordChangeForm(request.user)
return {'plugins': plugins, 'allowed': allowed, 'unallowed': unallowed, 'permissions': perms, 'form': form}
@login_required @login_required
def settings(request): def settings(request):
""" Render settings page. """ """ Render settings page. """
return render_to_response("settings/settings.html", getPluginDict(request), RequestContext(request)) pdict = getPluginDict(request)
if request.method == "POST":
form = PasswordChangeForm(request.user, data=request.POST)
if form.is_valid():
form.save()
pdict['password_success'] = "Es wurde ein neues Passwort gesetzt."
pdict['form'] = form
return render_to_response("settings/settings.html", pdict, RequestContext(request))
@login_required @login_required
def pluginPermission(request, method, pluginId): def pluginPermission(request, method, pluginId):