mandaye_vincennes: update to support the last version of Mandaye

This commit is contained in:
Jérôme Schneider 2014-09-16 16:16:00 +02:00
parent 3459713401
commit 2b0253daa9
3 changed files with 10 additions and 11 deletions

View File

@ -10,7 +10,7 @@ from mandaye.log import logger
from mandaye.response import _302, _401
from mandaye.template import serve_template
from mandaye.backends.default import ManagerSPUser
from mandaye.backends.default import Association
def get_associate_form(env, values):
""" Return association template content
@ -38,8 +38,8 @@ def get_current_account(env, values):
site_name = values.get('site_name')
if env['beaker.session'].get(site_name):
logger.debug('get_current_account there is one : %r' % \
ManagerSPUser.get_by_id(env['beaker.session'].get(site_name)))
return ManagerSPUser.get_by_id(env['beaker.session'].get(site_name))
Association.get_by_id(env['beaker.session'].get(site_name)))
return Association.get_by_id(env['beaker.session'].get(site_name))
else:
logger.debug('get_current_account : no account')
return None
@ -51,12 +51,11 @@ def get_multi_template(env, values, current_account):
unique_id = env['beaker.session'].get('unique_id')
if unique_id:
accounts = {}
sp_users = ManagerSPUser.get_sp_users(unique_id,
values.get('site_name'))
for sp_user in sp_users:
accounts[sp_user.id] = sp_user.login
associations = Association.get(values.get('site_name'), unique_id)
for asso in associations:
accounts[asso['id']] = asso['sp_login']
if current_account:
current_login = current_account.login
current_login = current_account['sp_login']
else:
current_login = None
template = serve_template(values.get('template'),
@ -114,7 +113,7 @@ class Biblio:
template = get_multi_template(env, values, current_account)
if current_account:
sub = re.subn(r'(<div class="content"><div id="opacaccount" class="summary"><div class="name">)<b>(.*)</b>',
r'\1<b>\2 (%s)</b>' % str(current_account.login),
r'\1<b>\2 (%s)</b>' % str(current_account['sp_login']),
response.msg)
response.msg = sub[0]
if sub[1] != 1:

View File

@ -10,6 +10,6 @@
</script>
<a href="javascript:disassociate_logout('${account.login}', ${account.id})"
<a href="javascript:disassociate_logout('${account['sp_login']}', ${account['id']})"
title="Cliquer ici pour supprimer l'association entre ce compte médiathèque et votre compte citoyen. Le compte médiathèque restera accessible par son propriétaire avec ses propres identifiants.">
Désassocier</a>

View File

@ -23,7 +23,7 @@
</li>
% if account:
<li>
<a href="javascript:disassociate_logout('${account.login}', ${account.id})" title="Cliquer ici pour supprimer l'association entre ce compte et votre compte citoyen.">Me désassocier</a>
<a href="javascript:mandaye_disassociate_logout('${urls['disassociate_url']}', '${account['sp_login']}', ${account['id']})" title="Cliquer ici pour supprimer l'association entre ce compte et votre compte citoyen.">Me désassocier</a>
</li>
% endif
</ul>