Browse Source

Added password changing for non-ldap user

master
Sebastian Lohff 11 years ago
parent
commit
eaf1551fa1
  1. 16
      k4ever/main/templates/settings/settings.html
  2. 17
      k4ever/main/views.py

16
k4ever/main/templates/settings/settings.html

@ -3,7 +3,21 @@ @@ -3,7 +3,21 @@
{% block "content" %}
<div style="width:800px">
<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 style="width:800px; margin-top: 25px">
<h1>Pluginberechtigungen</h1>

17
k4ever/main/views.py

@ -5,7 +5,7 @@ from django.contrib.auth.decorators import login_required @@ -5,7 +5,7 @@ from django.contrib.auth.decorators import login_required
from django.db.models import Count
from django.http import HttpResponseRedirect
from main.models import Plugin, PluginPermission
from django.contrib.auth.forms import PasswordChangeForm
from buyable.models import Purchase, Buyable, BuyableType
@login_required
@ -62,12 +62,23 @@ def getPluginDict(request): @@ -62,12 +62,23 @@ def getPluginDict(request):
unallowed = Plugin.objects.exclude(pluginpermission__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
def settings(request):
""" 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
def pluginPermission(request, method, pluginId):

Loading…
Cancel
Save