Révision 8f7e157d
Ajouté par Jérôme Schneider il y a plus de 9 ans
mandaye/filters/default.py | ||
---|---|---|
61 | 61 |
|
62 | 62 |
@staticmethod |
63 | 63 |
def addtoolbar(env, values, request, response): |
64 |
if env['beaker.session'].has_key('unique_id'): |
|
64 |
if config.mandaye_offline_toolbar or \ |
|
65 |
env['beaker.session'].has_key('unique_id'): |
|
65 | 66 |
response.msg = response.msg.replace( |
66 |
'</head>', |
|
67 |
'<script src="%s/js/toolbar.js" type="text/javascript"></script>\ |
|
68 |
<link rel="stylesheet" type="text/css" href="%s/css/toolbar.css">\ |
|
69 |
</head>' % (config.static_url, config.static_url)) |
|
67 |
'</head>',
|
|
68 |
'<script src="%s/js/toolbar.js" type="text/javascript"></script>\
|
|
69 |
<link rel="stylesheet" type="text/css" href="%s/css/toolbar.css">\
|
|
70 |
</head>' % (config.static_url, config.static_url))
|
|
70 | 71 |
return response |
71 | 72 |
|
72 | 73 |
@staticmethod |
73 | 74 |
def toolbar(env, values, request, response): |
74 | 75 |
values['urls'] = env['urls'] |
76 |
values['site_name'] = env["mandaye.config"]["site_name"] |
|
77 |
values['is_login'] = False |
|
78 |
current_account = None |
|
75 | 79 |
if env['beaker.session'].get('unique_id'): |
76 |
current_account = None
|
|
80 |
values['is_login'] = True
|
|
77 | 81 |
site_name = env["mandaye.config"]["site_name"] |
78 | 82 |
if env['beaker.session'].get(site_name): |
79 | 83 |
logger.debug('toolbar there is one : %r' % \ |
80 | 84 |
ManagerSPUser.get_by_id(env['beaker.session'].get(site_name))) |
81 | 85 |
current_account = ManagerSPUser.get_by_id(env['beaker.session'].get(site_name)) |
82 | 86 |
else: |
83 |
logger.debug('toolbar : no account')
|
|
87 |
logger.debug('toolbar: no account') |
|
84 | 88 |
values['account'] = current_account |
85 | 89 |
return template_response("toolbar.html", values) |
90 |
|
mandaye/global_config.py | ||
---|---|---|
94 | 94 |
auto_decompress = True |
95 | 95 |
# Ask mandaye to add a toolbar |
96 | 96 |
mandaye_toolbar = True |
97 |
mandaye_offline_toolbar = False |
|
97 | 98 |
# Authentic 2 auto connection |
98 | 99 |
a2_auto_connection = False |
99 | 100 |
|
mandaye/mappers/default.py | ||
---|---|---|
24 | 24 |
{ |
25 | 25 |
'path': r'/mandaye/toolbar', |
26 | 26 |
'response': {'filter': MandayeFilter.toolbar} |
27 |
} |
|
27 |
},
|
|
28 | 28 |
]) |
mandaye/skel/example.module/config.py | ||
---|---|---|
133 | 133 |
auto_decompress = config.getboolean('mandaye', 'auto_decompress') |
134 | 134 |
# Ask mandaye to add a toolbar with Mandaye's links |
135 | 135 |
mandaye_toolbar = config.getboolean('mandaye', 'toolbar') |
136 |
mandaye_toolbar_offline = config.getboolean('mandaye', 'offline_toolbar') |
|
136 | 137 |
# Authentic 2 auto connection |
137 | 138 |
a2_auto_connection = config.getboolean('mandaye', 'a2_auto_connection') |
138 | 139 |
|
mandaye/skel/example.module/default-config.ini | ||
---|---|---|
21 | 21 |
|
22 | 22 |
[mandaye] |
23 | 23 |
toolbar: true |
24 |
offline_toolbar: true |
|
24 | 25 |
a2_auto_connection: false |
25 | 26 |
; only sql at the moment |
26 | 27 |
storage_backend: sql |
mandaye/static/js/toolbar.js | ||
---|---|---|
40 | 40 |
httpReq.send(); |
41 | 41 |
} |
42 | 42 |
|
43 |
function mandaye_disassociate_logout(account, id) |
|
43 |
function mandaye_disassociate_logout(url, account, id)
|
|
44 | 44 |
{ |
45 | 45 |
var r = confirm("Etes-vous sûr de vouloir désassocier le compte " + account + " ?"); |
46 | 46 |
if (r == true) |
47 | 47 |
{ |
48 |
window.location = "${urls['disassociate_url']}?id=" + id + "&logout=1";
|
|
48 |
window.location = url + "?id=" + id;
|
|
49 | 49 |
} |
50 | 50 |
} |
51 | 51 |
|
52 |
mandaye_load('/mandaye/toolbar', function(response) { |
|
53 |
var body = document.body || document.getElementsByTagName('body')[0]; |
|
54 |
var div = document.createElement('div'); |
|
55 |
div.innerHTML = response; |
|
56 |
body.insertBefore(div, body.childNodes[0]); |
|
57 |
}); |
|
52 |
window.onload = function () { |
|
53 |
mandaye_load('/mandaye/toolbar', function(response) { |
|
54 |
var body = document.body || document.getElementsByTagName('body')[0]; |
|
55 |
var div = document.createElement('div'); |
|
56 |
div.innerHTML = response; |
|
57 |
body.insertBefore(div, body.childNodes[0]); |
|
58 |
}); |
|
59 |
} |
|
58 | 60 |
|
mandaye/templates/toolbar.html | ||
---|---|---|
8 | 8 |
</div> |
9 | 9 |
<div class="mandaye-toolbar-right"> |
10 | 10 |
<ul class="mandaye-toolbar-link"> |
11 |
% if is_login: |
|
11 | 12 |
<li> |
12 | 13 |
<a href="/mandaye/logout">Me déconnecter</a> |
13 | 14 |
</li> |
14 | 15 |
% if account: |
15 | 16 |
<li> |
16 |
<a href="javascript:mandaye_disassociate_logout('${account.login}', ${account.id})" title="Cliquer ici pour supprimer l'association entre ce compte et votre compte citoyen.">Me désassocier</a> |
|
17 |
<a href="javascript:mandaye_disassociate_logout('${urls['disassociate_url']}', '${account.login}', ${account.id})" title="Cliquer ici pour supprimer l'association entre ce compte et votre compte citoyen.">Me désassocier</a> |
|
18 |
</li> |
|
19 |
% endif |
|
20 |
% else: |
|
21 |
<li> |
|
22 |
<a href="/mandaye/sso" title="Cliquer ici pour vous connecter sur ${site_name}">Me connecter</a> |
|
17 | 23 |
</li> |
18 | 24 |
% endif |
19 | 25 |
</ul> |
Formats disponibles : Unified diff
toolbar: manage offline toolbar