浏览代码

Fix reset password process

Bastien Sevajol (Algoo) 9 年前
父节点
当前提交
b1151c30d5
共有 4 个文件被更改,包括 29 次插入2 次删除
  1. 1 1
      install/requirements.txt
  2. 1 0
      tracim/tracim/config/app_cfg.py
  3. 5 0
      tracim/tracim/controllers/root.py
  4. 22 1
      tracim/tracim/lib/utils.py

+ 1 - 1
install/requirements.txt 查看文件

45
 waitress==0.8.9
45
 waitress==0.8.9
46
 zope.interface==4.1.3
46
 zope.interface==4.1.3
47
 zope.sqlalchemy==0.7.6
47
 zope.sqlalchemy==0.7.6
48
-tgapp-resetpassword==0.1.3
48
+git+https://github.com/algoo/tgapp-resetpassword.git@master
49
 lxml
49
 lxml
50
 python-ldap-test==0.2.0
50
 python-ldap-test==0.2.0
51
 who-ldap==3.1.0
51
 who-ldap==3.1.0

+ 1 - 0
tracim/tracim/config/app_cfg.py 查看文件

69
 # flash.js_call -> javascript code which will be run when displaying the flash from javascript. Default is webflash.render(), you can use webflash.payload() to retrieve the message and show it with your favourite library.
69
 # flash.js_call -> javascript code which will be run when displaying the flash from javascript. Default is webflash.render(), you can use webflash.payload() to retrieve the message and show it with your favourite library.
70
 # flash.js_template -> string.Template instance used to replace full javascript support for flash messages. When rendering flash message for javascript usage the following code will be used instead of providing the standard webflash object. If you replace js_template you must also ensure cookie parsing and delete it for already displayed messages. The template will receive: $container_id, $cookie_name, $js_call variables.
70
 # flash.js_template -> string.Template instance used to replace full javascript support for flash messages. When rendering flash message for javascript usage the following code will be used instead of providing the standard webflash object. If you replace js_template you must also ensure cookie parsing and delete it for already displayed messages. The template will receive: $container_id, $cookie_name, $js_call variables.
71
 
71
 
72
+base_config['templating.genshi.name_constant_patch'] = True
72
 
73
 
73
 # Configure the authentication backend
74
 # Configure the authentication backend
74
 
75
 

+ 5 - 0
tracim/tracim/controllers/root.py 查看文件

24
 from tracim.controllers.help import HelpController
24
 from tracim.controllers.help import HelpController
25
 from tracim.controllers.user import UserRestController
25
 from tracim.controllers.user import UserRestController
26
 from tracim.controllers.workspace import UserWorkspaceRestController
26
 from tracim.controllers.workspace import UserWorkspaceRestController
27
+from tracim.lib.utils import replace_reset_password_templates
27
 
28
 
28
 from tracim.model.data import ContentType
29
 from tracim.model.data import ContentType
29
 from tracim.model.serializers import DictLikeClass
30
 from tracim.model.serializers import DictLikeClass
55
     workspaces = UserWorkspaceRestController()
56
     workspaces = UserWorkspaceRestController()
56
     user = UserRestController()
57
     user = UserRestController()
57
 
58
 
59
+    def _render_response(self, tgl, controller, response):
60
+        replace_reset_password_templates(controller.decoration.engines)
61
+        return super()._render_response(tgl, controller, response)
62
+
58
     def _before(self, *args, **kw):
63
     def _before(self, *args, **kw):
59
         super(RootController, self)._before(args, kw)
64
         super(RootController, self)._before(args, kw)
60
         tmpl_context.project_name = "tracim"
65
         tmpl_context.project_name = "tracim"

+ 22 - 1
tracim/tracim/lib/utils.py 查看文件

17
 
17
 
18
 
18
 
19
 class SameValueError(ValueError):
19
 class SameValueError(ValueError):
20
-    pass
20
+    pass
21
+
22
+
23
+def replace_reset_password_templates(engines):
24
+    try:
25
+        if engines['text/html'][1] == 'resetpassword.templates.index':
26
+            engines['text/html'] = (
27
+                'mako',
28
+                'tracim.templates.reset_password_index',
29
+                engines['text/html'][2],
30
+                engines['text/html'][3]
31
+            )
32
+
33
+        if engines['text/html'][1] == 'resetpassword.templates.change_password':
34
+            engines['text/html'] = (
35
+                'mako',
36
+                'tracim.templates.reset_password_change_password',
37
+                engines['text/html'][2],
38
+                engines['text/html'][3]
39
+            )
40
+    except IndexError:
41
+        pass