fnp
/
cas.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Templates.
[cas.git]
/
src
/
accounts
/
views.py
diff --git
a/src/accounts/views.py
b/src/accounts/views.py
index
b00dd20
..
9a95608
100644
(file)
--- a/
src/accounts/views.py
+++ b/
src/accounts/views.py
@@
-1,16
+1,20
@@
# Create your views here.
from django import http
# Create your views here.
from django import http
-from django.utils.translation import ugettext as __
-from django.views.generic.simple import direct_to_template
-from django.views.decorators.http import require_POST
from django.contrib.auth.decorators import login_required
from django.contrib.auth.decorators import login_required
+from django.contrib.auth import update_session_auth_hash
+from django.contrib import messages
+from django.shortcuts import render
+from django.utils.translation import ugettext as _
+from django.views.decorators.http import require_POST
from accounts.forms import UserBasicForm, UserPasswordForm
from accounts.forms import UserBasicForm, UserPasswordForm
+from .models import Service
@login_required
def account_profile(request, basic_form=None, pass_form=None):
@login_required
def account_profile(request, basic_form=None, pass_form=None):
- return
direct_to_template
(request, "account/profile.html", {
+ return
render
(request, "account/profile.html", {
"basic_form": basic_form or UserBasicForm(instance=request.user),
"pass_form": pass_form or UserPasswordForm(),
"basic_form": basic_form or UserBasicForm(instance=request.user),
"pass_form": pass_form or UserPasswordForm(),
+ "services": Service.objects.all(),
})
})
@@
-21,7
+25,7
@@
def account_change_basic_profile(request):
if form.is_valid():
form.save()
if form.is_valid():
form.save()
-
request.user.message_set.create(message=_
_("Profile has been changed."))
+
messages.add_message(request, messages.INFO,
_("Profile has been changed."))
return http.HttpResponseRedirect('/accounts/')
return account_profile(request, basic_form=form)
return http.HttpResponseRedirect('/accounts/')
return account_profile(request, basic_form=form)
@@
-34,8
+38,9
@@
def account_change_password(request):
if form.is_valid():
request.user.set_password(form.cleaned_data['new_password'])
request.user.save()
if form.is_valid():
request.user.set_password(form.cleaned_data['new_password'])
request.user.save()
+ update_session_auth_hash(request, request.user)
-
request.user.message_set.create(message=_
_("Password has been changed."))
+
messages.add_message(request, messages.INFO,
_("Password has been changed."))
return http.HttpResponseRedirect('/accounts/')
return account_profile(request, pass_form=form)
return http.HttpResponseRedirect('/accounts/')
return account_profile(request, pass_form=form)