##// END OF EJS Templates
pyramid: fixed some deprecated calls.
dan -
r3099:abc83359 default
parent child Browse files
Show More
@@ -21,22 +21,30 b' from rhodecode.apps._base import ADMIN_P'
21 21 from rhodecode.lib.utils2 import str2bool
22 22
23 23
24 def debug_style_enabled(info, request):
25 return str2bool(request.registry.settings.get('debug_style'))
24 class DebugStylePredicate(object):
25 def __init__(self, val, config):
26 self.val = val
26 27
28 def text(self):
29 return 'debug style route = %s' % self.val
30
31 phash = text
32
33 def __call__(self, info, request):
34 str2bool(request.registry.settings.get('debug_style'))
27 35
28 36 def includeme(config):
37 config.add_route_predicate(
38 'debug_style', DebugStylePredicate)
39
29 40 config.add_route(
30 41 name='debug_style_home',
31 42 pattern=ADMIN_PREFIX + '/debug_style',
32 custom_predicates=(debug_style_enabled,))
43 debug_style=True)
33 44 config.add_route(
34 45 name='debug_style_template',
35 46 pattern=ADMIN_PREFIX + '/debug_style/t/{t_path}',
36 custom_predicates=(debug_style_enabled,))
47 debug_style=True)
37 48
38 49 # Scan module for configuration decorators.
39 50 config.scan('.views', ignore='.tests')
40
41
42
@@ -28,7 +28,57 b' from rhodecode.integrations import integ'
28 28 log = logging.getLogger(__name__)
29 29
30 30
31 class ValidIntegrationPredicate(object):
32 def __init__(self, val, config):
33 self.val = val
34
35 def text(self):
36 return 'valid_integration_route = %s' % self.val
37
38 phash = text
39
40 def __call__(self, info, request):
41 integration_type = info['match']['integration']
42 integration_id = info['match'].get('integration_id')
43
44 if integration_type not in integration_type_registry:
45 return False
46
47 if integration_id:
48 if not safe_int(integration_id):
49 return False
50
51 integration = Integration.get(integration_id)
52 if not integration:
53 return False
54 if integration.integration_type != integration_type:
55 return False
56
57 # match types to repo or repo group
58 repo_name = info['match'].get('repo_name')
59 repo_group_name = info['match'].get('repo_group_name')
60 repo, repo_group = None, None
61 if repo_name:
62 repo = Repository.get_by_repo_name(repo_name)
63 if not repo:
64 return False
65
66 if repo_group_name:
67 repo_group = RepoGroup.get_by_group_name(repo_group_name)
68 if not repo_group:
69 return False
70
71 if repo and repo.repo_id != integration.repo_id:
72 return False
73 if repo_group and repo_group.group_id != integration.repo_group_id:
74 return False
75
76 return True
77
78
31 79 def includeme(config):
80 config.add_route_predicate(
81 'valid_integration', ValidIntegrationPredicate)
32 82
33 83 # global integrations
34 84 config.add_route('global_integrations_new',
@@ -52,10 +102,10 b' def includeme(config):'
52 102
53 103 config.add_route('global_integrations_create',
54 104 ADMIN_PREFIX + '/integrations/{integration}/new',
55 custom_predicates=(valid_integration,))
105 valid_integration=True)
56 106 config.add_route('global_integrations_edit',
57 107 ADMIN_PREFIX + '/integrations/{integration}/{integration_id}',
58 custom_predicates=(valid_integration,))
108 valid_integration=True)
59 109
60 110 for route_name in ['global_integrations_create', 'global_integrations_edit']:
61 111 config.add_view('rhodecode.integrations.views.GlobalIntegrationsView',
@@ -92,7 +142,7 b' def includeme(config):'
92 142 config.add_route('repo_group_integrations_list',
93 143 add_route_requirements('/{repo_group_name}/_settings/integrations/{integration}'),
94 144 repo_group_route=True,
95 custom_predicates=(valid_integration,))
145 valid_integration=True)
96 146 config.add_view('rhodecode.integrations.views.RepoGroupIntegrationsView',
97 147 attr='integration_list',
98 148 renderer='rhodecode:templates/admin/integrations/list.mako',
@@ -102,7 +152,7 b' def includeme(config):'
102 152 config.add_route('repo_group_integrations_create',
103 153 add_route_requirements('/{repo_group_name}/_settings/integrations/{integration}/new'),
104 154 repo_group_route=True,
105 custom_predicates=(valid_integration,))
155 valid_integration=True)
106 156 config.add_view('rhodecode.integrations.views.RepoGroupIntegrationsView',
107 157 attr='settings_get',
108 158 renderer='rhodecode:templates/admin/integrations/form.mako',
@@ -117,7 +167,7 b' def includeme(config):'
117 167 config.add_route('repo_group_integrations_edit',
118 168 add_route_requirements('/{repo_group_name}/_settings/integrations/{integration}/{integration_id}'),
119 169 repo_group_route=True,
120 custom_predicates=(valid_integration,))
170 valid_integration=True)
121 171
122 172 config.add_view('rhodecode.integrations.views.RepoGroupIntegrationsView',
123 173 attr='settings_get',
@@ -152,7 +202,7 b' def includeme(config):'
152 202 config.add_route('repo_integrations_list',
153 203 add_route_requirements('/{repo_name}/settings/integrations/{integration}'),
154 204 repo_route=True,
155 custom_predicates=(valid_integration,))
205 valid_integration=True)
156 206 config.add_view('rhodecode.integrations.views.RepoIntegrationsView',
157 207 attr='integration_list',
158 208 request_method='GET',
@@ -162,7 +212,7 b' def includeme(config):'
162 212 config.add_route('repo_integrations_create',
163 213 add_route_requirements('/{repo_name}/settings/integrations/{integration}/new'),
164 214 repo_route=True,
165 custom_predicates=(valid_integration,))
215 valid_integration=True)
166 216 config.add_view('rhodecode.integrations.views.RepoIntegrationsView',
167 217 attr='settings_get',
168 218 renderer='rhodecode:templates/admin/integrations/form.mako',
@@ -177,7 +227,7 b' def includeme(config):'
177 227 config.add_route('repo_integrations_edit',
178 228 add_route_requirements('/{repo_name}/settings/integrations/{integration}/{integration_id}'),
179 229 repo_route=True,
180 custom_predicates=(valid_integration,))
230 valid_integration=True)
181 231 config.add_view('rhodecode.integrations.views.RepoIntegrationsView',
182 232 attr='settings_get',
183 233 renderer='rhodecode:templates/admin/integrations/form.mako',
@@ -188,43 +238,3 b' def includeme(config):'
188 238 renderer='rhodecode:templates/admin/integrations/form.mako',
189 239 request_method='POST',
190 240 route_name='repo_integrations_edit')
191
192
193
194 def valid_integration(info, request):
195 integration_type = info['match']['integration']
196 integration_id = info['match'].get('integration_id')
197
198 if integration_type not in integration_type_registry:
199 return False
200
201 if integration_id:
202 if not safe_int(integration_id):
203 return False
204
205 integration = Integration.get(integration_id)
206 if not integration:
207 return False
208 if integration.integration_type != integration_type:
209 return False
210
211 # match types to repo or repo group
212 repo_name = info['match'].get('repo_name')
213 repo_group_name = info['match'].get('repo_group_name')
214 repo, repo_group = None, None
215 if repo_name:
216 repo = Repository.get_by_repo_name(repo_name)
217 if not repo:
218 return False
219
220 if repo_group_name:
221 repo_group = RepoGroup.get_by_group_name(repo_group_name)
222 if not repo_group:
223 return False
224
225 if repo and repo.repo_id != integration.repo_id:
226 return False
227 if repo_group and repo_group.group_id != integration.repo_group_id:
228 return False
229
230 return True
General Comments 0
You need to be logged in to leave comments. Login now