##// 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 from rhodecode.lib.utils2 import str2bool
21 from rhodecode.lib.utils2 import str2bool
22
22
23
23
24 def debug_style_enabled(info, request):
24 class DebugStylePredicate(object):
25 return str2bool(request.registry.settings.get('debug_style'))
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 def includeme(config):
36 def includeme(config):
37 config.add_route_predicate(
38 'debug_style', DebugStylePredicate)
39
29 config.add_route(
40 config.add_route(
30 name='debug_style_home',
41 name='debug_style_home',
31 pattern=ADMIN_PREFIX + '/debug_style',
42 pattern=ADMIN_PREFIX + '/debug_style',
32 custom_predicates=(debug_style_enabled,))
43 debug_style=True)
33 config.add_route(
44 config.add_route(
34 name='debug_style_template',
45 name='debug_style_template',
35 pattern=ADMIN_PREFIX + '/debug_style/t/{t_path}',
46 pattern=ADMIN_PREFIX + '/debug_style/t/{t_path}',
36 custom_predicates=(debug_style_enabled,))
47 debug_style=True)
37
48
38 # Scan module for configuration decorators.
49 # Scan module for configuration decorators.
39 config.scan('.views', ignore='.tests')
50 config.scan('.views', ignore='.tests')
40
41
42
@@ -28,7 +28,57 b' from rhodecode.integrations import integ'
28 log = logging.getLogger(__name__)
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 def includeme(config):
79 def includeme(config):
80 config.add_route_predicate(
81 'valid_integration', ValidIntegrationPredicate)
32
82
33 # global integrations
83 # global integrations
34 config.add_route('global_integrations_new',
84 config.add_route('global_integrations_new',
@@ -52,10 +102,10 b' def includeme(config):'
52
102
53 config.add_route('global_integrations_create',
103 config.add_route('global_integrations_create',
54 ADMIN_PREFIX + '/integrations/{integration}/new',
104 ADMIN_PREFIX + '/integrations/{integration}/new',
55 custom_predicates=(valid_integration,))
105 valid_integration=True)
56 config.add_route('global_integrations_edit',
106 config.add_route('global_integrations_edit',
57 ADMIN_PREFIX + '/integrations/{integration}/{integration_id}',
107 ADMIN_PREFIX + '/integrations/{integration}/{integration_id}',
58 custom_predicates=(valid_integration,))
108 valid_integration=True)
59
109
60 for route_name in ['global_integrations_create', 'global_integrations_edit']:
110 for route_name in ['global_integrations_create', 'global_integrations_edit']:
61 config.add_view('rhodecode.integrations.views.GlobalIntegrationsView',
111 config.add_view('rhodecode.integrations.views.GlobalIntegrationsView',
@@ -92,7 +142,7 b' def includeme(config):'
92 config.add_route('repo_group_integrations_list',
142 config.add_route('repo_group_integrations_list',
93 add_route_requirements('/{repo_group_name}/_settings/integrations/{integration}'),
143 add_route_requirements('/{repo_group_name}/_settings/integrations/{integration}'),
94 repo_group_route=True,
144 repo_group_route=True,
95 custom_predicates=(valid_integration,))
145 valid_integration=True)
96 config.add_view('rhodecode.integrations.views.RepoGroupIntegrationsView',
146 config.add_view('rhodecode.integrations.views.RepoGroupIntegrationsView',
97 attr='integration_list',
147 attr='integration_list',
98 renderer='rhodecode:templates/admin/integrations/list.mako',
148 renderer='rhodecode:templates/admin/integrations/list.mako',
@@ -102,7 +152,7 b' def includeme(config):'
102 config.add_route('repo_group_integrations_create',
152 config.add_route('repo_group_integrations_create',
103 add_route_requirements('/{repo_group_name}/_settings/integrations/{integration}/new'),
153 add_route_requirements('/{repo_group_name}/_settings/integrations/{integration}/new'),
104 repo_group_route=True,
154 repo_group_route=True,
105 custom_predicates=(valid_integration,))
155 valid_integration=True)
106 config.add_view('rhodecode.integrations.views.RepoGroupIntegrationsView',
156 config.add_view('rhodecode.integrations.views.RepoGroupIntegrationsView',
107 attr='settings_get',
157 attr='settings_get',
108 renderer='rhodecode:templates/admin/integrations/form.mako',
158 renderer='rhodecode:templates/admin/integrations/form.mako',
@@ -117,7 +167,7 b' def includeme(config):'
117 config.add_route('repo_group_integrations_edit',
167 config.add_route('repo_group_integrations_edit',
118 add_route_requirements('/{repo_group_name}/_settings/integrations/{integration}/{integration_id}'),
168 add_route_requirements('/{repo_group_name}/_settings/integrations/{integration}/{integration_id}'),
119 repo_group_route=True,
169 repo_group_route=True,
120 custom_predicates=(valid_integration,))
170 valid_integration=True)
121
171
122 config.add_view('rhodecode.integrations.views.RepoGroupIntegrationsView',
172 config.add_view('rhodecode.integrations.views.RepoGroupIntegrationsView',
123 attr='settings_get',
173 attr='settings_get',
@@ -152,7 +202,7 b' def includeme(config):'
152 config.add_route('repo_integrations_list',
202 config.add_route('repo_integrations_list',
153 add_route_requirements('/{repo_name}/settings/integrations/{integration}'),
203 add_route_requirements('/{repo_name}/settings/integrations/{integration}'),
154 repo_route=True,
204 repo_route=True,
155 custom_predicates=(valid_integration,))
205 valid_integration=True)
156 config.add_view('rhodecode.integrations.views.RepoIntegrationsView',
206 config.add_view('rhodecode.integrations.views.RepoIntegrationsView',
157 attr='integration_list',
207 attr='integration_list',
158 request_method='GET',
208 request_method='GET',
@@ -162,7 +212,7 b' def includeme(config):'
162 config.add_route('repo_integrations_create',
212 config.add_route('repo_integrations_create',
163 add_route_requirements('/{repo_name}/settings/integrations/{integration}/new'),
213 add_route_requirements('/{repo_name}/settings/integrations/{integration}/new'),
164 repo_route=True,
214 repo_route=True,
165 custom_predicates=(valid_integration,))
215 valid_integration=True)
166 config.add_view('rhodecode.integrations.views.RepoIntegrationsView',
216 config.add_view('rhodecode.integrations.views.RepoIntegrationsView',
167 attr='settings_get',
217 attr='settings_get',
168 renderer='rhodecode:templates/admin/integrations/form.mako',
218 renderer='rhodecode:templates/admin/integrations/form.mako',
@@ -177,7 +227,7 b' def includeme(config):'
177 config.add_route('repo_integrations_edit',
227 config.add_route('repo_integrations_edit',
178 add_route_requirements('/{repo_name}/settings/integrations/{integration}/{integration_id}'),
228 add_route_requirements('/{repo_name}/settings/integrations/{integration}/{integration_id}'),
179 repo_route=True,
229 repo_route=True,
180 custom_predicates=(valid_integration,))
230 valid_integration=True)
181 config.add_view('rhodecode.integrations.views.RepoIntegrationsView',
231 config.add_view('rhodecode.integrations.views.RepoIntegrationsView',
182 attr='settings_get',
232 attr='settings_get',
183 renderer='rhodecode:templates/admin/integrations/form.mako',
233 renderer='rhodecode:templates/admin/integrations/form.mako',
@@ -188,43 +238,3 b' def includeme(config):'
188 renderer='rhodecode:templates/admin/integrations/form.mako',
238 renderer='rhodecode:templates/admin/integrations/form.mako',
189 request_method='POST',
239 request_method='POST',
190 route_name='repo_integrations_edit')
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