Revision 1626571f
Transmission des traductions JS des thèmes depuis VigiGraph (cf. #329).
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@6101 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigigraph/controllers/root.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 |
# vim:set expandtab tabstop=4 shiftwidth=4:
|
|
2 |
# vim:set expandtab tabstop=4 shiftwidth=4: |
|
3 | 3 |
"""Vigigraph Controller""" |
4 | 4 |
|
5 | 5 |
import logging |
... | ... | |
7 | 7 |
from pylons.i18n import ugettext as _, lazy_ugettext as l_, get_lang |
8 | 8 |
from repoze.what.predicates import Any, All, not_anonymous, \ |
9 | 9 |
has_permission, in_group |
10 |
from pkg_resources import resource_filename |
|
10 | 11 |
|
11 | 12 |
from vigilo.turbogears.controllers import BaseController |
12 | 13 |
from vigilo.turbogears.controllers.error import ErrorController |
... | ... | |
59 | 60 |
rootdir = conf['pylons.paths'].get('root_path') |
60 | 61 |
localedir = os.path.join(rootdir, 'i18n') |
61 | 62 |
|
63 |
lang = get_lang() |
|
64 |
|
|
62 | 65 |
# Localise le fichier *.mo actuellement chargé |
63 | 66 |
# et génère le chemin jusqu'au *.js correspondant. |
64 | 67 |
filename = gettext.find(conf['pylons.package'], localedir, |
65 |
languages=get_lang())
|
|
68 |
languages=lang)
|
|
66 | 69 |
js = filename[:-3] + '.js' |
67 | 70 |
|
71 |
themes_filename = gettext.find( |
|
72 |
'vigilo-themes', |
|
73 |
resource_filename('vigilo.themes.i18n', ''), |
|
74 |
languages=lang) |
|
75 |
themes_js = themes_filename[:-3] + '.js' |
|
76 |
|
|
68 | 77 |
# Récupère et envoie le contenu du fichier de traduction *.js. |
69 | 78 |
fhandle = open(js, 'r') |
70 | 79 |
translations = fhandle.read() |
71 | 80 |
fhandle.close() |
81 |
|
|
82 |
fhandle = open(themes_js, 'r') |
|
83 |
translations += fhandle.read() |
|
84 |
fhandle.close() |
|
72 | 85 |
return translations |
73 | 86 |
|
74 | 87 |
@expose('login.html') |
... | ... | |
79 | 92 |
flash(_('Wrong credentials'), 'warning') |
80 | 93 |
return dict(page='login', login_counter=str(login_counter), |
81 | 94 |
came_from=came_from) |
82 |
|
|
95 |
|
|
83 | 96 |
@expose() |
84 | 97 |
def post_login(self, came_from='/'): |
85 | 98 |
""" |
86 | 99 |
Redirect the user to the initially requested page on successful |
87 | 100 |
authentication or redirect her back to the login page if login failed. |
88 |
|
|
101 |
|
|
89 | 102 |
""" |
90 | 103 |
if not request.identity: |
91 | 104 |
login_counter = request.environ['repoze.who.logins'] + 1 |
... | ... | |
103 | 116 |
""" |
104 | 117 |
Redirect the user to the initially requested page on logout and say |
105 | 118 |
goodbye as well. |
106 |
|
|
119 |
|
|
107 | 120 |
""" |
108 | 121 |
LOGGER.info(_('Some user logged out (from %(IP)s)') % { |
109 | 122 |
'IP': request.remote_addr, |
110 | 123 |
}) |
111 | 124 |
flash(_('We hope to see you soon!')) |
112 | 125 |
redirect(came_from) |
113 |
|
Also available in: Unified diff