[idp] extend the account management page with a profile section
This commit is contained in:
parent
05abd302e9
commit
5d10d7187f
|
@ -8,6 +8,20 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>{% trans "Account Management" %}</h2>
|
<h2>{% trans "Account Management" %}</h2>
|
||||||
|
<h3>{% trans "Profile" %}</h3>
|
||||||
|
<div id="profile">
|
||||||
|
{% if profile %}
|
||||||
|
<dl>
|
||||||
|
{% for key, value in profile %}
|
||||||
|
<dt>{{ key|capfirst }}</dt>
|
||||||
|
<dd>{{ value }}</dd>
|
||||||
|
{% endfor %}
|
||||||
|
</dl>
|
||||||
|
<p> <a href="{% url profiles_edit_profile %}">{% trans "Edit profile" %}</a></p>
|
||||||
|
{% else %}
|
||||||
|
<p> <a href="{% url profiles_create_profile %}">{% trans "Create profile" %}</a></p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
<h3>{% trans "Credentials" %}</h3>
|
<h3>{% trans "Credentials" %}</h3>
|
||||||
{% for html_block in frontends_block %}
|
{% for html_block in frontends_block %}
|
||||||
{{ html_block|safe }}
|
{{ html_block|safe }}
|
||||||
|
|
|
@ -14,6 +14,7 @@ from django.contrib.auth.forms import AuthenticationForm
|
||||||
from django.contrib.auth.forms import PasswordChangeForm
|
from django.contrib.auth.forms import PasswordChangeForm
|
||||||
from django.contrib.auth import logout as auth_logout
|
from django.contrib.auth import logout as auth_logout
|
||||||
from django.contrib.auth import REDIRECT_FIELD_NAME
|
from django.contrib.auth import REDIRECT_FIELD_NAME
|
||||||
|
from django.contrib.auth.models import SiteProfileNotAvailable
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
|
@ -22,6 +23,7 @@ from django.template import RequestContext
|
||||||
from django.utils.encoding import smart_unicode
|
from django.utils.encoding import smart_unicode
|
||||||
from django.views.decorators.csrf import csrf_exempt, csrf_protect
|
from django.views.decorators.csrf import csrf_exempt, csrf_protect
|
||||||
from django.views.generic.simple import redirect_to
|
from django.views.generic.simple import redirect_to
|
||||||
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
|
|
||||||
import authentic2.saml.common
|
import authentic2.saml.common
|
||||||
import authentic2.authsaml2.utils
|
import authentic2.authsaml2.utils
|
||||||
|
@ -69,10 +71,23 @@ def profile(request):
|
||||||
if request.session.test_cookie_worked():
|
if request.session.test_cookie_worked():
|
||||||
request.session.delete_test_cookie()
|
request.session.delete_test_cookie()
|
||||||
return frontend.post(request, form, None, '/profile')
|
return frontend.post(request, form, None, '/profile')
|
||||||
|
# User attributes management
|
||||||
|
try:
|
||||||
|
user_profile = request.user.get_profile()
|
||||||
|
profile = []
|
||||||
|
for field_name in user_profile._meta.get_all_field_names():
|
||||||
|
if field_name in ('id', 'user'):
|
||||||
|
continue
|
||||||
|
field = user_profile._meta.get_field_by_name(field_name)[0]
|
||||||
|
value = getattr(user_profile, field_name)
|
||||||
|
if value:
|
||||||
|
profile.append((field.verbose_name, value))
|
||||||
|
except (SiteProfileNotAvailable, ObjectDoesNotExist):
|
||||||
|
profile = ()
|
||||||
|
# Credentials management
|
||||||
blocks = [ frontend.profile(request, next='/profile') for frontend in frontends \
|
blocks = [ frontend.profile(request, next='/profile') for frontend in frontends \
|
||||||
if hasattr(frontend, 'profile') ]
|
if hasattr(frontend, 'profile') ]
|
||||||
return render_to_response('idp/account_management.html', { 'frontends_block': blocks },
|
return render_to_response('idp/account_management.html', { 'frontends_block': blocks, 'profile': profile },
|
||||||
RequestContext(request))
|
RequestContext(request))
|
||||||
|
|
||||||
def logout_list(request):
|
def logout_list(request):
|
||||||
|
|
|
@ -292,6 +292,6 @@ h4 {
|
||||||
padding-left: 0.5em;
|
padding-left: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
h4 + div {
|
h4 + div, div#profile {
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue