Show More
@@ -1,1112 +1,1106 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2010-2016 RhodeCode GmbH |
|
3 | # Copyright (C) 2010-2016 RhodeCode GmbH | |
4 | # |
|
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
7 | # (only), as published by the Free Software Foundation. |
|
7 | # (only), as published by the Free Software Foundation. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # |
|
16 | # | |
17 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
21 | """ |
|
21 | """ | |
22 | Routes configuration |
|
22 | Routes configuration | |
23 |
|
23 | |||
24 | The more specific and detailed routes should be defined first so they |
|
24 | The more specific and detailed routes should be defined first so they | |
25 | may take precedent over the more generic routes. For more information |
|
25 | may take precedent over the more generic routes. For more information | |
26 | refer to the routes manual at http://routes.groovie.org/docs/ |
|
26 | refer to the routes manual at http://routes.groovie.org/docs/ | |
27 |
|
27 | |||
28 | IMPORTANT: if you change any routing here, make sure to take a look at lib/base.py |
|
28 | IMPORTANT: if you change any routing here, make sure to take a look at lib/base.py | |
29 | and _route_name variable which uses some of stored naming here to do redirects. |
|
29 | and _route_name variable which uses some of stored naming here to do redirects. | |
30 | """ |
|
30 | """ | |
31 | import os |
|
31 | import os | |
32 | from routes import Mapper |
|
32 | from routes import Mapper | |
33 |
|
33 | |||
34 | from rhodecode.config import routing_links |
|
34 | from rhodecode.config import routing_links | |
35 |
|
35 | |||
36 | # prefix for non repository related links needs to be prefixed with `/` |
|
36 | # prefix for non repository related links needs to be prefixed with `/` | |
37 | ADMIN_PREFIX = '/_admin' |
|
37 | ADMIN_PREFIX = '/_admin' | |
38 |
|
38 | |||
39 | # Default requirements for URL parts |
|
39 | # Default requirements for URL parts | |
40 | URL_NAME_REQUIREMENTS = { |
|
40 | URL_NAME_REQUIREMENTS = { | |
41 | # group name can have a slash in them, but they must not end with a slash |
|
41 | # group name can have a slash in them, but they must not end with a slash | |
42 | 'group_name': r'.*?[^/]', |
|
42 | 'group_name': r'.*?[^/]', | |
43 | # repo names can have a slash in them, but they must not end with a slash |
|
43 | # repo names can have a slash in them, but they must not end with a slash | |
44 | 'repo_name': r'.*?[^/]', |
|
44 | 'repo_name': r'.*?[^/]', | |
45 | # file path eats up everything at the end |
|
45 | # file path eats up everything at the end | |
46 | 'f_path': r'.*', |
|
46 | 'f_path': r'.*', | |
47 | # reference types |
|
47 | # reference types | |
48 | 'source_ref_type': '(branch|book|tag|rev|\%\(source_ref_type\)s)', |
|
48 | 'source_ref_type': '(branch|book|tag|rev|\%\(source_ref_type\)s)', | |
49 | 'target_ref_type': '(branch|book|tag|rev|\%\(target_ref_type\)s)', |
|
49 | 'target_ref_type': '(branch|book|tag|rev|\%\(target_ref_type\)s)', | |
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 |
|
52 | |||
53 | def make_map(config): |
|
53 | def make_map(config): | |
54 | """Create, configure and return the routes Mapper""" |
|
54 | """Create, configure and return the routes Mapper""" | |
55 | rmap = Mapper(directory=config['pylons.paths']['controllers'], |
|
55 | rmap = Mapper(directory=config['pylons.paths']['controllers'], | |
56 | always_scan=config['debug']) |
|
56 | always_scan=config['debug']) | |
57 | rmap.minimization = False |
|
57 | rmap.minimization = False | |
58 | rmap.explicit = False |
|
58 | rmap.explicit = False | |
59 |
|
59 | |||
60 | from rhodecode.lib.utils2 import str2bool |
|
60 | from rhodecode.lib.utils2 import str2bool | |
61 | from rhodecode.model import repo, repo_group |
|
61 | from rhodecode.model import repo, repo_group | |
62 |
|
62 | |||
63 | def check_repo(environ, match_dict): |
|
63 | def check_repo(environ, match_dict): | |
64 | """ |
|
64 | """ | |
65 | check for valid repository for proper 404 handling |
|
65 | check for valid repository for proper 404 handling | |
66 |
|
66 | |||
67 | :param environ: |
|
67 | :param environ: | |
68 | :param match_dict: |
|
68 | :param match_dict: | |
69 | """ |
|
69 | """ | |
70 | repo_name = match_dict.get('repo_name') |
|
70 | repo_name = match_dict.get('repo_name') | |
71 |
|
71 | |||
72 | if match_dict.get('f_path'): |
|
72 | if match_dict.get('f_path'): | |
73 | # fix for multiple initial slashes that causes errors |
|
73 | # fix for multiple initial slashes that causes errors | |
74 | match_dict['f_path'] = match_dict['f_path'].lstrip('/') |
|
74 | match_dict['f_path'] = match_dict['f_path'].lstrip('/') | |
75 | repo_model = repo.RepoModel() |
|
75 | repo_model = repo.RepoModel() | |
76 | by_name_match = repo_model.get_by_repo_name(repo_name) |
|
76 | by_name_match = repo_model.get_by_repo_name(repo_name) | |
77 | # if we match quickly from database, short circuit the operation, |
|
77 | # if we match quickly from database, short circuit the operation, | |
78 | # and validate repo based on the type. |
|
78 | # and validate repo based on the type. | |
79 | if by_name_match: |
|
79 | if by_name_match: | |
80 | return True |
|
80 | return True | |
81 |
|
81 | |||
82 | by_id_match = repo_model.get_repo_by_id(repo_name) |
|
82 | by_id_match = repo_model.get_repo_by_id(repo_name) | |
83 | if by_id_match: |
|
83 | if by_id_match: | |
84 | repo_name = by_id_match.repo_name |
|
84 | repo_name = by_id_match.repo_name | |
85 | match_dict['repo_name'] = repo_name |
|
85 | match_dict['repo_name'] = repo_name | |
86 | return True |
|
86 | return True | |
87 |
|
87 | |||
88 | return False |
|
88 | return False | |
89 |
|
89 | |||
90 | def check_group(environ, match_dict): |
|
90 | def check_group(environ, match_dict): | |
91 | """ |
|
91 | """ | |
92 | check for valid repository group path for proper 404 handling |
|
92 | check for valid repository group path for proper 404 handling | |
93 |
|
93 | |||
94 | :param environ: |
|
94 | :param environ: | |
95 | :param match_dict: |
|
95 | :param match_dict: | |
96 | """ |
|
96 | """ | |
97 | repo_group_name = match_dict.get('group_name') |
|
97 | repo_group_name = match_dict.get('group_name') | |
98 | repo_group_model = repo_group.RepoGroupModel() |
|
98 | repo_group_model = repo_group.RepoGroupModel() | |
99 | by_name_match = repo_group_model.get_by_group_name(repo_group_name) |
|
99 | by_name_match = repo_group_model.get_by_group_name(repo_group_name) | |
100 | if by_name_match: |
|
100 | if by_name_match: | |
101 | return True |
|
101 | return True | |
102 |
|
102 | |||
103 | return False |
|
103 | return False | |
104 |
|
104 | |||
105 | def check_user_group(environ, match_dict): |
|
105 | def check_user_group(environ, match_dict): | |
106 | """ |
|
106 | """ | |
107 | check for valid user group for proper 404 handling |
|
107 | check for valid user group for proper 404 handling | |
108 |
|
108 | |||
109 | :param environ: |
|
109 | :param environ: | |
110 | :param match_dict: |
|
110 | :param match_dict: | |
111 | """ |
|
111 | """ | |
112 | return True |
|
112 | return True | |
113 |
|
113 | |||
114 | def check_int(environ, match_dict): |
|
114 | def check_int(environ, match_dict): | |
115 | return match_dict.get('id').isdigit() |
|
115 | return match_dict.get('id').isdigit() | |
116 |
|
116 | |||
117 | # The ErrorController route (handles 404/500 error pages); it should |
|
117 | # The ErrorController route (handles 404/500 error pages); it should | |
118 | # likely stay at the top, ensuring it can always be resolved |
|
118 | # likely stay at the top, ensuring it can always be resolved | |
119 | rmap.connect('/error/{action}', controller='error') |
|
119 | rmap.connect('/error/{action}', controller='error') | |
120 | rmap.connect('/error/{action}/{id}', controller='error') |
|
120 | rmap.connect('/error/{action}/{id}', controller='error') | |
121 |
|
121 | |||
122 | #========================================================================== |
|
122 | #========================================================================== | |
123 | # CUSTOM ROUTES HERE |
|
123 | # CUSTOM ROUTES HERE | |
124 | #========================================================================== |
|
124 | #========================================================================== | |
125 |
|
125 | |||
126 | # MAIN PAGE |
|
126 | # MAIN PAGE | |
127 | rmap.connect('home', '/', controller='home', action='index') |
|
127 | rmap.connect('home', '/', controller='home', action='index') | |
128 | rmap.connect('repo_switcher_data', '/_repos_and_groups', controller='home', |
|
128 | rmap.connect('repo_switcher_data', '/_repos_and_groups', controller='home', | |
129 | action='repo_switcher_data') |
|
129 | action='repo_switcher_data') | |
130 | rmap.connect('repo_list_data', '/_repos', controller='home', |
|
130 | rmap.connect('repo_list_data', '/_repos', controller='home', | |
131 | action='repo_list_data') |
|
131 | action='repo_list_data') | |
132 |
|
132 | |||
133 | rmap.connect('user_autocomplete_data', '/_users', controller='home', |
|
133 | rmap.connect('user_autocomplete_data', '/_users', controller='home', | |
134 | action='user_autocomplete_data') |
|
134 | action='user_autocomplete_data') | |
135 | rmap.connect('user_group_autocomplete_data', '/_user_groups', controller='home', |
|
135 | rmap.connect('user_group_autocomplete_data', '/_user_groups', controller='home', | |
136 | action='user_group_autocomplete_data') |
|
136 | action='user_group_autocomplete_data') | |
137 |
|
137 | |||
138 | rmap.connect( |
|
138 | rmap.connect( | |
139 | 'user_profile', '/_profiles/{username}', controller='users', |
|
139 | 'user_profile', '/_profiles/{username}', controller='users', | |
140 | action='user_profile') |
|
140 | action='user_profile') | |
141 |
|
141 | |||
142 | # TODO: johbo: Static links, to be replaced by our redirection mechanism |
|
142 | # TODO: johbo: Static links, to be replaced by our redirection mechanism | |
143 | rmap.connect('rst_help', |
|
143 | rmap.connect('rst_help', | |
144 | 'http://docutils.sourceforge.net/docs/user/rst/quickref.html', |
|
144 | 'http://docutils.sourceforge.net/docs/user/rst/quickref.html', | |
145 | _static=True) |
|
145 | _static=True) | |
146 | rmap.connect('markdown_help', |
|
146 | rmap.connect('markdown_help', | |
147 | 'http://daringfireball.net/projects/markdown/syntax', |
|
147 | 'http://daringfireball.net/projects/markdown/syntax', | |
148 | _static=True) |
|
148 | _static=True) | |
149 | rmap.connect('rhodecode_official', 'https://rhodecode.com', _static=True) |
|
149 | rmap.connect('rhodecode_official', 'https://rhodecode.com', _static=True) | |
150 | rmap.connect('rhodecode_support', 'https://rhodecode.com/help/', _static=True) |
|
150 | rmap.connect('rhodecode_support', 'https://rhodecode.com/help/', _static=True) | |
151 | rmap.connect('rhodecode_translations', 'https://rhodecode.com/translate/enterprise', _static=True) |
|
151 | rmap.connect('rhodecode_translations', 'https://rhodecode.com/translate/enterprise', _static=True) | |
152 | # TODO: anderson - making this a static link since redirect won't play |
|
152 | # TODO: anderson - making this a static link since redirect won't play | |
153 | # nice with POST requests |
|
153 | # nice with POST requests | |
154 | rmap.connect('enterprise_license_convert_from_old', |
|
154 | rmap.connect('enterprise_license_convert_from_old', | |
155 | 'https://rhodecode.com/u/license-upgrade', |
|
155 | 'https://rhodecode.com/u/license-upgrade', | |
156 | _static=True) |
|
156 | _static=True) | |
157 |
|
157 | |||
158 | routing_links.connect_redirection_links(rmap) |
|
158 | routing_links.connect_redirection_links(rmap) | |
159 |
|
159 | |||
160 | rmap.connect('ping', '%s/ping' % (ADMIN_PREFIX,), controller='home', action='ping') |
|
160 | rmap.connect('ping', '%s/ping' % (ADMIN_PREFIX,), controller='home', action='ping') | |
161 | rmap.connect('error_test', '%s/error_test' % (ADMIN_PREFIX,), controller='home', action='error_test') |
|
161 | rmap.connect('error_test', '%s/error_test' % (ADMIN_PREFIX,), controller='home', action='error_test') | |
162 |
|
162 | |||
163 | # ADMIN REPOSITORY ROUTES |
|
163 | # ADMIN REPOSITORY ROUTES | |
164 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
164 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
165 | controller='admin/repos') as m: |
|
165 | controller='admin/repos') as m: | |
166 | m.connect('repos', '/repos', |
|
166 | m.connect('repos', '/repos', | |
167 | action='create', conditions={'method': ['POST']}) |
|
167 | action='create', conditions={'method': ['POST']}) | |
168 | m.connect('repos', '/repos', |
|
168 | m.connect('repos', '/repos', | |
169 | action='index', conditions={'method': ['GET']}) |
|
169 | action='index', conditions={'method': ['GET']}) | |
170 | m.connect('new_repo', '/create_repository', |
|
170 | m.connect('new_repo', '/create_repository', | |
171 | action='create_repository', conditions={'method': ['GET']}) |
|
171 | action='create_repository', conditions={'method': ['GET']}) | |
172 | m.connect('/repos/{repo_name}', |
|
172 | m.connect('/repos/{repo_name}', | |
173 | action='update', conditions={'method': ['PUT'], |
|
173 | action='update', conditions={'method': ['PUT'], | |
174 | 'function': check_repo}, |
|
174 | 'function': check_repo}, | |
175 | requirements=URL_NAME_REQUIREMENTS) |
|
175 | requirements=URL_NAME_REQUIREMENTS) | |
176 | m.connect('delete_repo', '/repos/{repo_name}', |
|
176 | m.connect('delete_repo', '/repos/{repo_name}', | |
177 | action='delete', conditions={'method': ['DELETE']}, |
|
177 | action='delete', conditions={'method': ['DELETE']}, | |
178 | requirements=URL_NAME_REQUIREMENTS) |
|
178 | requirements=URL_NAME_REQUIREMENTS) | |
179 | m.connect('repo', '/repos/{repo_name}', |
|
179 | m.connect('repo', '/repos/{repo_name}', | |
180 | action='show', conditions={'method': ['GET'], |
|
180 | action='show', conditions={'method': ['GET'], | |
181 | 'function': check_repo}, |
|
181 | 'function': check_repo}, | |
182 | requirements=URL_NAME_REQUIREMENTS) |
|
182 | requirements=URL_NAME_REQUIREMENTS) | |
183 |
|
183 | |||
184 | # ADMIN REPOSITORY GROUPS ROUTES |
|
184 | # ADMIN REPOSITORY GROUPS ROUTES | |
185 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
185 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
186 | controller='admin/repo_groups') as m: |
|
186 | controller='admin/repo_groups') as m: | |
187 | m.connect('repo_groups', '/repo_groups', |
|
187 | m.connect('repo_groups', '/repo_groups', | |
188 | action='create', conditions={'method': ['POST']}) |
|
188 | action='create', conditions={'method': ['POST']}) | |
189 | m.connect('repo_groups', '/repo_groups', |
|
189 | m.connect('repo_groups', '/repo_groups', | |
190 | action='index', conditions={'method': ['GET']}) |
|
190 | action='index', conditions={'method': ['GET']}) | |
191 | m.connect('new_repo_group', '/repo_groups/new', |
|
191 | m.connect('new_repo_group', '/repo_groups/new', | |
192 | action='new', conditions={'method': ['GET']}) |
|
192 | action='new', conditions={'method': ['GET']}) | |
193 | m.connect('update_repo_group', '/repo_groups/{group_name}', |
|
193 | m.connect('update_repo_group', '/repo_groups/{group_name}', | |
194 | action='update', conditions={'method': ['PUT'], |
|
194 | action='update', conditions={'method': ['PUT'], | |
195 | 'function': check_group}, |
|
195 | 'function': check_group}, | |
196 | requirements=URL_NAME_REQUIREMENTS) |
|
196 | requirements=URL_NAME_REQUIREMENTS) | |
197 |
|
197 | |||
198 | # EXTRAS REPO GROUP ROUTES |
|
198 | # EXTRAS REPO GROUP ROUTES | |
199 | m.connect('edit_repo_group', '/repo_groups/{group_name}/edit', |
|
199 | m.connect('edit_repo_group', '/repo_groups/{group_name}/edit', | |
200 | action='edit', |
|
200 | action='edit', | |
201 | conditions={'method': ['GET'], 'function': check_group}, |
|
201 | conditions={'method': ['GET'], 'function': check_group}, | |
202 | requirements=URL_NAME_REQUIREMENTS) |
|
202 | requirements=URL_NAME_REQUIREMENTS) | |
203 | m.connect('edit_repo_group', '/repo_groups/{group_name}/edit', |
|
203 | m.connect('edit_repo_group', '/repo_groups/{group_name}/edit', | |
204 | action='edit', |
|
204 | action='edit', | |
205 | conditions={'method': ['PUT'], 'function': check_group}, |
|
205 | conditions={'method': ['PUT'], 'function': check_group}, | |
206 | requirements=URL_NAME_REQUIREMENTS) |
|
206 | requirements=URL_NAME_REQUIREMENTS) | |
207 |
|
207 | |||
208 | m.connect('edit_repo_group_advanced', '/repo_groups/{group_name}/edit/advanced', |
|
208 | m.connect('edit_repo_group_advanced', '/repo_groups/{group_name}/edit/advanced', | |
209 | action='edit_repo_group_advanced', |
|
209 | action='edit_repo_group_advanced', | |
210 | conditions={'method': ['GET'], 'function': check_group}, |
|
210 | conditions={'method': ['GET'], 'function': check_group}, | |
211 | requirements=URL_NAME_REQUIREMENTS) |
|
211 | requirements=URL_NAME_REQUIREMENTS) | |
212 | m.connect('edit_repo_group_advanced', '/repo_groups/{group_name}/edit/advanced', |
|
212 | m.connect('edit_repo_group_advanced', '/repo_groups/{group_name}/edit/advanced', | |
213 | action='edit_repo_group_advanced', |
|
213 | action='edit_repo_group_advanced', | |
214 | conditions={'method': ['PUT'], 'function': check_group}, |
|
214 | conditions={'method': ['PUT'], 'function': check_group}, | |
215 | requirements=URL_NAME_REQUIREMENTS) |
|
215 | requirements=URL_NAME_REQUIREMENTS) | |
216 |
|
216 | |||
217 | m.connect('edit_repo_group_perms', '/repo_groups/{group_name}/edit/permissions', |
|
217 | m.connect('edit_repo_group_perms', '/repo_groups/{group_name}/edit/permissions', | |
218 | action='edit_repo_group_perms', |
|
218 | action='edit_repo_group_perms', | |
219 | conditions={'method': ['GET'], 'function': check_group}, |
|
219 | conditions={'method': ['GET'], 'function': check_group}, | |
220 | requirements=URL_NAME_REQUIREMENTS) |
|
220 | requirements=URL_NAME_REQUIREMENTS) | |
221 | m.connect('edit_repo_group_perms', '/repo_groups/{group_name}/edit/permissions', |
|
221 | m.connect('edit_repo_group_perms', '/repo_groups/{group_name}/edit/permissions', | |
222 | action='update_perms', |
|
222 | action='update_perms', | |
223 | conditions={'method': ['PUT'], 'function': check_group}, |
|
223 | conditions={'method': ['PUT'], 'function': check_group}, | |
224 | requirements=URL_NAME_REQUIREMENTS) |
|
224 | requirements=URL_NAME_REQUIREMENTS) | |
225 |
|
225 | |||
226 | m.connect('delete_repo_group', '/repo_groups/{group_name}', |
|
226 | m.connect('delete_repo_group', '/repo_groups/{group_name}', | |
227 | action='delete', conditions={'method': ['DELETE'], |
|
227 | action='delete', conditions={'method': ['DELETE'], | |
228 | 'function': check_group}, |
|
228 | 'function': check_group}, | |
229 | requirements=URL_NAME_REQUIREMENTS) |
|
229 | requirements=URL_NAME_REQUIREMENTS) | |
230 |
|
230 | |||
231 | # ADMIN USER ROUTES |
|
231 | # ADMIN USER ROUTES | |
232 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
232 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
233 | controller='admin/users') as m: |
|
233 | controller='admin/users') as m: | |
234 | m.connect('users', '/users', |
|
234 | m.connect('users', '/users', | |
235 | action='create', conditions={'method': ['POST']}) |
|
235 | action='create', conditions={'method': ['POST']}) | |
236 | m.connect('users', '/users', |
|
236 | m.connect('users', '/users', | |
237 | action='index', conditions={'method': ['GET']}) |
|
237 | action='index', conditions={'method': ['GET']}) | |
238 | m.connect('new_user', '/users/new', |
|
238 | m.connect('new_user', '/users/new', | |
239 | action='new', conditions={'method': ['GET']}) |
|
239 | action='new', conditions={'method': ['GET']}) | |
240 | m.connect('update_user', '/users/{user_id}', |
|
240 | m.connect('update_user', '/users/{user_id}', | |
241 | action='update', conditions={'method': ['PUT']}) |
|
241 | action='update', conditions={'method': ['PUT']}) | |
242 | m.connect('delete_user', '/users/{user_id}', |
|
242 | m.connect('delete_user', '/users/{user_id}', | |
243 | action='delete', conditions={'method': ['DELETE']}) |
|
243 | action='delete', conditions={'method': ['DELETE']}) | |
244 | m.connect('edit_user', '/users/{user_id}/edit', |
|
244 | m.connect('edit_user', '/users/{user_id}/edit', | |
245 | action='edit', conditions={'method': ['GET']}) |
|
245 | action='edit', conditions={'method': ['GET']}) | |
246 | m.connect('user', '/users/{user_id}', |
|
246 | m.connect('user', '/users/{user_id}', | |
247 | action='show', conditions={'method': ['GET']}) |
|
247 | action='show', conditions={'method': ['GET']}) | |
248 | m.connect('force_password_reset_user', '/users/{user_id}/password_reset', |
|
248 | m.connect('force_password_reset_user', '/users/{user_id}/password_reset', | |
249 | action='reset_password', conditions={'method': ['POST']}) |
|
249 | action='reset_password', conditions={'method': ['POST']}) | |
250 | m.connect('create_personal_repo_group', '/users/{user_id}/create_repo_group', |
|
250 | m.connect('create_personal_repo_group', '/users/{user_id}/create_repo_group', | |
251 | action='create_personal_repo_group', conditions={'method': ['POST']}) |
|
251 | action='create_personal_repo_group', conditions={'method': ['POST']}) | |
252 |
|
252 | |||
253 | # EXTRAS USER ROUTES |
|
253 | # EXTRAS USER ROUTES | |
254 | m.connect('edit_user_advanced', '/users/{user_id}/edit/advanced', |
|
254 | m.connect('edit_user_advanced', '/users/{user_id}/edit/advanced', | |
255 | action='edit_advanced', conditions={'method': ['GET']}) |
|
255 | action='edit_advanced', conditions={'method': ['GET']}) | |
256 | m.connect('edit_user_advanced', '/users/{user_id}/edit/advanced', |
|
256 | m.connect('edit_user_advanced', '/users/{user_id}/edit/advanced', | |
257 | action='update_advanced', conditions={'method': ['PUT']}) |
|
257 | action='update_advanced', conditions={'method': ['PUT']}) | |
258 |
|
258 | |||
259 | m.connect('edit_user_auth_tokens', '/users/{user_id}/edit/auth_tokens', |
|
259 | m.connect('edit_user_auth_tokens', '/users/{user_id}/edit/auth_tokens', | |
260 | action='edit_auth_tokens', conditions={'method': ['GET']}) |
|
260 | action='edit_auth_tokens', conditions={'method': ['GET']}) | |
261 | m.connect('edit_user_auth_tokens', '/users/{user_id}/edit/auth_tokens', |
|
261 | m.connect('edit_user_auth_tokens', '/users/{user_id}/edit/auth_tokens', | |
262 | action='add_auth_token', conditions={'method': ['PUT']}) |
|
262 | action='add_auth_token', conditions={'method': ['PUT']}) | |
263 | m.connect('edit_user_auth_tokens', '/users/{user_id}/edit/auth_tokens', |
|
263 | m.connect('edit_user_auth_tokens', '/users/{user_id}/edit/auth_tokens', | |
264 | action='delete_auth_token', conditions={'method': ['DELETE']}) |
|
264 | action='delete_auth_token', conditions={'method': ['DELETE']}) | |
265 |
|
265 | |||
266 | m.connect('edit_user_global_perms', '/users/{user_id}/edit/global_permissions', |
|
266 | m.connect('edit_user_global_perms', '/users/{user_id}/edit/global_permissions', | |
267 | action='edit_global_perms', conditions={'method': ['GET']}) |
|
267 | action='edit_global_perms', conditions={'method': ['GET']}) | |
268 | m.connect('edit_user_global_perms', '/users/{user_id}/edit/global_permissions', |
|
268 | m.connect('edit_user_global_perms', '/users/{user_id}/edit/global_permissions', | |
269 | action='update_global_perms', conditions={'method': ['PUT']}) |
|
269 | action='update_global_perms', conditions={'method': ['PUT']}) | |
270 |
|
270 | |||
271 | m.connect('edit_user_perms_summary', '/users/{user_id}/edit/permissions_summary', |
|
271 | m.connect('edit_user_perms_summary', '/users/{user_id}/edit/permissions_summary', | |
272 | action='edit_perms_summary', conditions={'method': ['GET']}) |
|
272 | action='edit_perms_summary', conditions={'method': ['GET']}) | |
273 |
|
273 | |||
274 | m.connect('edit_user_emails', '/users/{user_id}/edit/emails', |
|
274 | m.connect('edit_user_emails', '/users/{user_id}/edit/emails', | |
275 | action='edit_emails', conditions={'method': ['GET']}) |
|
275 | action='edit_emails', conditions={'method': ['GET']}) | |
276 | m.connect('edit_user_emails', '/users/{user_id}/edit/emails', |
|
276 | m.connect('edit_user_emails', '/users/{user_id}/edit/emails', | |
277 | action='add_email', conditions={'method': ['PUT']}) |
|
277 | action='add_email', conditions={'method': ['PUT']}) | |
278 | m.connect('edit_user_emails', '/users/{user_id}/edit/emails', |
|
278 | m.connect('edit_user_emails', '/users/{user_id}/edit/emails', | |
279 | action='delete_email', conditions={'method': ['DELETE']}) |
|
279 | action='delete_email', conditions={'method': ['DELETE']}) | |
280 |
|
280 | |||
281 | m.connect('edit_user_ips', '/users/{user_id}/edit/ips', |
|
281 | m.connect('edit_user_ips', '/users/{user_id}/edit/ips', | |
282 | action='edit_ips', conditions={'method': ['GET']}) |
|
282 | action='edit_ips', conditions={'method': ['GET']}) | |
283 | m.connect('edit_user_ips', '/users/{user_id}/edit/ips', |
|
283 | m.connect('edit_user_ips', '/users/{user_id}/edit/ips', | |
284 | action='add_ip', conditions={'method': ['PUT']}) |
|
284 | action='add_ip', conditions={'method': ['PUT']}) | |
285 | m.connect('edit_user_ips', '/users/{user_id}/edit/ips', |
|
285 | m.connect('edit_user_ips', '/users/{user_id}/edit/ips', | |
286 | action='delete_ip', conditions={'method': ['DELETE']}) |
|
286 | action='delete_ip', conditions={'method': ['DELETE']}) | |
287 |
|
287 | |||
288 | # ADMIN USER GROUPS REST ROUTES |
|
288 | # ADMIN USER GROUPS REST ROUTES | |
289 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
289 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
290 | controller='admin/user_groups') as m: |
|
290 | controller='admin/user_groups') as m: | |
291 | m.connect('users_groups', '/user_groups', |
|
291 | m.connect('users_groups', '/user_groups', | |
292 | action='create', conditions={'method': ['POST']}) |
|
292 | action='create', conditions={'method': ['POST']}) | |
293 | m.connect('users_groups', '/user_groups', |
|
293 | m.connect('users_groups', '/user_groups', | |
294 | action='index', conditions={'method': ['GET']}) |
|
294 | action='index', conditions={'method': ['GET']}) | |
295 | m.connect('new_users_group', '/user_groups/new', |
|
295 | m.connect('new_users_group', '/user_groups/new', | |
296 | action='new', conditions={'method': ['GET']}) |
|
296 | action='new', conditions={'method': ['GET']}) | |
297 | m.connect('update_users_group', '/user_groups/{user_group_id}', |
|
297 | m.connect('update_users_group', '/user_groups/{user_group_id}', | |
298 | action='update', conditions={'method': ['PUT']}) |
|
298 | action='update', conditions={'method': ['PUT']}) | |
299 | m.connect('delete_users_group', '/user_groups/{user_group_id}', |
|
299 | m.connect('delete_users_group', '/user_groups/{user_group_id}', | |
300 | action='delete', conditions={'method': ['DELETE']}) |
|
300 | action='delete', conditions={'method': ['DELETE']}) | |
301 | m.connect('edit_users_group', '/user_groups/{user_group_id}/edit', |
|
301 | m.connect('edit_users_group', '/user_groups/{user_group_id}/edit', | |
302 | action='edit', conditions={'method': ['GET']}, |
|
302 | action='edit', conditions={'method': ['GET']}, | |
303 | function=check_user_group) |
|
303 | function=check_user_group) | |
304 |
|
304 | |||
305 | # EXTRAS USER GROUP ROUTES |
|
305 | # EXTRAS USER GROUP ROUTES | |
306 | m.connect('edit_user_group_global_perms', '/user_groups/{user_group_id}/edit/global_permissions', |
|
306 | m.connect('edit_user_group_global_perms', '/user_groups/{user_group_id}/edit/global_permissions', | |
307 | action='edit_global_perms', conditions={'method': ['GET']}) |
|
307 | action='edit_global_perms', conditions={'method': ['GET']}) | |
308 | m.connect('edit_user_group_global_perms', '/user_groups/{user_group_id}/edit/global_permissions', |
|
308 | m.connect('edit_user_group_global_perms', '/user_groups/{user_group_id}/edit/global_permissions', | |
309 | action='update_global_perms', conditions={'method': ['PUT']}) |
|
309 | action='update_global_perms', conditions={'method': ['PUT']}) | |
310 | m.connect('edit_user_group_perms_summary', '/user_groups/{user_group_id}/edit/permissions_summary', |
|
310 | m.connect('edit_user_group_perms_summary', '/user_groups/{user_group_id}/edit/permissions_summary', | |
311 | action='edit_perms_summary', conditions={'method': ['GET']}) |
|
311 | action='edit_perms_summary', conditions={'method': ['GET']}) | |
312 |
|
312 | |||
313 | m.connect('edit_user_group_perms', '/user_groups/{user_group_id}/edit/permissions', |
|
313 | m.connect('edit_user_group_perms', '/user_groups/{user_group_id}/edit/permissions', | |
314 | action='edit_perms', conditions={'method': ['GET']}) |
|
314 | action='edit_perms', conditions={'method': ['GET']}) | |
315 | m.connect('edit_user_group_perms', '/user_groups/{user_group_id}/edit/permissions', |
|
315 | m.connect('edit_user_group_perms', '/user_groups/{user_group_id}/edit/permissions', | |
316 | action='update_perms', conditions={'method': ['PUT']}) |
|
316 | action='update_perms', conditions={'method': ['PUT']}) | |
317 |
|
317 | |||
318 | m.connect('edit_user_group_advanced', '/user_groups/{user_group_id}/edit/advanced', |
|
318 | m.connect('edit_user_group_advanced', '/user_groups/{user_group_id}/edit/advanced', | |
319 | action='edit_advanced', conditions={'method': ['GET']}) |
|
319 | action='edit_advanced', conditions={'method': ['GET']}) | |
320 |
|
320 | |||
321 | m.connect('edit_user_group_members', '/user_groups/{user_group_id}/edit/members', |
|
321 | m.connect('edit_user_group_members', '/user_groups/{user_group_id}/edit/members', | |
322 | action='edit_members', conditions={'method': ['GET']}) |
|
322 | action='edit_members', conditions={'method': ['GET']}) | |
323 |
|
323 | |||
324 | # ADMIN PERMISSIONS ROUTES |
|
324 | # ADMIN PERMISSIONS ROUTES | |
325 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
325 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
326 | controller='admin/permissions') as m: |
|
326 | controller='admin/permissions') as m: | |
327 | m.connect('admin_permissions_application', '/permissions/application', |
|
327 | m.connect('admin_permissions_application', '/permissions/application', | |
328 | action='permission_application_update', conditions={'method': ['POST']}) |
|
328 | action='permission_application_update', conditions={'method': ['POST']}) | |
329 | m.connect('admin_permissions_application', '/permissions/application', |
|
329 | m.connect('admin_permissions_application', '/permissions/application', | |
330 | action='permission_application', conditions={'method': ['GET']}) |
|
330 | action='permission_application', conditions={'method': ['GET']}) | |
331 |
|
331 | |||
332 | m.connect('admin_permissions_global', '/permissions/global', |
|
332 | m.connect('admin_permissions_global', '/permissions/global', | |
333 | action='permission_global_update', conditions={'method': ['POST']}) |
|
333 | action='permission_global_update', conditions={'method': ['POST']}) | |
334 | m.connect('admin_permissions_global', '/permissions/global', |
|
334 | m.connect('admin_permissions_global', '/permissions/global', | |
335 | action='permission_global', conditions={'method': ['GET']}) |
|
335 | action='permission_global', conditions={'method': ['GET']}) | |
336 |
|
336 | |||
337 | m.connect('admin_permissions_object', '/permissions/object', |
|
337 | m.connect('admin_permissions_object', '/permissions/object', | |
338 | action='permission_objects_update', conditions={'method': ['POST']}) |
|
338 | action='permission_objects_update', conditions={'method': ['POST']}) | |
339 | m.connect('admin_permissions_object', '/permissions/object', |
|
339 | m.connect('admin_permissions_object', '/permissions/object', | |
340 | action='permission_objects', conditions={'method': ['GET']}) |
|
340 | action='permission_objects', conditions={'method': ['GET']}) | |
341 |
|
341 | |||
342 | m.connect('admin_permissions_ips', '/permissions/ips', |
|
342 | m.connect('admin_permissions_ips', '/permissions/ips', | |
343 | action='permission_ips', conditions={'method': ['POST']}) |
|
343 | action='permission_ips', conditions={'method': ['POST']}) | |
344 | m.connect('admin_permissions_ips', '/permissions/ips', |
|
344 | m.connect('admin_permissions_ips', '/permissions/ips', | |
345 | action='permission_ips', conditions={'method': ['GET']}) |
|
345 | action='permission_ips', conditions={'method': ['GET']}) | |
346 |
|
346 | |||
347 | m.connect('admin_permissions_overview', '/permissions/overview', |
|
347 | m.connect('admin_permissions_overview', '/permissions/overview', | |
348 | action='permission_perms', conditions={'method': ['GET']}) |
|
348 | action='permission_perms', conditions={'method': ['GET']}) | |
349 |
|
349 | |||
350 | # ADMIN DEFAULTS REST ROUTES |
|
350 | # ADMIN DEFAULTS REST ROUTES | |
351 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
351 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
352 | controller='admin/defaults') as m: |
|
352 | controller='admin/defaults') as m: | |
353 | m.connect('admin_defaults_repositories', '/defaults/repositories', |
|
353 | m.connect('admin_defaults_repositories', '/defaults/repositories', | |
354 | action='update_repository_defaults', conditions={'method': ['POST']}) |
|
354 | action='update_repository_defaults', conditions={'method': ['POST']}) | |
355 | m.connect('admin_defaults_repositories', '/defaults/repositories', |
|
355 | m.connect('admin_defaults_repositories', '/defaults/repositories', | |
356 | action='index', conditions={'method': ['GET']}) |
|
356 | action='index', conditions={'method': ['GET']}) | |
357 |
|
357 | |||
358 | # ADMIN DEBUG STYLE ROUTES |
|
358 | # ADMIN DEBUG STYLE ROUTES | |
359 | if str2bool(config.get('debug_style')): |
|
359 | if str2bool(config.get('debug_style')): | |
360 | with rmap.submapper(path_prefix=ADMIN_PREFIX + '/debug_style', |
|
360 | with rmap.submapper(path_prefix=ADMIN_PREFIX + '/debug_style', | |
361 | controller='debug_style') as m: |
|
361 | controller='debug_style') as m: | |
362 | m.connect('debug_style_home', '', |
|
362 | m.connect('debug_style_home', '', | |
363 | action='index', conditions={'method': ['GET']}) |
|
363 | action='index', conditions={'method': ['GET']}) | |
364 | m.connect('debug_style_template', '/t/{t_path}', |
|
364 | m.connect('debug_style_template', '/t/{t_path}', | |
365 | action='template', conditions={'method': ['GET']}) |
|
365 | action='template', conditions={'method': ['GET']}) | |
366 |
|
366 | |||
367 | # ADMIN SETTINGS ROUTES |
|
367 | # ADMIN SETTINGS ROUTES | |
368 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
368 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
369 | controller='admin/settings') as m: |
|
369 | controller='admin/settings') as m: | |
370 |
|
370 | |||
371 | # default |
|
371 | # default | |
372 | m.connect('admin_settings', '/settings', |
|
372 | m.connect('admin_settings', '/settings', | |
373 | action='settings_global_update', |
|
373 | action='settings_global_update', | |
374 | conditions={'method': ['POST']}) |
|
374 | conditions={'method': ['POST']}) | |
375 | m.connect('admin_settings', '/settings', |
|
375 | m.connect('admin_settings', '/settings', | |
376 | action='settings_global', conditions={'method': ['GET']}) |
|
376 | action='settings_global', conditions={'method': ['GET']}) | |
377 |
|
377 | |||
378 | m.connect('admin_settings_vcs', '/settings/vcs', |
|
378 | m.connect('admin_settings_vcs', '/settings/vcs', | |
379 | action='settings_vcs_update', |
|
379 | action='settings_vcs_update', | |
380 | conditions={'method': ['POST']}) |
|
380 | conditions={'method': ['POST']}) | |
381 | m.connect('admin_settings_vcs', '/settings/vcs', |
|
381 | m.connect('admin_settings_vcs', '/settings/vcs', | |
382 | action='settings_vcs', |
|
382 | action='settings_vcs', | |
383 | conditions={'method': ['GET']}) |
|
383 | conditions={'method': ['GET']}) | |
384 | m.connect('admin_settings_vcs', '/settings/vcs', |
|
384 | m.connect('admin_settings_vcs', '/settings/vcs', | |
385 | action='delete_svn_pattern', |
|
385 | action='delete_svn_pattern', | |
386 | conditions={'method': ['DELETE']}) |
|
386 | conditions={'method': ['DELETE']}) | |
387 |
|
387 | |||
388 | m.connect('admin_settings_mapping', '/settings/mapping', |
|
388 | m.connect('admin_settings_mapping', '/settings/mapping', | |
389 | action='settings_mapping_update', |
|
389 | action='settings_mapping_update', | |
390 | conditions={'method': ['POST']}) |
|
390 | conditions={'method': ['POST']}) | |
391 | m.connect('admin_settings_mapping', '/settings/mapping', |
|
391 | m.connect('admin_settings_mapping', '/settings/mapping', | |
392 | action='settings_mapping', conditions={'method': ['GET']}) |
|
392 | action='settings_mapping', conditions={'method': ['GET']}) | |
393 |
|
393 | |||
394 | m.connect('admin_settings_global', '/settings/global', |
|
394 | m.connect('admin_settings_global', '/settings/global', | |
395 | action='settings_global_update', |
|
395 | action='settings_global_update', | |
396 | conditions={'method': ['POST']}) |
|
396 | conditions={'method': ['POST']}) | |
397 | m.connect('admin_settings_global', '/settings/global', |
|
397 | m.connect('admin_settings_global', '/settings/global', | |
398 | action='settings_global', conditions={'method': ['GET']}) |
|
398 | action='settings_global', conditions={'method': ['GET']}) | |
399 |
|
399 | |||
400 | m.connect('admin_settings_visual', '/settings/visual', |
|
400 | m.connect('admin_settings_visual', '/settings/visual', | |
401 | action='settings_visual_update', |
|
401 | action='settings_visual_update', | |
402 | conditions={'method': ['POST']}) |
|
402 | conditions={'method': ['POST']}) | |
403 | m.connect('admin_settings_visual', '/settings/visual', |
|
403 | m.connect('admin_settings_visual', '/settings/visual', | |
404 | action='settings_visual', conditions={'method': ['GET']}) |
|
404 | action='settings_visual', conditions={'method': ['GET']}) | |
405 |
|
405 | |||
406 | m.connect('admin_settings_issuetracker', |
|
406 | m.connect('admin_settings_issuetracker', | |
407 | '/settings/issue-tracker', action='settings_issuetracker', |
|
407 | '/settings/issue-tracker', action='settings_issuetracker', | |
408 | conditions={'method': ['GET']}) |
|
408 | conditions={'method': ['GET']}) | |
409 | m.connect('admin_settings_issuetracker_save', |
|
409 | m.connect('admin_settings_issuetracker_save', | |
410 | '/settings/issue-tracker/save', |
|
410 | '/settings/issue-tracker/save', | |
411 | action='settings_issuetracker_save', |
|
411 | action='settings_issuetracker_save', | |
412 | conditions={'method': ['POST']}) |
|
412 | conditions={'method': ['POST']}) | |
413 | m.connect('admin_issuetracker_test', '/settings/issue-tracker/test', |
|
413 | m.connect('admin_issuetracker_test', '/settings/issue-tracker/test', | |
414 | action='settings_issuetracker_test', |
|
414 | action='settings_issuetracker_test', | |
415 | conditions={'method': ['POST']}) |
|
415 | conditions={'method': ['POST']}) | |
416 | m.connect('admin_issuetracker_delete', |
|
416 | m.connect('admin_issuetracker_delete', | |
417 | '/settings/issue-tracker/delete', |
|
417 | '/settings/issue-tracker/delete', | |
418 | action='settings_issuetracker_delete', |
|
418 | action='settings_issuetracker_delete', | |
419 | conditions={'method': ['DELETE']}) |
|
419 | conditions={'method': ['DELETE']}) | |
420 |
|
420 | |||
421 | m.connect('admin_settings_email', '/settings/email', |
|
421 | m.connect('admin_settings_email', '/settings/email', | |
422 | action='settings_email_update', |
|
422 | action='settings_email_update', | |
423 | conditions={'method': ['POST']}) |
|
423 | conditions={'method': ['POST']}) | |
424 | m.connect('admin_settings_email', '/settings/email', |
|
424 | m.connect('admin_settings_email', '/settings/email', | |
425 | action='settings_email', conditions={'method': ['GET']}) |
|
425 | action='settings_email', conditions={'method': ['GET']}) | |
426 |
|
426 | |||
427 | m.connect('admin_settings_hooks', '/settings/hooks', |
|
427 | m.connect('admin_settings_hooks', '/settings/hooks', | |
428 | action='settings_hooks_update', |
|
428 | action='settings_hooks_update', | |
429 | conditions={'method': ['POST', 'DELETE']}) |
|
429 | conditions={'method': ['POST', 'DELETE']}) | |
430 | m.connect('admin_settings_hooks', '/settings/hooks', |
|
430 | m.connect('admin_settings_hooks', '/settings/hooks', | |
431 | action='settings_hooks', conditions={'method': ['GET']}) |
|
431 | action='settings_hooks', conditions={'method': ['GET']}) | |
432 |
|
432 | |||
433 | m.connect('admin_settings_search', '/settings/search', |
|
433 | m.connect('admin_settings_search', '/settings/search', | |
434 | action='settings_search', conditions={'method': ['GET']}) |
|
434 | action='settings_search', conditions={'method': ['GET']}) | |
435 |
|
435 | |||
436 | m.connect('admin_settings_system', '/settings/system', |
|
436 | m.connect('admin_settings_system', '/settings/system', | |
437 | action='settings_system', conditions={'method': ['GET']}) |
|
437 | action='settings_system', conditions={'method': ['GET']}) | |
438 |
|
438 | |||
439 | m.connect('admin_settings_system_update', '/settings/system/updates', |
|
439 | m.connect('admin_settings_system_update', '/settings/system/updates', | |
440 | action='settings_system_update', conditions={'method': ['GET']}) |
|
440 | action='settings_system_update', conditions={'method': ['GET']}) | |
441 |
|
441 | |||
442 | m.connect('admin_settings_supervisor', '/settings/supervisor', |
|
442 | m.connect('admin_settings_supervisor', '/settings/supervisor', | |
443 | action='settings_supervisor', conditions={'method': ['GET']}) |
|
443 | action='settings_supervisor', conditions={'method': ['GET']}) | |
444 | m.connect('admin_settings_supervisor_log', '/settings/supervisor/{procid}/log', |
|
444 | m.connect('admin_settings_supervisor_log', '/settings/supervisor/{procid}/log', | |
445 | action='settings_supervisor_log', conditions={'method': ['GET']}) |
|
445 | action='settings_supervisor_log', conditions={'method': ['GET']}) | |
446 |
|
446 | |||
447 | m.connect('admin_settings_labs', '/settings/labs', |
|
447 | m.connect('admin_settings_labs', '/settings/labs', | |
448 | action='settings_labs_update', |
|
448 | action='settings_labs_update', | |
449 | conditions={'method': ['POST']}) |
|
449 | conditions={'method': ['POST']}) | |
450 | m.connect('admin_settings_labs', '/settings/labs', |
|
450 | m.connect('admin_settings_labs', '/settings/labs', | |
451 | action='settings_labs', conditions={'method': ['GET']}) |
|
451 | action='settings_labs', conditions={'method': ['GET']}) | |
452 |
|
452 | |||
453 | m.connect('admin_settings_open_source', '/settings/open_source', |
|
453 | m.connect('admin_settings_open_source', '/settings/open_source', | |
454 | action='settings_open_source', |
|
454 | action='settings_open_source', | |
455 | conditions={'method': ['GET']}) |
|
455 | conditions={'method': ['GET']}) | |
456 |
|
456 | |||
457 | # ADMIN MY ACCOUNT |
|
457 | # ADMIN MY ACCOUNT | |
458 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
458 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
459 | controller='admin/my_account') as m: |
|
459 | controller='admin/my_account') as m: | |
460 |
|
460 | |||
461 | m.connect('my_account', '/my_account', |
|
461 | m.connect('my_account', '/my_account', | |
462 | action='my_account', conditions={'method': ['GET']}) |
|
462 | action='my_account', conditions={'method': ['GET']}) | |
463 | m.connect('my_account_edit', '/my_account/edit', |
|
463 | m.connect('my_account_edit', '/my_account/edit', | |
464 | action='my_account_edit', conditions={'method': ['GET']}) |
|
464 | action='my_account_edit', conditions={'method': ['GET']}) | |
465 | m.connect('my_account', '/my_account', |
|
465 | m.connect('my_account', '/my_account', | |
466 | action='my_account_update', conditions={'method': ['POST']}) |
|
466 | action='my_account_update', conditions={'method': ['POST']}) | |
467 |
|
467 | |||
468 | m.connect('my_account_password', '/my_account/password', |
|
468 | m.connect('my_account_password', '/my_account/password', | |
469 | action='my_account_password', conditions={'method': ['GET']}) |
|
469 | action='my_account_password', conditions={'method': ['GET']}) | |
470 | m.connect('my_account_password', '/my_account/password', |
|
470 | m.connect('my_account_password', '/my_account/password', | |
471 | action='my_account_password_update', conditions={'method': ['POST']}) |
|
471 | action='my_account_password_update', conditions={'method': ['POST']}) | |
472 |
|
472 | |||
473 | m.connect('my_account_repos', '/my_account/repos', |
|
473 | m.connect('my_account_repos', '/my_account/repos', | |
474 | action='my_account_repos', conditions={'method': ['GET']}) |
|
474 | action='my_account_repos', conditions={'method': ['GET']}) | |
475 |
|
475 | |||
476 | m.connect('my_account_watched', '/my_account/watched', |
|
476 | m.connect('my_account_watched', '/my_account/watched', | |
477 | action='my_account_watched', conditions={'method': ['GET']}) |
|
477 | action='my_account_watched', conditions={'method': ['GET']}) | |
478 |
|
478 | |||
479 | m.connect('my_account_pullrequests', '/my_account/pull_requests', |
|
479 | m.connect('my_account_pullrequests', '/my_account/pull_requests', | |
480 | action='my_account_pullrequests', conditions={'method': ['GET']}) |
|
480 | action='my_account_pullrequests', conditions={'method': ['GET']}) | |
481 |
|
481 | |||
482 | m.connect('my_account_perms', '/my_account/perms', |
|
482 | m.connect('my_account_perms', '/my_account/perms', | |
483 | action='my_account_perms', conditions={'method': ['GET']}) |
|
483 | action='my_account_perms', conditions={'method': ['GET']}) | |
484 |
|
484 | |||
485 | m.connect('my_account_emails', '/my_account/emails', |
|
485 | m.connect('my_account_emails', '/my_account/emails', | |
486 | action='my_account_emails', conditions={'method': ['GET']}) |
|
486 | action='my_account_emails', conditions={'method': ['GET']}) | |
487 | m.connect('my_account_emails', '/my_account/emails', |
|
487 | m.connect('my_account_emails', '/my_account/emails', | |
488 | action='my_account_emails_add', conditions={'method': ['POST']}) |
|
488 | action='my_account_emails_add', conditions={'method': ['POST']}) | |
489 | m.connect('my_account_emails', '/my_account/emails', |
|
489 | m.connect('my_account_emails', '/my_account/emails', | |
490 | action='my_account_emails_delete', conditions={'method': ['DELETE']}) |
|
490 | action='my_account_emails_delete', conditions={'method': ['DELETE']}) | |
491 |
|
491 | |||
492 | m.connect('my_account_auth_tokens', '/my_account/auth_tokens', |
|
492 | m.connect('my_account_auth_tokens', '/my_account/auth_tokens', | |
493 | action='my_account_auth_tokens', conditions={'method': ['GET']}) |
|
493 | action='my_account_auth_tokens', conditions={'method': ['GET']}) | |
494 | m.connect('my_account_auth_tokens', '/my_account/auth_tokens', |
|
494 | m.connect('my_account_auth_tokens', '/my_account/auth_tokens', | |
495 | action='my_account_auth_tokens_add', conditions={'method': ['POST']}) |
|
495 | action='my_account_auth_tokens_add', conditions={'method': ['POST']}) | |
496 | m.connect('my_account_auth_tokens', '/my_account/auth_tokens', |
|
496 | m.connect('my_account_auth_tokens', '/my_account/auth_tokens', | |
497 | action='my_account_auth_tokens_delete', conditions={'method': ['DELETE']}) |
|
497 | action='my_account_auth_tokens_delete', conditions={'method': ['DELETE']}) | |
498 |
|
498 | |||
499 | m.connect('my_account_oauth', '/my_account/oauth', |
|
|||
500 | action='my_account_oauth', conditions={'method': ['GET']}) |
|
|||
501 | m.connect('my_account_oauth', '/my_account/oauth', |
|
|||
502 | action='my_account_oauth_delete', |
|
|||
503 | conditions={'method': ['DELETE']}) |
|
|||
504 |
|
||||
505 | # NOTIFICATION REST ROUTES |
|
499 | # NOTIFICATION REST ROUTES | |
506 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
500 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
507 | controller='admin/notifications') as m: |
|
501 | controller='admin/notifications') as m: | |
508 | m.connect('notifications', '/notifications', |
|
502 | m.connect('notifications', '/notifications', | |
509 | action='index', conditions={'method': ['GET']}) |
|
503 | action='index', conditions={'method': ['GET']}) | |
510 | m.connect('notifications_mark_all_read', '/notifications/mark_all_read', |
|
504 | m.connect('notifications_mark_all_read', '/notifications/mark_all_read', | |
511 | action='mark_all_read', conditions={'method': ['POST']}) |
|
505 | action='mark_all_read', conditions={'method': ['POST']}) | |
512 |
|
506 | |||
513 | m.connect('/notifications/{notification_id}', |
|
507 | m.connect('/notifications/{notification_id}', | |
514 | action='update', conditions={'method': ['PUT']}) |
|
508 | action='update', conditions={'method': ['PUT']}) | |
515 | m.connect('/notifications/{notification_id}', |
|
509 | m.connect('/notifications/{notification_id}', | |
516 | action='delete', conditions={'method': ['DELETE']}) |
|
510 | action='delete', conditions={'method': ['DELETE']}) | |
517 | m.connect('notification', '/notifications/{notification_id}', |
|
511 | m.connect('notification', '/notifications/{notification_id}', | |
518 | action='show', conditions={'method': ['GET']}) |
|
512 | action='show', conditions={'method': ['GET']}) | |
519 |
|
513 | |||
520 | # ADMIN GIST |
|
514 | # ADMIN GIST | |
521 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
515 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
522 | controller='admin/gists') as m: |
|
516 | controller='admin/gists') as m: | |
523 | m.connect('gists', '/gists', |
|
517 | m.connect('gists', '/gists', | |
524 | action='create', conditions={'method': ['POST']}) |
|
518 | action='create', conditions={'method': ['POST']}) | |
525 | m.connect('gists', '/gists', |
|
519 | m.connect('gists', '/gists', | |
526 | action='index', conditions={'method': ['GET']}) |
|
520 | action='index', conditions={'method': ['GET']}) | |
527 | m.connect('new_gist', '/gists/new', |
|
521 | m.connect('new_gist', '/gists/new', | |
528 | action='new', conditions={'method': ['GET']}) |
|
522 | action='new', conditions={'method': ['GET']}) | |
529 |
|
523 | |||
530 | m.connect('/gists/{gist_id}', |
|
524 | m.connect('/gists/{gist_id}', | |
531 | action='delete', conditions={'method': ['DELETE']}) |
|
525 | action='delete', conditions={'method': ['DELETE']}) | |
532 | m.connect('edit_gist', '/gists/{gist_id}/edit', |
|
526 | m.connect('edit_gist', '/gists/{gist_id}/edit', | |
533 | action='edit_form', conditions={'method': ['GET']}) |
|
527 | action='edit_form', conditions={'method': ['GET']}) | |
534 | m.connect('edit_gist', '/gists/{gist_id}/edit', |
|
528 | m.connect('edit_gist', '/gists/{gist_id}/edit', | |
535 | action='edit', conditions={'method': ['POST']}) |
|
529 | action='edit', conditions={'method': ['POST']}) | |
536 | m.connect( |
|
530 | m.connect( | |
537 | 'edit_gist_check_revision', '/gists/{gist_id}/edit/check_revision', |
|
531 | 'edit_gist_check_revision', '/gists/{gist_id}/edit/check_revision', | |
538 | action='check_revision', conditions={'method': ['GET']}) |
|
532 | action='check_revision', conditions={'method': ['GET']}) | |
539 |
|
533 | |||
540 | m.connect('gist', '/gists/{gist_id}', |
|
534 | m.connect('gist', '/gists/{gist_id}', | |
541 | action='show', conditions={'method': ['GET']}) |
|
535 | action='show', conditions={'method': ['GET']}) | |
542 | m.connect('gist_rev', '/gists/{gist_id}/{revision}', |
|
536 | m.connect('gist_rev', '/gists/{gist_id}/{revision}', | |
543 | revision='tip', |
|
537 | revision='tip', | |
544 | action='show', conditions={'method': ['GET']}) |
|
538 | action='show', conditions={'method': ['GET']}) | |
545 | m.connect('formatted_gist', '/gists/{gist_id}/{revision}/{format}', |
|
539 | m.connect('formatted_gist', '/gists/{gist_id}/{revision}/{format}', | |
546 | revision='tip', |
|
540 | revision='tip', | |
547 | action='show', conditions={'method': ['GET']}) |
|
541 | action='show', conditions={'method': ['GET']}) | |
548 | m.connect('formatted_gist_file', '/gists/{gist_id}/{revision}/{format}/{f_path}', |
|
542 | m.connect('formatted_gist_file', '/gists/{gist_id}/{revision}/{format}/{f_path}', | |
549 | revision='tip', |
|
543 | revision='tip', | |
550 | action='show', conditions={'method': ['GET']}, |
|
544 | action='show', conditions={'method': ['GET']}, | |
551 | requirements=URL_NAME_REQUIREMENTS) |
|
545 | requirements=URL_NAME_REQUIREMENTS) | |
552 |
|
546 | |||
553 | # ADMIN MAIN PAGES |
|
547 | # ADMIN MAIN PAGES | |
554 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
548 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
555 | controller='admin/admin') as m: |
|
549 | controller='admin/admin') as m: | |
556 | m.connect('admin_home', '', action='index') |
|
550 | m.connect('admin_home', '', action='index') | |
557 | m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}', |
|
551 | m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}', | |
558 | action='add_repo') |
|
552 | action='add_repo') | |
559 | m.connect( |
|
553 | m.connect( | |
560 | 'pull_requests_global', '/pull_requests/{pull_request_id:[0-9]+}', |
|
554 | 'pull_requests_global', '/pull_requests/{pull_request_id:[0-9]+}', | |
561 | action='pull_requests') |
|
555 | action='pull_requests') | |
562 |
|
556 | |||
563 | # USER JOURNAL |
|
557 | # USER JOURNAL | |
564 | rmap.connect('journal', '%s/journal' % (ADMIN_PREFIX,), |
|
558 | rmap.connect('journal', '%s/journal' % (ADMIN_PREFIX,), | |
565 | controller='journal', action='index') |
|
559 | controller='journal', action='index') | |
566 | rmap.connect('journal_rss', '%s/journal/rss' % (ADMIN_PREFIX,), |
|
560 | rmap.connect('journal_rss', '%s/journal/rss' % (ADMIN_PREFIX,), | |
567 | controller='journal', action='journal_rss') |
|
561 | controller='journal', action='journal_rss') | |
568 | rmap.connect('journal_atom', '%s/journal/atom' % (ADMIN_PREFIX,), |
|
562 | rmap.connect('journal_atom', '%s/journal/atom' % (ADMIN_PREFIX,), | |
569 | controller='journal', action='journal_atom') |
|
563 | controller='journal', action='journal_atom') | |
570 |
|
564 | |||
571 | rmap.connect('public_journal', '%s/public_journal' % (ADMIN_PREFIX,), |
|
565 | rmap.connect('public_journal', '%s/public_journal' % (ADMIN_PREFIX,), | |
572 | controller='journal', action='public_journal') |
|
566 | controller='journal', action='public_journal') | |
573 |
|
567 | |||
574 | rmap.connect('public_journal_rss', '%s/public_journal/rss' % (ADMIN_PREFIX,), |
|
568 | rmap.connect('public_journal_rss', '%s/public_journal/rss' % (ADMIN_PREFIX,), | |
575 | controller='journal', action='public_journal_rss') |
|
569 | controller='journal', action='public_journal_rss') | |
576 |
|
570 | |||
577 | rmap.connect('public_journal_rss_old', '%s/public_journal_rss' % (ADMIN_PREFIX,), |
|
571 | rmap.connect('public_journal_rss_old', '%s/public_journal_rss' % (ADMIN_PREFIX,), | |
578 | controller='journal', action='public_journal_rss') |
|
572 | controller='journal', action='public_journal_rss') | |
579 |
|
573 | |||
580 | rmap.connect('public_journal_atom', |
|
574 | rmap.connect('public_journal_atom', | |
581 | '%s/public_journal/atom' % (ADMIN_PREFIX,), controller='journal', |
|
575 | '%s/public_journal/atom' % (ADMIN_PREFIX,), controller='journal', | |
582 | action='public_journal_atom') |
|
576 | action='public_journal_atom') | |
583 |
|
577 | |||
584 | rmap.connect('public_journal_atom_old', |
|
578 | rmap.connect('public_journal_atom_old', | |
585 | '%s/public_journal_atom' % (ADMIN_PREFIX,), controller='journal', |
|
579 | '%s/public_journal_atom' % (ADMIN_PREFIX,), controller='journal', | |
586 | action='public_journal_atom') |
|
580 | action='public_journal_atom') | |
587 |
|
581 | |||
588 | rmap.connect('toggle_following', '%s/toggle_following' % (ADMIN_PREFIX,), |
|
582 | rmap.connect('toggle_following', '%s/toggle_following' % (ADMIN_PREFIX,), | |
589 | controller='journal', action='toggle_following', |
|
583 | controller='journal', action='toggle_following', | |
590 | conditions={'method': ['POST']}) |
|
584 | conditions={'method': ['POST']}) | |
591 |
|
585 | |||
592 | # FULL TEXT SEARCH |
|
586 | # FULL TEXT SEARCH | |
593 | rmap.connect('search', '%s/search' % (ADMIN_PREFIX,), |
|
587 | rmap.connect('search', '%s/search' % (ADMIN_PREFIX,), | |
594 | controller='search') |
|
588 | controller='search') | |
595 | rmap.connect('search_repo_home', '/{repo_name}/search', |
|
589 | rmap.connect('search_repo_home', '/{repo_name}/search', | |
596 | controller='search', |
|
590 | controller='search', | |
597 | action='index', |
|
591 | action='index', | |
598 | conditions={'function': check_repo}, |
|
592 | conditions={'function': check_repo}, | |
599 | requirements=URL_NAME_REQUIREMENTS) |
|
593 | requirements=URL_NAME_REQUIREMENTS) | |
600 |
|
594 | |||
601 | # LOGIN/LOGOUT/REGISTER/SIGN IN |
|
595 | # LOGIN/LOGOUT/REGISTER/SIGN IN | |
602 | rmap.connect('login_home', '%s/login' % (ADMIN_PREFIX,), controller='login', |
|
596 | rmap.connect('login_home', '%s/login' % (ADMIN_PREFIX,), controller='login', | |
603 | action='index') |
|
597 | action='index') | |
604 |
|
598 | |||
605 | rmap.connect('logout_home', '%s/logout' % (ADMIN_PREFIX,), controller='login', |
|
599 | rmap.connect('logout_home', '%s/logout' % (ADMIN_PREFIX,), controller='login', | |
606 | action='logout', conditions={'method': ['POST']}) |
|
600 | action='logout', conditions={'method': ['POST']}) | |
607 |
|
601 | |||
608 | rmap.connect('register', '%s/register' % (ADMIN_PREFIX,), controller='login', |
|
602 | rmap.connect('register', '%s/register' % (ADMIN_PREFIX,), controller='login', | |
609 | action='register') |
|
603 | action='register') | |
610 |
|
604 | |||
611 | rmap.connect('reset_password', '%s/password_reset' % (ADMIN_PREFIX,), |
|
605 | rmap.connect('reset_password', '%s/password_reset' % (ADMIN_PREFIX,), | |
612 | controller='login', action='password_reset') |
|
606 | controller='login', action='password_reset') | |
613 |
|
607 | |||
614 | rmap.connect('reset_password_confirmation', |
|
608 | rmap.connect('reset_password_confirmation', | |
615 | '%s/password_reset_confirmation' % (ADMIN_PREFIX,), |
|
609 | '%s/password_reset_confirmation' % (ADMIN_PREFIX,), | |
616 | controller='login', action='password_reset_confirmation') |
|
610 | controller='login', action='password_reset_confirmation') | |
617 |
|
611 | |||
618 | rmap.connect('social_auth', |
|
612 | rmap.connect('social_auth', | |
619 | '%s/social_auth/{provider_name}' % (ADMIN_PREFIX,), |
|
613 | '%s/social_auth/{provider_name}' % (ADMIN_PREFIX,), | |
620 | controller='login', action='social_auth') |
|
614 | controller='login', action='social_auth') | |
621 |
|
615 | |||
622 | # FEEDS |
|
616 | # FEEDS | |
623 | rmap.connect('rss_feed_home', '/{repo_name}/feed/rss', |
|
617 | rmap.connect('rss_feed_home', '/{repo_name}/feed/rss', | |
624 | controller='feed', action='rss', |
|
618 | controller='feed', action='rss', | |
625 | conditions={'function': check_repo}, |
|
619 | conditions={'function': check_repo}, | |
626 | requirements=URL_NAME_REQUIREMENTS) |
|
620 | requirements=URL_NAME_REQUIREMENTS) | |
627 |
|
621 | |||
628 | rmap.connect('atom_feed_home', '/{repo_name}/feed/atom', |
|
622 | rmap.connect('atom_feed_home', '/{repo_name}/feed/atom', | |
629 | controller='feed', action='atom', |
|
623 | controller='feed', action='atom', | |
630 | conditions={'function': check_repo}, |
|
624 | conditions={'function': check_repo}, | |
631 | requirements=URL_NAME_REQUIREMENTS) |
|
625 | requirements=URL_NAME_REQUIREMENTS) | |
632 |
|
626 | |||
633 | #========================================================================== |
|
627 | #========================================================================== | |
634 | # REPOSITORY ROUTES |
|
628 | # REPOSITORY ROUTES | |
635 | #========================================================================== |
|
629 | #========================================================================== | |
636 |
|
630 | |||
637 | rmap.connect('repo_creating_home', '/{repo_name}/repo_creating', |
|
631 | rmap.connect('repo_creating_home', '/{repo_name}/repo_creating', | |
638 | controller='admin/repos', action='repo_creating', |
|
632 | controller='admin/repos', action='repo_creating', | |
639 | requirements=URL_NAME_REQUIREMENTS) |
|
633 | requirements=URL_NAME_REQUIREMENTS) | |
640 | rmap.connect('repo_check_home', '/{repo_name}/crepo_check', |
|
634 | rmap.connect('repo_check_home', '/{repo_name}/crepo_check', | |
641 | controller='admin/repos', action='repo_check', |
|
635 | controller='admin/repos', action='repo_check', | |
642 | requirements=URL_NAME_REQUIREMENTS) |
|
636 | requirements=URL_NAME_REQUIREMENTS) | |
643 |
|
637 | |||
644 | rmap.connect('repo_stats', '/{repo_name}/repo_stats/{commit_id}', |
|
638 | rmap.connect('repo_stats', '/{repo_name}/repo_stats/{commit_id}', | |
645 | controller='summary', action='repo_stats', |
|
639 | controller='summary', action='repo_stats', | |
646 | conditions={'function': check_repo}, |
|
640 | conditions={'function': check_repo}, | |
647 | requirements=URL_NAME_REQUIREMENTS) |
|
641 | requirements=URL_NAME_REQUIREMENTS) | |
648 |
|
642 | |||
649 | rmap.connect('repo_refs_data', '/{repo_name}/refs-data', |
|
643 | rmap.connect('repo_refs_data', '/{repo_name}/refs-data', | |
650 | controller='summary', action='repo_refs_data', |
|
644 | controller='summary', action='repo_refs_data', | |
651 | requirements=URL_NAME_REQUIREMENTS) |
|
645 | requirements=URL_NAME_REQUIREMENTS) | |
652 | rmap.connect('repo_refs_changelog_data', '/{repo_name}/refs-data-changelog', |
|
646 | rmap.connect('repo_refs_changelog_data', '/{repo_name}/refs-data-changelog', | |
653 | controller='summary', action='repo_refs_changelog_data', |
|
647 | controller='summary', action='repo_refs_changelog_data', | |
654 | requirements=URL_NAME_REQUIREMENTS) |
|
648 | requirements=URL_NAME_REQUIREMENTS) | |
655 |
|
649 | |||
656 | rmap.connect('changeset_home', '/{repo_name}/changeset/{revision}', |
|
650 | rmap.connect('changeset_home', '/{repo_name}/changeset/{revision}', | |
657 | controller='changeset', revision='tip', |
|
651 | controller='changeset', revision='tip', | |
658 | conditions={'function': check_repo}, |
|
652 | conditions={'function': check_repo}, | |
659 | requirements=URL_NAME_REQUIREMENTS) |
|
653 | requirements=URL_NAME_REQUIREMENTS) | |
660 | rmap.connect('changeset_children', '/{repo_name}/changeset_children/{revision}', |
|
654 | rmap.connect('changeset_children', '/{repo_name}/changeset_children/{revision}', | |
661 | controller='changeset', revision='tip', action='changeset_children', |
|
655 | controller='changeset', revision='tip', action='changeset_children', | |
662 | conditions={'function': check_repo}, |
|
656 | conditions={'function': check_repo}, | |
663 | requirements=URL_NAME_REQUIREMENTS) |
|
657 | requirements=URL_NAME_REQUIREMENTS) | |
664 | rmap.connect('changeset_parents', '/{repo_name}/changeset_parents/{revision}', |
|
658 | rmap.connect('changeset_parents', '/{repo_name}/changeset_parents/{revision}', | |
665 | controller='changeset', revision='tip', action='changeset_parents', |
|
659 | controller='changeset', revision='tip', action='changeset_parents', | |
666 | conditions={'function': check_repo}, |
|
660 | conditions={'function': check_repo}, | |
667 | requirements=URL_NAME_REQUIREMENTS) |
|
661 | requirements=URL_NAME_REQUIREMENTS) | |
668 |
|
662 | |||
669 | # repo edit options |
|
663 | # repo edit options | |
670 | rmap.connect('edit_repo', '/{repo_name}/settings', |
|
664 | rmap.connect('edit_repo', '/{repo_name}/settings', | |
671 | controller='admin/repos', action='edit', |
|
665 | controller='admin/repos', action='edit', | |
672 | conditions={'method': ['GET'], 'function': check_repo}, |
|
666 | conditions={'method': ['GET'], 'function': check_repo}, | |
673 | requirements=URL_NAME_REQUIREMENTS) |
|
667 | requirements=URL_NAME_REQUIREMENTS) | |
674 |
|
668 | |||
675 | rmap.connect('edit_repo_perms', '/{repo_name}/settings/permissions', |
|
669 | rmap.connect('edit_repo_perms', '/{repo_name}/settings/permissions', | |
676 | controller='admin/repos', action='edit_permissions', |
|
670 | controller='admin/repos', action='edit_permissions', | |
677 | conditions={'method': ['GET'], 'function': check_repo}, |
|
671 | conditions={'method': ['GET'], 'function': check_repo}, | |
678 | requirements=URL_NAME_REQUIREMENTS) |
|
672 | requirements=URL_NAME_REQUIREMENTS) | |
679 | rmap.connect('edit_repo_perms_update', '/{repo_name}/settings/permissions', |
|
673 | rmap.connect('edit_repo_perms_update', '/{repo_name}/settings/permissions', | |
680 | controller='admin/repos', action='edit_permissions_update', |
|
674 | controller='admin/repos', action='edit_permissions_update', | |
681 | conditions={'method': ['PUT'], 'function': check_repo}, |
|
675 | conditions={'method': ['PUT'], 'function': check_repo}, | |
682 | requirements=URL_NAME_REQUIREMENTS) |
|
676 | requirements=URL_NAME_REQUIREMENTS) | |
683 |
|
677 | |||
684 | rmap.connect('edit_repo_fields', '/{repo_name}/settings/fields', |
|
678 | rmap.connect('edit_repo_fields', '/{repo_name}/settings/fields', | |
685 | controller='admin/repos', action='edit_fields', |
|
679 | controller='admin/repos', action='edit_fields', | |
686 | conditions={'method': ['GET'], 'function': check_repo}, |
|
680 | conditions={'method': ['GET'], 'function': check_repo}, | |
687 | requirements=URL_NAME_REQUIREMENTS) |
|
681 | requirements=URL_NAME_REQUIREMENTS) | |
688 | rmap.connect('create_repo_fields', '/{repo_name}/settings/fields/new', |
|
682 | rmap.connect('create_repo_fields', '/{repo_name}/settings/fields/new', | |
689 | controller='admin/repos', action='create_repo_field', |
|
683 | controller='admin/repos', action='create_repo_field', | |
690 | conditions={'method': ['PUT'], 'function': check_repo}, |
|
684 | conditions={'method': ['PUT'], 'function': check_repo}, | |
691 | requirements=URL_NAME_REQUIREMENTS) |
|
685 | requirements=URL_NAME_REQUIREMENTS) | |
692 | rmap.connect('delete_repo_fields', '/{repo_name}/settings/fields/{field_id}', |
|
686 | rmap.connect('delete_repo_fields', '/{repo_name}/settings/fields/{field_id}', | |
693 | controller='admin/repos', action='delete_repo_field', |
|
687 | controller='admin/repos', action='delete_repo_field', | |
694 | conditions={'method': ['DELETE'], 'function': check_repo}, |
|
688 | conditions={'method': ['DELETE'], 'function': check_repo}, | |
695 | requirements=URL_NAME_REQUIREMENTS) |
|
689 | requirements=URL_NAME_REQUIREMENTS) | |
696 |
|
690 | |||
697 | rmap.connect('edit_repo_advanced', '/{repo_name}/settings/advanced', |
|
691 | rmap.connect('edit_repo_advanced', '/{repo_name}/settings/advanced', | |
698 | controller='admin/repos', action='edit_advanced', |
|
692 | controller='admin/repos', action='edit_advanced', | |
699 | conditions={'method': ['GET'], 'function': check_repo}, |
|
693 | conditions={'method': ['GET'], 'function': check_repo}, | |
700 | requirements=URL_NAME_REQUIREMENTS) |
|
694 | requirements=URL_NAME_REQUIREMENTS) | |
701 |
|
695 | |||
702 | rmap.connect('edit_repo_advanced_locking', '/{repo_name}/settings/advanced/locking', |
|
696 | rmap.connect('edit_repo_advanced_locking', '/{repo_name}/settings/advanced/locking', | |
703 | controller='admin/repos', action='edit_advanced_locking', |
|
697 | controller='admin/repos', action='edit_advanced_locking', | |
704 | conditions={'method': ['PUT'], 'function': check_repo}, |
|
698 | conditions={'method': ['PUT'], 'function': check_repo}, | |
705 | requirements=URL_NAME_REQUIREMENTS) |
|
699 | requirements=URL_NAME_REQUIREMENTS) | |
706 | rmap.connect('toggle_locking', '/{repo_name}/settings/advanced/locking_toggle', |
|
700 | rmap.connect('toggle_locking', '/{repo_name}/settings/advanced/locking_toggle', | |
707 | controller='admin/repos', action='toggle_locking', |
|
701 | controller='admin/repos', action='toggle_locking', | |
708 | conditions={'method': ['GET'], 'function': check_repo}, |
|
702 | conditions={'method': ['GET'], 'function': check_repo}, | |
709 | requirements=URL_NAME_REQUIREMENTS) |
|
703 | requirements=URL_NAME_REQUIREMENTS) | |
710 |
|
704 | |||
711 | rmap.connect('edit_repo_advanced_journal', '/{repo_name}/settings/advanced/journal', |
|
705 | rmap.connect('edit_repo_advanced_journal', '/{repo_name}/settings/advanced/journal', | |
712 | controller='admin/repos', action='edit_advanced_journal', |
|
706 | controller='admin/repos', action='edit_advanced_journal', | |
713 | conditions={'method': ['PUT'], 'function': check_repo}, |
|
707 | conditions={'method': ['PUT'], 'function': check_repo}, | |
714 | requirements=URL_NAME_REQUIREMENTS) |
|
708 | requirements=URL_NAME_REQUIREMENTS) | |
715 |
|
709 | |||
716 | rmap.connect('edit_repo_advanced_fork', '/{repo_name}/settings/advanced/fork', |
|
710 | rmap.connect('edit_repo_advanced_fork', '/{repo_name}/settings/advanced/fork', | |
717 | controller='admin/repos', action='edit_advanced_fork', |
|
711 | controller='admin/repos', action='edit_advanced_fork', | |
718 | conditions={'method': ['PUT'], 'function': check_repo}, |
|
712 | conditions={'method': ['PUT'], 'function': check_repo}, | |
719 | requirements=URL_NAME_REQUIREMENTS) |
|
713 | requirements=URL_NAME_REQUIREMENTS) | |
720 |
|
714 | |||
721 | rmap.connect('edit_repo_caches', '/{repo_name}/settings/caches', |
|
715 | rmap.connect('edit_repo_caches', '/{repo_name}/settings/caches', | |
722 | controller='admin/repos', action='edit_caches_form', |
|
716 | controller='admin/repos', action='edit_caches_form', | |
723 | conditions={'method': ['GET'], 'function': check_repo}, |
|
717 | conditions={'method': ['GET'], 'function': check_repo}, | |
724 | requirements=URL_NAME_REQUIREMENTS) |
|
718 | requirements=URL_NAME_REQUIREMENTS) | |
725 | rmap.connect('edit_repo_caches', '/{repo_name}/settings/caches', |
|
719 | rmap.connect('edit_repo_caches', '/{repo_name}/settings/caches', | |
726 | controller='admin/repos', action='edit_caches', |
|
720 | controller='admin/repos', action='edit_caches', | |
727 | conditions={'method': ['PUT'], 'function': check_repo}, |
|
721 | conditions={'method': ['PUT'], 'function': check_repo}, | |
728 | requirements=URL_NAME_REQUIREMENTS) |
|
722 | requirements=URL_NAME_REQUIREMENTS) | |
729 |
|
723 | |||
730 | rmap.connect('edit_repo_remote', '/{repo_name}/settings/remote', |
|
724 | rmap.connect('edit_repo_remote', '/{repo_name}/settings/remote', | |
731 | controller='admin/repos', action='edit_remote_form', |
|
725 | controller='admin/repos', action='edit_remote_form', | |
732 | conditions={'method': ['GET'], 'function': check_repo}, |
|
726 | conditions={'method': ['GET'], 'function': check_repo}, | |
733 | requirements=URL_NAME_REQUIREMENTS) |
|
727 | requirements=URL_NAME_REQUIREMENTS) | |
734 | rmap.connect('edit_repo_remote', '/{repo_name}/settings/remote', |
|
728 | rmap.connect('edit_repo_remote', '/{repo_name}/settings/remote', | |
735 | controller='admin/repos', action='edit_remote', |
|
729 | controller='admin/repos', action='edit_remote', | |
736 | conditions={'method': ['PUT'], 'function': check_repo}, |
|
730 | conditions={'method': ['PUT'], 'function': check_repo}, | |
737 | requirements=URL_NAME_REQUIREMENTS) |
|
731 | requirements=URL_NAME_REQUIREMENTS) | |
738 |
|
732 | |||
739 | rmap.connect('edit_repo_statistics', '/{repo_name}/settings/statistics', |
|
733 | rmap.connect('edit_repo_statistics', '/{repo_name}/settings/statistics', | |
740 | controller='admin/repos', action='edit_statistics_form', |
|
734 | controller='admin/repos', action='edit_statistics_form', | |
741 | conditions={'method': ['GET'], 'function': check_repo}, |
|
735 | conditions={'method': ['GET'], 'function': check_repo}, | |
742 | requirements=URL_NAME_REQUIREMENTS) |
|
736 | requirements=URL_NAME_REQUIREMENTS) | |
743 | rmap.connect('edit_repo_statistics', '/{repo_name}/settings/statistics', |
|
737 | rmap.connect('edit_repo_statistics', '/{repo_name}/settings/statistics', | |
744 | controller='admin/repos', action='edit_statistics', |
|
738 | controller='admin/repos', action='edit_statistics', | |
745 | conditions={'method': ['PUT'], 'function': check_repo}, |
|
739 | conditions={'method': ['PUT'], 'function': check_repo}, | |
746 | requirements=URL_NAME_REQUIREMENTS) |
|
740 | requirements=URL_NAME_REQUIREMENTS) | |
747 | rmap.connect('repo_settings_issuetracker', |
|
741 | rmap.connect('repo_settings_issuetracker', | |
748 | '/{repo_name}/settings/issue-tracker', |
|
742 | '/{repo_name}/settings/issue-tracker', | |
749 | controller='admin/repos', action='repo_issuetracker', |
|
743 | controller='admin/repos', action='repo_issuetracker', | |
750 | conditions={'method': ['GET'], 'function': check_repo}, |
|
744 | conditions={'method': ['GET'], 'function': check_repo}, | |
751 | requirements=URL_NAME_REQUIREMENTS) |
|
745 | requirements=URL_NAME_REQUIREMENTS) | |
752 | rmap.connect('repo_issuetracker_test', |
|
746 | rmap.connect('repo_issuetracker_test', | |
753 | '/{repo_name}/settings/issue-tracker/test', |
|
747 | '/{repo_name}/settings/issue-tracker/test', | |
754 | controller='admin/repos', action='repo_issuetracker_test', |
|
748 | controller='admin/repos', action='repo_issuetracker_test', | |
755 | conditions={'method': ['POST'], 'function': check_repo}, |
|
749 | conditions={'method': ['POST'], 'function': check_repo}, | |
756 | requirements=URL_NAME_REQUIREMENTS) |
|
750 | requirements=URL_NAME_REQUIREMENTS) | |
757 | rmap.connect('repo_issuetracker_delete', |
|
751 | rmap.connect('repo_issuetracker_delete', | |
758 | '/{repo_name}/settings/issue-tracker/delete', |
|
752 | '/{repo_name}/settings/issue-tracker/delete', | |
759 | controller='admin/repos', action='repo_issuetracker_delete', |
|
753 | controller='admin/repos', action='repo_issuetracker_delete', | |
760 | conditions={'method': ['DELETE'], 'function': check_repo}, |
|
754 | conditions={'method': ['DELETE'], 'function': check_repo}, | |
761 | requirements=URL_NAME_REQUIREMENTS) |
|
755 | requirements=URL_NAME_REQUIREMENTS) | |
762 | rmap.connect('repo_issuetracker_save', |
|
756 | rmap.connect('repo_issuetracker_save', | |
763 | '/{repo_name}/settings/issue-tracker/save', |
|
757 | '/{repo_name}/settings/issue-tracker/save', | |
764 | controller='admin/repos', action='repo_issuetracker_save', |
|
758 | controller='admin/repos', action='repo_issuetracker_save', | |
765 | conditions={'method': ['POST'], 'function': check_repo}, |
|
759 | conditions={'method': ['POST'], 'function': check_repo}, | |
766 | requirements=URL_NAME_REQUIREMENTS) |
|
760 | requirements=URL_NAME_REQUIREMENTS) | |
767 | rmap.connect('repo_vcs_settings', '/{repo_name}/settings/vcs', |
|
761 | rmap.connect('repo_vcs_settings', '/{repo_name}/settings/vcs', | |
768 | controller='admin/repos', action='repo_settings_vcs_update', |
|
762 | controller='admin/repos', action='repo_settings_vcs_update', | |
769 | conditions={'method': ['POST'], 'function': check_repo}, |
|
763 | conditions={'method': ['POST'], 'function': check_repo}, | |
770 | requirements=URL_NAME_REQUIREMENTS) |
|
764 | requirements=URL_NAME_REQUIREMENTS) | |
771 | rmap.connect('repo_vcs_settings', '/{repo_name}/settings/vcs', |
|
765 | rmap.connect('repo_vcs_settings', '/{repo_name}/settings/vcs', | |
772 | controller='admin/repos', action='repo_settings_vcs', |
|
766 | controller='admin/repos', action='repo_settings_vcs', | |
773 | conditions={'method': ['GET'], 'function': check_repo}, |
|
767 | conditions={'method': ['GET'], 'function': check_repo}, | |
774 | requirements=URL_NAME_REQUIREMENTS) |
|
768 | requirements=URL_NAME_REQUIREMENTS) | |
775 | rmap.connect('repo_vcs_settings', '/{repo_name}/settings/vcs', |
|
769 | rmap.connect('repo_vcs_settings', '/{repo_name}/settings/vcs', | |
776 | controller='admin/repos', action='repo_delete_svn_pattern', |
|
770 | controller='admin/repos', action='repo_delete_svn_pattern', | |
777 | conditions={'method': ['DELETE'], 'function': check_repo}, |
|
771 | conditions={'method': ['DELETE'], 'function': check_repo}, | |
778 | requirements=URL_NAME_REQUIREMENTS) |
|
772 | requirements=URL_NAME_REQUIREMENTS) | |
779 |
|
773 | |||
780 | # still working url for backward compat. |
|
774 | # still working url for backward compat. | |
781 | rmap.connect('raw_changeset_home_depraced', |
|
775 | rmap.connect('raw_changeset_home_depraced', | |
782 | '/{repo_name}/raw-changeset/{revision}', |
|
776 | '/{repo_name}/raw-changeset/{revision}', | |
783 | controller='changeset', action='changeset_raw', |
|
777 | controller='changeset', action='changeset_raw', | |
784 | revision='tip', conditions={'function': check_repo}, |
|
778 | revision='tip', conditions={'function': check_repo}, | |
785 | requirements=URL_NAME_REQUIREMENTS) |
|
779 | requirements=URL_NAME_REQUIREMENTS) | |
786 |
|
780 | |||
787 | # new URLs |
|
781 | # new URLs | |
788 | rmap.connect('changeset_raw_home', |
|
782 | rmap.connect('changeset_raw_home', | |
789 | '/{repo_name}/changeset-diff/{revision}', |
|
783 | '/{repo_name}/changeset-diff/{revision}', | |
790 | controller='changeset', action='changeset_raw', |
|
784 | controller='changeset', action='changeset_raw', | |
791 | revision='tip', conditions={'function': check_repo}, |
|
785 | revision='tip', conditions={'function': check_repo}, | |
792 | requirements=URL_NAME_REQUIREMENTS) |
|
786 | requirements=URL_NAME_REQUIREMENTS) | |
793 |
|
787 | |||
794 | rmap.connect('changeset_patch_home', |
|
788 | rmap.connect('changeset_patch_home', | |
795 | '/{repo_name}/changeset-patch/{revision}', |
|
789 | '/{repo_name}/changeset-patch/{revision}', | |
796 | controller='changeset', action='changeset_patch', |
|
790 | controller='changeset', action='changeset_patch', | |
797 | revision='tip', conditions={'function': check_repo}, |
|
791 | revision='tip', conditions={'function': check_repo}, | |
798 | requirements=URL_NAME_REQUIREMENTS) |
|
792 | requirements=URL_NAME_REQUIREMENTS) | |
799 |
|
793 | |||
800 | rmap.connect('changeset_download_home', |
|
794 | rmap.connect('changeset_download_home', | |
801 | '/{repo_name}/changeset-download/{revision}', |
|
795 | '/{repo_name}/changeset-download/{revision}', | |
802 | controller='changeset', action='changeset_download', |
|
796 | controller='changeset', action='changeset_download', | |
803 | revision='tip', conditions={'function': check_repo}, |
|
797 | revision='tip', conditions={'function': check_repo}, | |
804 | requirements=URL_NAME_REQUIREMENTS) |
|
798 | requirements=URL_NAME_REQUIREMENTS) | |
805 |
|
799 | |||
806 | rmap.connect('changeset_comment', |
|
800 | rmap.connect('changeset_comment', | |
807 | '/{repo_name}/changeset/{revision}/comment', |
|
801 | '/{repo_name}/changeset/{revision}/comment', | |
808 | controller='changeset', revision='tip', action='comment', |
|
802 | controller='changeset', revision='tip', action='comment', | |
809 | conditions={'function': check_repo}, |
|
803 | conditions={'function': check_repo}, | |
810 | requirements=URL_NAME_REQUIREMENTS) |
|
804 | requirements=URL_NAME_REQUIREMENTS) | |
811 |
|
805 | |||
812 | rmap.connect('changeset_comment_preview', |
|
806 | rmap.connect('changeset_comment_preview', | |
813 | '/{repo_name}/changeset/comment/preview', |
|
807 | '/{repo_name}/changeset/comment/preview', | |
814 | controller='changeset', action='preview_comment', |
|
808 | controller='changeset', action='preview_comment', | |
815 | conditions={'function': check_repo, 'method': ['POST']}, |
|
809 | conditions={'function': check_repo, 'method': ['POST']}, | |
816 | requirements=URL_NAME_REQUIREMENTS) |
|
810 | requirements=URL_NAME_REQUIREMENTS) | |
817 |
|
811 | |||
818 | rmap.connect('changeset_comment_delete', |
|
812 | rmap.connect('changeset_comment_delete', | |
819 | '/{repo_name}/changeset/comment/{comment_id}/delete', |
|
813 | '/{repo_name}/changeset/comment/{comment_id}/delete', | |
820 | controller='changeset', action='delete_comment', |
|
814 | controller='changeset', action='delete_comment', | |
821 | conditions={'function': check_repo, 'method': ['DELETE']}, |
|
815 | conditions={'function': check_repo, 'method': ['DELETE']}, | |
822 | requirements=URL_NAME_REQUIREMENTS) |
|
816 | requirements=URL_NAME_REQUIREMENTS) | |
823 |
|
817 | |||
824 | rmap.connect('changeset_info', '/changeset_info/{repo_name}/{revision}', |
|
818 | rmap.connect('changeset_info', '/changeset_info/{repo_name}/{revision}', | |
825 | controller='changeset', action='changeset_info', |
|
819 | controller='changeset', action='changeset_info', | |
826 | requirements=URL_NAME_REQUIREMENTS) |
|
820 | requirements=URL_NAME_REQUIREMENTS) | |
827 |
|
821 | |||
828 | rmap.connect('compare_home', |
|
822 | rmap.connect('compare_home', | |
829 | '/{repo_name}/compare', |
|
823 | '/{repo_name}/compare', | |
830 | controller='compare', action='index', |
|
824 | controller='compare', action='index', | |
831 | conditions={'function': check_repo}, |
|
825 | conditions={'function': check_repo}, | |
832 | requirements=URL_NAME_REQUIREMENTS) |
|
826 | requirements=URL_NAME_REQUIREMENTS) | |
833 |
|
827 | |||
834 | rmap.connect('compare_url', |
|
828 | rmap.connect('compare_url', | |
835 | '/{repo_name}/compare/{source_ref_type}@{source_ref:.*?}...{target_ref_type}@{target_ref:.*?}', |
|
829 | '/{repo_name}/compare/{source_ref_type}@{source_ref:.*?}...{target_ref_type}@{target_ref:.*?}', | |
836 | controller='compare', action='compare', |
|
830 | controller='compare', action='compare', | |
837 | conditions={'function': check_repo}, |
|
831 | conditions={'function': check_repo}, | |
838 | requirements=URL_NAME_REQUIREMENTS) |
|
832 | requirements=URL_NAME_REQUIREMENTS) | |
839 |
|
833 | |||
840 | rmap.connect('pullrequest_home', |
|
834 | rmap.connect('pullrequest_home', | |
841 | '/{repo_name}/pull-request/new', controller='pullrequests', |
|
835 | '/{repo_name}/pull-request/new', controller='pullrequests', | |
842 | action='index', conditions={'function': check_repo, |
|
836 | action='index', conditions={'function': check_repo, | |
843 | 'method': ['GET']}, |
|
837 | 'method': ['GET']}, | |
844 | requirements=URL_NAME_REQUIREMENTS) |
|
838 | requirements=URL_NAME_REQUIREMENTS) | |
845 |
|
839 | |||
846 | rmap.connect('pullrequest', |
|
840 | rmap.connect('pullrequest', | |
847 | '/{repo_name}/pull-request/new', controller='pullrequests', |
|
841 | '/{repo_name}/pull-request/new', controller='pullrequests', | |
848 | action='create', conditions={'function': check_repo, |
|
842 | action='create', conditions={'function': check_repo, | |
849 | 'method': ['POST']}, |
|
843 | 'method': ['POST']}, | |
850 | requirements=URL_NAME_REQUIREMENTS) |
|
844 | requirements=URL_NAME_REQUIREMENTS) | |
851 |
|
845 | |||
852 | rmap.connect('pullrequest_repo_refs', |
|
846 | rmap.connect('pullrequest_repo_refs', | |
853 | '/{repo_name}/pull-request/refs/{target_repo_name:.*?[^/]}', |
|
847 | '/{repo_name}/pull-request/refs/{target_repo_name:.*?[^/]}', | |
854 | controller='pullrequests', |
|
848 | controller='pullrequests', | |
855 | action='get_repo_refs', |
|
849 | action='get_repo_refs', | |
856 | conditions={'function': check_repo, 'method': ['GET']}, |
|
850 | conditions={'function': check_repo, 'method': ['GET']}, | |
857 | requirements=URL_NAME_REQUIREMENTS) |
|
851 | requirements=URL_NAME_REQUIREMENTS) | |
858 |
|
852 | |||
859 | rmap.connect('pullrequest_repo_destinations', |
|
853 | rmap.connect('pullrequest_repo_destinations', | |
860 | '/{repo_name}/pull-request/repo-destinations', |
|
854 | '/{repo_name}/pull-request/repo-destinations', | |
861 | controller='pullrequests', |
|
855 | controller='pullrequests', | |
862 | action='get_repo_destinations', |
|
856 | action='get_repo_destinations', | |
863 | conditions={'function': check_repo, 'method': ['GET']}, |
|
857 | conditions={'function': check_repo, 'method': ['GET']}, | |
864 | requirements=URL_NAME_REQUIREMENTS) |
|
858 | requirements=URL_NAME_REQUIREMENTS) | |
865 |
|
859 | |||
866 | rmap.connect('pullrequest_show', |
|
860 | rmap.connect('pullrequest_show', | |
867 | '/{repo_name}/pull-request/{pull_request_id}', |
|
861 | '/{repo_name}/pull-request/{pull_request_id}', | |
868 | controller='pullrequests', |
|
862 | controller='pullrequests', | |
869 | action='show', conditions={'function': check_repo, |
|
863 | action='show', conditions={'function': check_repo, | |
870 | 'method': ['GET']}, |
|
864 | 'method': ['GET']}, | |
871 | requirements=URL_NAME_REQUIREMENTS) |
|
865 | requirements=URL_NAME_REQUIREMENTS) | |
872 |
|
866 | |||
873 | rmap.connect('pullrequest_update', |
|
867 | rmap.connect('pullrequest_update', | |
874 | '/{repo_name}/pull-request/{pull_request_id}', |
|
868 | '/{repo_name}/pull-request/{pull_request_id}', | |
875 | controller='pullrequests', |
|
869 | controller='pullrequests', | |
876 | action='update', conditions={'function': check_repo, |
|
870 | action='update', conditions={'function': check_repo, | |
877 | 'method': ['PUT']}, |
|
871 | 'method': ['PUT']}, | |
878 | requirements=URL_NAME_REQUIREMENTS) |
|
872 | requirements=URL_NAME_REQUIREMENTS) | |
879 |
|
873 | |||
880 | rmap.connect('pullrequest_merge', |
|
874 | rmap.connect('pullrequest_merge', | |
881 | '/{repo_name}/pull-request/{pull_request_id}', |
|
875 | '/{repo_name}/pull-request/{pull_request_id}', | |
882 | controller='pullrequests', |
|
876 | controller='pullrequests', | |
883 | action='merge', conditions={'function': check_repo, |
|
877 | action='merge', conditions={'function': check_repo, | |
884 | 'method': ['POST']}, |
|
878 | 'method': ['POST']}, | |
885 | requirements=URL_NAME_REQUIREMENTS) |
|
879 | requirements=URL_NAME_REQUIREMENTS) | |
886 |
|
880 | |||
887 | rmap.connect('pullrequest_delete', |
|
881 | rmap.connect('pullrequest_delete', | |
888 | '/{repo_name}/pull-request/{pull_request_id}', |
|
882 | '/{repo_name}/pull-request/{pull_request_id}', | |
889 | controller='pullrequests', |
|
883 | controller='pullrequests', | |
890 | action='delete', conditions={'function': check_repo, |
|
884 | action='delete', conditions={'function': check_repo, | |
891 | 'method': ['DELETE']}, |
|
885 | 'method': ['DELETE']}, | |
892 | requirements=URL_NAME_REQUIREMENTS) |
|
886 | requirements=URL_NAME_REQUIREMENTS) | |
893 |
|
887 | |||
894 | rmap.connect('pullrequest_show_all', |
|
888 | rmap.connect('pullrequest_show_all', | |
895 | '/{repo_name}/pull-request', |
|
889 | '/{repo_name}/pull-request', | |
896 | controller='pullrequests', |
|
890 | controller='pullrequests', | |
897 | action='show_all', conditions={'function': check_repo, |
|
891 | action='show_all', conditions={'function': check_repo, | |
898 | 'method': ['GET']}, |
|
892 | 'method': ['GET']}, | |
899 | requirements=URL_NAME_REQUIREMENTS) |
|
893 | requirements=URL_NAME_REQUIREMENTS) | |
900 |
|
894 | |||
901 | rmap.connect('pullrequest_comment', |
|
895 | rmap.connect('pullrequest_comment', | |
902 | '/{repo_name}/pull-request-comment/{pull_request_id}', |
|
896 | '/{repo_name}/pull-request-comment/{pull_request_id}', | |
903 | controller='pullrequests', |
|
897 | controller='pullrequests', | |
904 | action='comment', conditions={'function': check_repo, |
|
898 | action='comment', conditions={'function': check_repo, | |
905 | 'method': ['POST']}, |
|
899 | 'method': ['POST']}, | |
906 | requirements=URL_NAME_REQUIREMENTS) |
|
900 | requirements=URL_NAME_REQUIREMENTS) | |
907 |
|
901 | |||
908 | rmap.connect('pullrequest_comment_delete', |
|
902 | rmap.connect('pullrequest_comment_delete', | |
909 | '/{repo_name}/pull-request-comment/{comment_id}/delete', |
|
903 | '/{repo_name}/pull-request-comment/{comment_id}/delete', | |
910 | controller='pullrequests', action='delete_comment', |
|
904 | controller='pullrequests', action='delete_comment', | |
911 | conditions={'function': check_repo, 'method': ['DELETE']}, |
|
905 | conditions={'function': check_repo, 'method': ['DELETE']}, | |
912 | requirements=URL_NAME_REQUIREMENTS) |
|
906 | requirements=URL_NAME_REQUIREMENTS) | |
913 |
|
907 | |||
914 | rmap.connect('summary_home_explicit', '/{repo_name}/summary', |
|
908 | rmap.connect('summary_home_explicit', '/{repo_name}/summary', | |
915 | controller='summary', conditions={'function': check_repo}, |
|
909 | controller='summary', conditions={'function': check_repo}, | |
916 | requirements=URL_NAME_REQUIREMENTS) |
|
910 | requirements=URL_NAME_REQUIREMENTS) | |
917 |
|
911 | |||
918 | rmap.connect('branches_home', '/{repo_name}/branches', |
|
912 | rmap.connect('branches_home', '/{repo_name}/branches', | |
919 | controller='branches', conditions={'function': check_repo}, |
|
913 | controller='branches', conditions={'function': check_repo}, | |
920 | requirements=URL_NAME_REQUIREMENTS) |
|
914 | requirements=URL_NAME_REQUIREMENTS) | |
921 |
|
915 | |||
922 | rmap.connect('tags_home', '/{repo_name}/tags', |
|
916 | rmap.connect('tags_home', '/{repo_name}/tags', | |
923 | controller='tags', conditions={'function': check_repo}, |
|
917 | controller='tags', conditions={'function': check_repo}, | |
924 | requirements=URL_NAME_REQUIREMENTS) |
|
918 | requirements=URL_NAME_REQUIREMENTS) | |
925 |
|
919 | |||
926 | rmap.connect('bookmarks_home', '/{repo_name}/bookmarks', |
|
920 | rmap.connect('bookmarks_home', '/{repo_name}/bookmarks', | |
927 | controller='bookmarks', conditions={'function': check_repo}, |
|
921 | controller='bookmarks', conditions={'function': check_repo}, | |
928 | requirements=URL_NAME_REQUIREMENTS) |
|
922 | requirements=URL_NAME_REQUIREMENTS) | |
929 |
|
923 | |||
930 | rmap.connect('changelog_home', '/{repo_name}/changelog', |
|
924 | rmap.connect('changelog_home', '/{repo_name}/changelog', | |
931 | controller='changelog', conditions={'function': check_repo}, |
|
925 | controller='changelog', conditions={'function': check_repo}, | |
932 | requirements=URL_NAME_REQUIREMENTS) |
|
926 | requirements=URL_NAME_REQUIREMENTS) | |
933 |
|
927 | |||
934 | rmap.connect('changelog_summary_home', '/{repo_name}/changelog_summary', |
|
928 | rmap.connect('changelog_summary_home', '/{repo_name}/changelog_summary', | |
935 | controller='changelog', action='changelog_summary', |
|
929 | controller='changelog', action='changelog_summary', | |
936 | conditions={'function': check_repo}, |
|
930 | conditions={'function': check_repo}, | |
937 | requirements=URL_NAME_REQUIREMENTS) |
|
931 | requirements=URL_NAME_REQUIREMENTS) | |
938 |
|
932 | |||
939 | rmap.connect('changelog_file_home', '/{repo_name}/changelog/{revision}/{f_path}', |
|
933 | rmap.connect('changelog_file_home', '/{repo_name}/changelog/{revision}/{f_path}', | |
940 | controller='changelog', f_path=None, |
|
934 | controller='changelog', f_path=None, | |
941 | conditions={'function': check_repo}, |
|
935 | conditions={'function': check_repo}, | |
942 | requirements=URL_NAME_REQUIREMENTS) |
|
936 | requirements=URL_NAME_REQUIREMENTS) | |
943 |
|
937 | |||
944 | rmap.connect('changelog_details', '/{repo_name}/changelog_details/{cs}', |
|
938 | rmap.connect('changelog_details', '/{repo_name}/changelog_details/{cs}', | |
945 | controller='changelog', action='changelog_details', |
|
939 | controller='changelog', action='changelog_details', | |
946 | conditions={'function': check_repo}, |
|
940 | conditions={'function': check_repo}, | |
947 | requirements=URL_NAME_REQUIREMENTS) |
|
941 | requirements=URL_NAME_REQUIREMENTS) | |
948 |
|
942 | |||
949 | rmap.connect('files_home', |
|
943 | rmap.connect('files_home', | |
950 | '/{repo_name}/files/{revision}/{f_path}', |
|
944 | '/{repo_name}/files/{revision}/{f_path}', | |
951 | controller='files', revision='tip', f_path='', |
|
945 | controller='files', revision='tip', f_path='', | |
952 | conditions={'function': check_repo}, |
|
946 | conditions={'function': check_repo}, | |
953 | requirements=URL_NAME_REQUIREMENTS) |
|
947 | requirements=URL_NAME_REQUIREMENTS) | |
954 |
|
948 | |||
955 | rmap.connect('files_home_simple_catchrev', |
|
949 | rmap.connect('files_home_simple_catchrev', | |
956 | '/{repo_name}/files/{revision}', |
|
950 | '/{repo_name}/files/{revision}', | |
957 | controller='files', revision='tip', f_path='', |
|
951 | controller='files', revision='tip', f_path='', | |
958 | conditions={'function': check_repo}, |
|
952 | conditions={'function': check_repo}, | |
959 | requirements=URL_NAME_REQUIREMENTS) |
|
953 | requirements=URL_NAME_REQUIREMENTS) | |
960 |
|
954 | |||
961 | rmap.connect('files_home_simple_catchall', |
|
955 | rmap.connect('files_home_simple_catchall', | |
962 | '/{repo_name}/files', |
|
956 | '/{repo_name}/files', | |
963 | controller='files', revision='tip', f_path='', |
|
957 | controller='files', revision='tip', f_path='', | |
964 | conditions={'function': check_repo}, |
|
958 | conditions={'function': check_repo}, | |
965 | requirements=URL_NAME_REQUIREMENTS) |
|
959 | requirements=URL_NAME_REQUIREMENTS) | |
966 |
|
960 | |||
967 | rmap.connect('files_history_home', |
|
961 | rmap.connect('files_history_home', | |
968 | '/{repo_name}/history/{revision}/{f_path}', |
|
962 | '/{repo_name}/history/{revision}/{f_path}', | |
969 | controller='files', action='history', revision='tip', f_path='', |
|
963 | controller='files', action='history', revision='tip', f_path='', | |
970 | conditions={'function': check_repo}, |
|
964 | conditions={'function': check_repo}, | |
971 | requirements=URL_NAME_REQUIREMENTS) |
|
965 | requirements=URL_NAME_REQUIREMENTS) | |
972 |
|
966 | |||
973 | rmap.connect('files_authors_home', |
|
967 | rmap.connect('files_authors_home', | |
974 | '/{repo_name}/authors/{revision}/{f_path}', |
|
968 | '/{repo_name}/authors/{revision}/{f_path}', | |
975 | controller='files', action='authors', revision='tip', f_path='', |
|
969 | controller='files', action='authors', revision='tip', f_path='', | |
976 | conditions={'function': check_repo}, |
|
970 | conditions={'function': check_repo}, | |
977 | requirements=URL_NAME_REQUIREMENTS) |
|
971 | requirements=URL_NAME_REQUIREMENTS) | |
978 |
|
972 | |||
979 | rmap.connect('files_diff_home', '/{repo_name}/diff/{f_path}', |
|
973 | rmap.connect('files_diff_home', '/{repo_name}/diff/{f_path}', | |
980 | controller='files', action='diff', f_path='', |
|
974 | controller='files', action='diff', f_path='', | |
981 | conditions={'function': check_repo}, |
|
975 | conditions={'function': check_repo}, | |
982 | requirements=URL_NAME_REQUIREMENTS) |
|
976 | requirements=URL_NAME_REQUIREMENTS) | |
983 |
|
977 | |||
984 | rmap.connect('files_diff_2way_home', |
|
978 | rmap.connect('files_diff_2way_home', | |
985 | '/{repo_name}/diff-2way/{f_path}', |
|
979 | '/{repo_name}/diff-2way/{f_path}', | |
986 | controller='files', action='diff_2way', f_path='', |
|
980 | controller='files', action='diff_2way', f_path='', | |
987 | conditions={'function': check_repo}, |
|
981 | conditions={'function': check_repo}, | |
988 | requirements=URL_NAME_REQUIREMENTS) |
|
982 | requirements=URL_NAME_REQUIREMENTS) | |
989 |
|
983 | |||
990 | rmap.connect('files_rawfile_home', |
|
984 | rmap.connect('files_rawfile_home', | |
991 | '/{repo_name}/rawfile/{revision}/{f_path}', |
|
985 | '/{repo_name}/rawfile/{revision}/{f_path}', | |
992 | controller='files', action='rawfile', revision='tip', |
|
986 | controller='files', action='rawfile', revision='tip', | |
993 | f_path='', conditions={'function': check_repo}, |
|
987 | f_path='', conditions={'function': check_repo}, | |
994 | requirements=URL_NAME_REQUIREMENTS) |
|
988 | requirements=URL_NAME_REQUIREMENTS) | |
995 |
|
989 | |||
996 | rmap.connect('files_raw_home', |
|
990 | rmap.connect('files_raw_home', | |
997 | '/{repo_name}/raw/{revision}/{f_path}', |
|
991 | '/{repo_name}/raw/{revision}/{f_path}', | |
998 | controller='files', action='raw', revision='tip', f_path='', |
|
992 | controller='files', action='raw', revision='tip', f_path='', | |
999 | conditions={'function': check_repo}, |
|
993 | conditions={'function': check_repo}, | |
1000 | requirements=URL_NAME_REQUIREMENTS) |
|
994 | requirements=URL_NAME_REQUIREMENTS) | |
1001 |
|
995 | |||
1002 | rmap.connect('files_render_home', |
|
996 | rmap.connect('files_render_home', | |
1003 | '/{repo_name}/render/{revision}/{f_path}', |
|
997 | '/{repo_name}/render/{revision}/{f_path}', | |
1004 | controller='files', action='index', revision='tip', f_path='', |
|
998 | controller='files', action='index', revision='tip', f_path='', | |
1005 | rendered=True, conditions={'function': check_repo}, |
|
999 | rendered=True, conditions={'function': check_repo}, | |
1006 | requirements=URL_NAME_REQUIREMENTS) |
|
1000 | requirements=URL_NAME_REQUIREMENTS) | |
1007 |
|
1001 | |||
1008 | rmap.connect('files_annotate_home', |
|
1002 | rmap.connect('files_annotate_home', | |
1009 | '/{repo_name}/annotate/{revision}/{f_path}', |
|
1003 | '/{repo_name}/annotate/{revision}/{f_path}', | |
1010 | controller='files', action='index', revision='tip', |
|
1004 | controller='files', action='index', revision='tip', | |
1011 | f_path='', annotate=True, conditions={'function': check_repo}, |
|
1005 | f_path='', annotate=True, conditions={'function': check_repo}, | |
1012 | requirements=URL_NAME_REQUIREMENTS) |
|
1006 | requirements=URL_NAME_REQUIREMENTS) | |
1013 |
|
1007 | |||
1014 | rmap.connect('files_edit', |
|
1008 | rmap.connect('files_edit', | |
1015 | '/{repo_name}/edit/{revision}/{f_path}', |
|
1009 | '/{repo_name}/edit/{revision}/{f_path}', | |
1016 | controller='files', action='edit', revision='tip', |
|
1010 | controller='files', action='edit', revision='tip', | |
1017 | f_path='', |
|
1011 | f_path='', | |
1018 | conditions={'function': check_repo, 'method': ['POST']}, |
|
1012 | conditions={'function': check_repo, 'method': ['POST']}, | |
1019 | requirements=URL_NAME_REQUIREMENTS) |
|
1013 | requirements=URL_NAME_REQUIREMENTS) | |
1020 |
|
1014 | |||
1021 | rmap.connect('files_edit_home', |
|
1015 | rmap.connect('files_edit_home', | |
1022 | '/{repo_name}/edit/{revision}/{f_path}', |
|
1016 | '/{repo_name}/edit/{revision}/{f_path}', | |
1023 | controller='files', action='edit_home', revision='tip', |
|
1017 | controller='files', action='edit_home', revision='tip', | |
1024 | f_path='', conditions={'function': check_repo}, |
|
1018 | f_path='', conditions={'function': check_repo}, | |
1025 | requirements=URL_NAME_REQUIREMENTS) |
|
1019 | requirements=URL_NAME_REQUIREMENTS) | |
1026 |
|
1020 | |||
1027 | rmap.connect('files_add', |
|
1021 | rmap.connect('files_add', | |
1028 | '/{repo_name}/add/{revision}/{f_path}', |
|
1022 | '/{repo_name}/add/{revision}/{f_path}', | |
1029 | controller='files', action='add', revision='tip', |
|
1023 | controller='files', action='add', revision='tip', | |
1030 | f_path='', |
|
1024 | f_path='', | |
1031 | conditions={'function': check_repo, 'method': ['POST']}, |
|
1025 | conditions={'function': check_repo, 'method': ['POST']}, | |
1032 | requirements=URL_NAME_REQUIREMENTS) |
|
1026 | requirements=URL_NAME_REQUIREMENTS) | |
1033 |
|
1027 | |||
1034 | rmap.connect('files_add_home', |
|
1028 | rmap.connect('files_add_home', | |
1035 | '/{repo_name}/add/{revision}/{f_path}', |
|
1029 | '/{repo_name}/add/{revision}/{f_path}', | |
1036 | controller='files', action='add_home', revision='tip', |
|
1030 | controller='files', action='add_home', revision='tip', | |
1037 | f_path='', conditions={'function': check_repo}, |
|
1031 | f_path='', conditions={'function': check_repo}, | |
1038 | requirements=URL_NAME_REQUIREMENTS) |
|
1032 | requirements=URL_NAME_REQUIREMENTS) | |
1039 |
|
1033 | |||
1040 | rmap.connect('files_delete', |
|
1034 | rmap.connect('files_delete', | |
1041 | '/{repo_name}/delete/{revision}/{f_path}', |
|
1035 | '/{repo_name}/delete/{revision}/{f_path}', | |
1042 | controller='files', action='delete', revision='tip', |
|
1036 | controller='files', action='delete', revision='tip', | |
1043 | f_path='', |
|
1037 | f_path='', | |
1044 | conditions={'function': check_repo, 'method': ['POST']}, |
|
1038 | conditions={'function': check_repo, 'method': ['POST']}, | |
1045 | requirements=URL_NAME_REQUIREMENTS) |
|
1039 | requirements=URL_NAME_REQUIREMENTS) | |
1046 |
|
1040 | |||
1047 | rmap.connect('files_delete_home', |
|
1041 | rmap.connect('files_delete_home', | |
1048 | '/{repo_name}/delete/{revision}/{f_path}', |
|
1042 | '/{repo_name}/delete/{revision}/{f_path}', | |
1049 | controller='files', action='delete_home', revision='tip', |
|
1043 | controller='files', action='delete_home', revision='tip', | |
1050 | f_path='', conditions={'function': check_repo}, |
|
1044 | f_path='', conditions={'function': check_repo}, | |
1051 | requirements=URL_NAME_REQUIREMENTS) |
|
1045 | requirements=URL_NAME_REQUIREMENTS) | |
1052 |
|
1046 | |||
1053 | rmap.connect('files_archive_home', '/{repo_name}/archive/{fname}', |
|
1047 | rmap.connect('files_archive_home', '/{repo_name}/archive/{fname}', | |
1054 | controller='files', action='archivefile', |
|
1048 | controller='files', action='archivefile', | |
1055 | conditions={'function': check_repo}, |
|
1049 | conditions={'function': check_repo}, | |
1056 | requirements=URL_NAME_REQUIREMENTS) |
|
1050 | requirements=URL_NAME_REQUIREMENTS) | |
1057 |
|
1051 | |||
1058 | rmap.connect('files_nodelist_home', |
|
1052 | rmap.connect('files_nodelist_home', | |
1059 | '/{repo_name}/nodelist/{revision}/{f_path}', |
|
1053 | '/{repo_name}/nodelist/{revision}/{f_path}', | |
1060 | controller='files', action='nodelist', |
|
1054 | controller='files', action='nodelist', | |
1061 | conditions={'function': check_repo}, |
|
1055 | conditions={'function': check_repo}, | |
1062 | requirements=URL_NAME_REQUIREMENTS) |
|
1056 | requirements=URL_NAME_REQUIREMENTS) | |
1063 |
|
1057 | |||
1064 | rmap.connect('files_metadata_list_home', |
|
1058 | rmap.connect('files_metadata_list_home', | |
1065 | '/{repo_name}/metadata_list/{revision}/{f_path}', |
|
1059 | '/{repo_name}/metadata_list/{revision}/{f_path}', | |
1066 | controller='files', action='metadata_list', |
|
1060 | controller='files', action='metadata_list', | |
1067 | conditions={'function': check_repo}, |
|
1061 | conditions={'function': check_repo}, | |
1068 | requirements=URL_NAME_REQUIREMENTS) |
|
1062 | requirements=URL_NAME_REQUIREMENTS) | |
1069 |
|
1063 | |||
1070 | rmap.connect('repo_fork_create_home', '/{repo_name}/fork', |
|
1064 | rmap.connect('repo_fork_create_home', '/{repo_name}/fork', | |
1071 | controller='forks', action='fork_create', |
|
1065 | controller='forks', action='fork_create', | |
1072 | conditions={'function': check_repo, 'method': ['POST']}, |
|
1066 | conditions={'function': check_repo, 'method': ['POST']}, | |
1073 | requirements=URL_NAME_REQUIREMENTS) |
|
1067 | requirements=URL_NAME_REQUIREMENTS) | |
1074 |
|
1068 | |||
1075 | rmap.connect('repo_fork_home', '/{repo_name}/fork', |
|
1069 | rmap.connect('repo_fork_home', '/{repo_name}/fork', | |
1076 | controller='forks', action='fork', |
|
1070 | controller='forks', action='fork', | |
1077 | conditions={'function': check_repo}, |
|
1071 | conditions={'function': check_repo}, | |
1078 | requirements=URL_NAME_REQUIREMENTS) |
|
1072 | requirements=URL_NAME_REQUIREMENTS) | |
1079 |
|
1073 | |||
1080 | rmap.connect('repo_forks_home', '/{repo_name}/forks', |
|
1074 | rmap.connect('repo_forks_home', '/{repo_name}/forks', | |
1081 | controller='forks', action='forks', |
|
1075 | controller='forks', action='forks', | |
1082 | conditions={'function': check_repo}, |
|
1076 | conditions={'function': check_repo}, | |
1083 | requirements=URL_NAME_REQUIREMENTS) |
|
1077 | requirements=URL_NAME_REQUIREMENTS) | |
1084 |
|
1078 | |||
1085 | rmap.connect('repo_followers_home', '/{repo_name}/followers', |
|
1079 | rmap.connect('repo_followers_home', '/{repo_name}/followers', | |
1086 | controller='followers', action='followers', |
|
1080 | controller='followers', action='followers', | |
1087 | conditions={'function': check_repo}, |
|
1081 | conditions={'function': check_repo}, | |
1088 | requirements=URL_NAME_REQUIREMENTS) |
|
1082 | requirements=URL_NAME_REQUIREMENTS) | |
1089 |
|
1083 | |||
1090 | # must be here for proper group/repo catching pattern |
|
1084 | # must be here for proper group/repo catching pattern | |
1091 | _connect_with_slash( |
|
1085 | _connect_with_slash( | |
1092 | rmap, 'repo_group_home', '/{group_name}', |
|
1086 | rmap, 'repo_group_home', '/{group_name}', | |
1093 | controller='home', action='index_repo_group', |
|
1087 | controller='home', action='index_repo_group', | |
1094 | conditions={'function': check_group}, |
|
1088 | conditions={'function': check_group}, | |
1095 | requirements=URL_NAME_REQUIREMENTS) |
|
1089 | requirements=URL_NAME_REQUIREMENTS) | |
1096 |
|
1090 | |||
1097 | # catch all, at the end |
|
1091 | # catch all, at the end | |
1098 | _connect_with_slash( |
|
1092 | _connect_with_slash( | |
1099 | rmap, 'summary_home', '/{repo_name}', |
|
1093 | rmap, 'summary_home', '/{repo_name}', | |
1100 | controller='summary', action='index', |
|
1094 | controller='summary', action='index', | |
1101 | conditions={'function': check_repo}, |
|
1095 | conditions={'function': check_repo}, | |
1102 | requirements=URL_NAME_REQUIREMENTS) |
|
1096 | requirements=URL_NAME_REQUIREMENTS) | |
1103 |
|
1097 | |||
1104 | return rmap |
|
1098 | return rmap | |
1105 |
|
1099 | |||
1106 |
|
1100 | |||
1107 | def _connect_with_slash(mapper, name, path, *args, **kwargs): |
|
1101 | def _connect_with_slash(mapper, name, path, *args, **kwargs): | |
1108 | """ |
|
1102 | """ | |
1109 | Connect a route with an optional trailing slash in `path`. |
|
1103 | Connect a route with an optional trailing slash in `path`. | |
1110 | """ |
|
1104 | """ | |
1111 | mapper.connect(name + '_slash', path + '/', *args, **kwargs) |
|
1105 | mapper.connect(name + '_slash', path + '/', *args, **kwargs) | |
1112 | mapper.connect(name, path, *args, **kwargs) |
|
1106 | mapper.connect(name, path, *args, **kwargs) |
@@ -1,373 +1,348 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2013-2016 RhodeCode GmbH |
|
3 | # Copyright (C) 2013-2016 RhodeCode GmbH | |
4 | # |
|
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
7 | # (only), as published by the Free Software Foundation. |
|
7 | # (only), as published by the Free Software Foundation. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # |
|
16 | # | |
17 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
21 |
|
21 | |||
22 | """ |
|
22 | """ | |
23 | my account controller for RhodeCode admin |
|
23 | my account controller for RhodeCode admin | |
24 | """ |
|
24 | """ | |
25 |
|
25 | |||
26 | import logging |
|
26 | import logging | |
27 |
|
27 | |||
28 | import formencode |
|
28 | import formencode | |
29 | from formencode import htmlfill |
|
29 | from formencode import htmlfill | |
30 | from pylons import request, tmpl_context as c, url, session |
|
30 | from pylons import request, tmpl_context as c, url, session | |
31 | from pylons.controllers.util import redirect |
|
31 | from pylons.controllers.util import redirect | |
32 | from pylons.i18n.translation import _ |
|
32 | from pylons.i18n.translation import _ | |
33 | from sqlalchemy.orm import joinedload |
|
33 | from sqlalchemy.orm import joinedload | |
34 |
|
34 | |||
35 | from rhodecode.lib import helpers as h |
|
35 | from rhodecode.lib import helpers as h | |
36 | from rhodecode.lib import auth |
|
36 | from rhodecode.lib import auth | |
37 | from rhodecode.lib.auth import ( |
|
37 | from rhodecode.lib.auth import ( | |
38 | LoginRequired, NotAnonymous, AuthUser, generate_auth_token) |
|
38 | LoginRequired, NotAnonymous, AuthUser, generate_auth_token) | |
39 | from rhodecode.lib.base import BaseController, render |
|
39 | from rhodecode.lib.base import BaseController, render | |
40 | from rhodecode.lib.utils2 import safe_int, md5 |
|
40 | from rhodecode.lib.utils2 import safe_int, md5 | |
41 | from rhodecode.lib.ext_json import json |
|
41 | from rhodecode.lib.ext_json import json | |
42 | from rhodecode.model.db import (Repository, PullRequest, PullRequestReviewers, |
|
42 | from rhodecode.model.db import ( | |
43 | UserEmailMap, User, UserFollowing, |
|
43 | Repository, PullRequest, PullRequestReviewers, UserEmailMap, User, | |
44 | ExternalIdentity) |
|
44 | UserFollowing) | |
45 | from rhodecode.model.forms import UserForm, PasswordChangeForm |
|
45 | from rhodecode.model.forms import UserForm, PasswordChangeForm | |
46 | from rhodecode.model.scm import RepoList |
|
46 | from rhodecode.model.scm import RepoList | |
47 | from rhodecode.model.user import UserModel |
|
47 | from rhodecode.model.user import UserModel | |
48 | from rhodecode.model.repo import RepoModel |
|
48 | from rhodecode.model.repo import RepoModel | |
49 | from rhodecode.model.auth_token import AuthTokenModel |
|
49 | from rhodecode.model.auth_token import AuthTokenModel | |
50 | from rhodecode.model.meta import Session |
|
50 | from rhodecode.model.meta import Session | |
51 | from rhodecode.model.settings import SettingsModel |
|
|||
52 |
|
51 | |||
53 | log = logging.getLogger(__name__) |
|
52 | log = logging.getLogger(__name__) | |
54 |
|
53 | |||
55 |
|
54 | |||
56 | class MyAccountController(BaseController): |
|
55 | class MyAccountController(BaseController): | |
57 | """REST Controller styled on the Atom Publishing Protocol""" |
|
56 | """REST Controller styled on the Atom Publishing Protocol""" | |
58 | # To properly map this controller, ensure your config/routing.py |
|
57 | # To properly map this controller, ensure your config/routing.py | |
59 | # file has a resource setup: |
|
58 | # file has a resource setup: | |
60 | # map.resource('setting', 'settings', controller='admin/settings', |
|
59 | # map.resource('setting', 'settings', controller='admin/settings', | |
61 | # path_prefix='/admin', name_prefix='admin_') |
|
60 | # path_prefix='/admin', name_prefix='admin_') | |
62 |
|
61 | |||
63 | @LoginRequired() |
|
62 | @LoginRequired() | |
64 | @NotAnonymous() |
|
63 | @NotAnonymous() | |
65 | def __before__(self): |
|
64 | def __before__(self): | |
66 | super(MyAccountController, self).__before__() |
|
65 | super(MyAccountController, self).__before__() | |
67 |
|
66 | |||
68 | def __load_data(self): |
|
67 | def __load_data(self): | |
69 | c.user = User.get(c.rhodecode_user.user_id) |
|
68 | c.user = User.get(c.rhodecode_user.user_id) | |
70 | if c.user.username == User.DEFAULT_USER: |
|
69 | if c.user.username == User.DEFAULT_USER: | |
71 | h.flash(_("You can't edit this user since it's" |
|
70 | h.flash(_("You can't edit this user since it's" | |
72 | " crucial for entire application"), category='warning') |
|
71 | " crucial for entire application"), category='warning') | |
73 | return redirect(url('users')) |
|
72 | return redirect(url('users')) | |
74 |
|
73 | |||
75 | def _load_my_repos_data(self, watched=False): |
|
74 | def _load_my_repos_data(self, watched=False): | |
76 | if watched: |
|
75 | if watched: | |
77 | admin = False |
|
76 | admin = False | |
78 | follows_repos = Session().query(UserFollowing)\ |
|
77 | follows_repos = Session().query(UserFollowing)\ | |
79 | .filter(UserFollowing.user_id == c.rhodecode_user.user_id)\ |
|
78 | .filter(UserFollowing.user_id == c.rhodecode_user.user_id)\ | |
80 | .options(joinedload(UserFollowing.follows_repository))\ |
|
79 | .options(joinedload(UserFollowing.follows_repository))\ | |
81 | .all() |
|
80 | .all() | |
82 | repo_list = [x.follows_repository for x in follows_repos] |
|
81 | repo_list = [x.follows_repository for x in follows_repos] | |
83 | else: |
|
82 | else: | |
84 | admin = True |
|
83 | admin = True | |
85 | repo_list = Repository.get_all_repos( |
|
84 | repo_list = Repository.get_all_repos( | |
86 | user_id=c.rhodecode_user.user_id) |
|
85 | user_id=c.rhodecode_user.user_id) | |
87 | repo_list = RepoList(repo_list, perm_set=[ |
|
86 | repo_list = RepoList(repo_list, perm_set=[ | |
88 | 'repository.read', 'repository.write', 'repository.admin']) |
|
87 | 'repository.read', 'repository.write', 'repository.admin']) | |
89 |
|
88 | |||
90 | repos_data = RepoModel().get_repos_as_dict( |
|
89 | repos_data = RepoModel().get_repos_as_dict( | |
91 | repo_list=repo_list, admin=admin) |
|
90 | repo_list=repo_list, admin=admin) | |
92 | # json used to render the grid |
|
91 | # json used to render the grid | |
93 | return json.dumps(repos_data) |
|
92 | return json.dumps(repos_data) | |
94 |
|
93 | |||
95 | @auth.CSRFRequired() |
|
94 | @auth.CSRFRequired() | |
96 | def my_account_update(self): |
|
95 | def my_account_update(self): | |
97 | """ |
|
96 | """ | |
98 | POST /_admin/my_account Updates info of my account |
|
97 | POST /_admin/my_account Updates info of my account | |
99 | """ |
|
98 | """ | |
100 | # url('my_account') |
|
99 | # url('my_account') | |
101 | c.active = 'profile_edit' |
|
100 | c.active = 'profile_edit' | |
102 | self.__load_data() |
|
101 | self.__load_data() | |
103 | c.perm_user = AuthUser(user_id=c.rhodecode_user.user_id, |
|
102 | c.perm_user = AuthUser(user_id=c.rhodecode_user.user_id, | |
104 | ip_addr=self.ip_addr) |
|
103 | ip_addr=self.ip_addr) | |
105 | c.extern_type = c.user.extern_type |
|
104 | c.extern_type = c.user.extern_type | |
106 | c.extern_name = c.user.extern_name |
|
105 | c.extern_name = c.user.extern_name | |
107 |
|
106 | |||
108 | defaults = c.user.get_dict() |
|
107 | defaults = c.user.get_dict() | |
109 | update = False |
|
108 | update = False | |
110 | _form = UserForm(edit=True, |
|
109 | _form = UserForm(edit=True, | |
111 | old_data={'user_id': c.rhodecode_user.user_id, |
|
110 | old_data={'user_id': c.rhodecode_user.user_id, | |
112 | 'email': c.rhodecode_user.email})() |
|
111 | 'email': c.rhodecode_user.email})() | |
113 | form_result = {} |
|
112 | form_result = {} | |
114 | try: |
|
113 | try: | |
115 | post_data = dict(request.POST) |
|
114 | post_data = dict(request.POST) | |
116 | post_data['new_password'] = '' |
|
115 | post_data['new_password'] = '' | |
117 | post_data['password_confirmation'] = '' |
|
116 | post_data['password_confirmation'] = '' | |
118 | form_result = _form.to_python(post_data) |
|
117 | form_result = _form.to_python(post_data) | |
119 | # skip updating those attrs for my account |
|
118 | # skip updating those attrs for my account | |
120 | skip_attrs = ['admin', 'active', 'extern_type', 'extern_name', |
|
119 | skip_attrs = ['admin', 'active', 'extern_type', 'extern_name', | |
121 | 'new_password', 'password_confirmation'] |
|
120 | 'new_password', 'password_confirmation'] | |
122 | # TODO: plugin should define if username can be updated |
|
121 | # TODO: plugin should define if username can be updated | |
123 | if c.extern_type != "rhodecode": |
|
122 | if c.extern_type != "rhodecode": | |
124 | # forbid updating username for external accounts |
|
123 | # forbid updating username for external accounts | |
125 | skip_attrs.append('username') |
|
124 | skip_attrs.append('username') | |
126 |
|
125 | |||
127 | UserModel().update_user( |
|
126 | UserModel().update_user( | |
128 | c.rhodecode_user.user_id, skip_attrs=skip_attrs, **form_result) |
|
127 | c.rhodecode_user.user_id, skip_attrs=skip_attrs, **form_result) | |
129 | h.flash(_('Your account was updated successfully'), |
|
128 | h.flash(_('Your account was updated successfully'), | |
130 | category='success') |
|
129 | category='success') | |
131 | Session().commit() |
|
130 | Session().commit() | |
132 | update = True |
|
131 | update = True | |
133 |
|
132 | |||
134 | except formencode.Invalid as errors: |
|
133 | except formencode.Invalid as errors: | |
135 | return htmlfill.render( |
|
134 | return htmlfill.render( | |
136 | render('admin/my_account/my_account.html'), |
|
135 | render('admin/my_account/my_account.html'), | |
137 | defaults=errors.value, |
|
136 | defaults=errors.value, | |
138 | errors=errors.error_dict or {}, |
|
137 | errors=errors.error_dict or {}, | |
139 | prefix_error=False, |
|
138 | prefix_error=False, | |
140 | encoding="UTF-8", |
|
139 | encoding="UTF-8", | |
141 | force_defaults=False) |
|
140 | force_defaults=False) | |
142 | except Exception: |
|
141 | except Exception: | |
143 | log.exception("Exception updating user") |
|
142 | log.exception("Exception updating user") | |
144 | h.flash(_('Error occurred during update of user %s') |
|
143 | h.flash(_('Error occurred during update of user %s') | |
145 | % form_result.get('username'), category='error') |
|
144 | % form_result.get('username'), category='error') | |
146 |
|
145 | |||
147 | if update: |
|
146 | if update: | |
148 | return redirect('my_account') |
|
147 | return redirect('my_account') | |
149 |
|
148 | |||
150 | return htmlfill.render( |
|
149 | return htmlfill.render( | |
151 | render('admin/my_account/my_account.html'), |
|
150 | render('admin/my_account/my_account.html'), | |
152 | defaults=defaults, |
|
151 | defaults=defaults, | |
153 | encoding="UTF-8", |
|
152 | encoding="UTF-8", | |
154 | force_defaults=False |
|
153 | force_defaults=False | |
155 | ) |
|
154 | ) | |
156 |
|
155 | |||
157 | def my_account(self): |
|
156 | def my_account(self): | |
158 | """ |
|
157 | """ | |
159 | GET /_admin/my_account Displays info about my account |
|
158 | GET /_admin/my_account Displays info about my account | |
160 | """ |
|
159 | """ | |
161 | # url('my_account') |
|
160 | # url('my_account') | |
162 | c.active = 'profile' |
|
161 | c.active = 'profile' | |
163 | self.__load_data() |
|
162 | self.__load_data() | |
164 |
|
163 | |||
165 | defaults = c.user.get_dict() |
|
164 | defaults = c.user.get_dict() | |
166 | return htmlfill.render( |
|
165 | return htmlfill.render( | |
167 | render('admin/my_account/my_account.html'), |
|
166 | render('admin/my_account/my_account.html'), | |
168 | defaults=defaults, encoding="UTF-8", force_defaults=False) |
|
167 | defaults=defaults, encoding="UTF-8", force_defaults=False) | |
169 |
|
168 | |||
170 | def my_account_edit(self): |
|
169 | def my_account_edit(self): | |
171 | """ |
|
170 | """ | |
172 | GET /_admin/my_account/edit Displays edit form of my account |
|
171 | GET /_admin/my_account/edit Displays edit form of my account | |
173 | """ |
|
172 | """ | |
174 | c.active = 'profile_edit' |
|
173 | c.active = 'profile_edit' | |
175 | self.__load_data() |
|
174 | self.__load_data() | |
176 | c.perm_user = AuthUser(user_id=c.rhodecode_user.user_id, |
|
175 | c.perm_user = AuthUser(user_id=c.rhodecode_user.user_id, | |
177 | ip_addr=self.ip_addr) |
|
176 | ip_addr=self.ip_addr) | |
178 | c.extern_type = c.user.extern_type |
|
177 | c.extern_type = c.user.extern_type | |
179 | c.extern_name = c.user.extern_name |
|
178 | c.extern_name = c.user.extern_name | |
180 |
|
179 | |||
181 | defaults = c.user.get_dict() |
|
180 | defaults = c.user.get_dict() | |
182 | return htmlfill.render( |
|
181 | return htmlfill.render( | |
183 | render('admin/my_account/my_account.html'), |
|
182 | render('admin/my_account/my_account.html'), | |
184 | defaults=defaults, |
|
183 | defaults=defaults, | |
185 | encoding="UTF-8", |
|
184 | encoding="UTF-8", | |
186 | force_defaults=False |
|
185 | force_defaults=False | |
187 | ) |
|
186 | ) | |
188 |
|
187 | |||
189 | @auth.CSRFRequired() |
|
188 | @auth.CSRFRequired() | |
190 | def my_account_password_update(self): |
|
189 | def my_account_password_update(self): | |
191 | c.active = 'password' |
|
190 | c.active = 'password' | |
192 | self.__load_data() |
|
191 | self.__load_data() | |
193 | _form = PasswordChangeForm(c.rhodecode_user.username)() |
|
192 | _form = PasswordChangeForm(c.rhodecode_user.username)() | |
194 | try: |
|
193 | try: | |
195 | form_result = _form.to_python(request.POST) |
|
194 | form_result = _form.to_python(request.POST) | |
196 | UserModel().update_user(c.rhodecode_user.user_id, **form_result) |
|
195 | UserModel().update_user(c.rhodecode_user.user_id, **form_result) | |
197 | instance = c.rhodecode_user.get_instance() |
|
196 | instance = c.rhodecode_user.get_instance() | |
198 | instance.update_userdata(force_password_change=False) |
|
197 | instance.update_userdata(force_password_change=False) | |
199 | Session().commit() |
|
198 | Session().commit() | |
200 | session.setdefault('rhodecode_user', {}).update( |
|
199 | session.setdefault('rhodecode_user', {}).update( | |
201 | {'password': md5(instance.password)}) |
|
200 | {'password': md5(instance.password)}) | |
202 | session.save() |
|
201 | session.save() | |
203 | h.flash(_("Successfully updated password"), category='success') |
|
202 | h.flash(_("Successfully updated password"), category='success') | |
204 | except formencode.Invalid as errors: |
|
203 | except formencode.Invalid as errors: | |
205 | return htmlfill.render( |
|
204 | return htmlfill.render( | |
206 | render('admin/my_account/my_account.html'), |
|
205 | render('admin/my_account/my_account.html'), | |
207 | defaults=errors.value, |
|
206 | defaults=errors.value, | |
208 | errors=errors.error_dict or {}, |
|
207 | errors=errors.error_dict or {}, | |
209 | prefix_error=False, |
|
208 | prefix_error=False, | |
210 | encoding="UTF-8", |
|
209 | encoding="UTF-8", | |
211 | force_defaults=False) |
|
210 | force_defaults=False) | |
212 | except Exception: |
|
211 | except Exception: | |
213 | log.exception("Exception updating password") |
|
212 | log.exception("Exception updating password") | |
214 | h.flash(_('Error occurred during update of user password'), |
|
213 | h.flash(_('Error occurred during update of user password'), | |
215 | category='error') |
|
214 | category='error') | |
216 | return render('admin/my_account/my_account.html') |
|
215 | return render('admin/my_account/my_account.html') | |
217 |
|
216 | |||
218 | def my_account_password(self): |
|
217 | def my_account_password(self): | |
219 | c.active = 'password' |
|
218 | c.active = 'password' | |
220 | self.__load_data() |
|
219 | self.__load_data() | |
221 | return render('admin/my_account/my_account.html') |
|
220 | return render('admin/my_account/my_account.html') | |
222 |
|
221 | |||
223 | def my_account_repos(self): |
|
222 | def my_account_repos(self): | |
224 | c.active = 'repos' |
|
223 | c.active = 'repos' | |
225 | self.__load_data() |
|
224 | self.__load_data() | |
226 |
|
225 | |||
227 | # json used to render the grid |
|
226 | # json used to render the grid | |
228 | c.data = self._load_my_repos_data() |
|
227 | c.data = self._load_my_repos_data() | |
229 | return render('admin/my_account/my_account.html') |
|
228 | return render('admin/my_account/my_account.html') | |
230 |
|
229 | |||
231 | def my_account_watched(self): |
|
230 | def my_account_watched(self): | |
232 | c.active = 'watched' |
|
231 | c.active = 'watched' | |
233 | self.__load_data() |
|
232 | self.__load_data() | |
234 |
|
233 | |||
235 | # json used to render the grid |
|
234 | # json used to render the grid | |
236 | c.data = self._load_my_repos_data(watched=True) |
|
235 | c.data = self._load_my_repos_data(watched=True) | |
237 | return render('admin/my_account/my_account.html') |
|
236 | return render('admin/my_account/my_account.html') | |
238 |
|
237 | |||
239 | def my_account_perms(self): |
|
238 | def my_account_perms(self): | |
240 | c.active = 'perms' |
|
239 | c.active = 'perms' | |
241 | self.__load_data() |
|
240 | self.__load_data() | |
242 | c.perm_user = AuthUser(user_id=c.rhodecode_user.user_id, |
|
241 | c.perm_user = AuthUser(user_id=c.rhodecode_user.user_id, | |
243 | ip_addr=self.ip_addr) |
|
242 | ip_addr=self.ip_addr) | |
244 |
|
243 | |||
245 | return render('admin/my_account/my_account.html') |
|
244 | return render('admin/my_account/my_account.html') | |
246 |
|
245 | |||
247 | def my_account_emails(self): |
|
246 | def my_account_emails(self): | |
248 | c.active = 'emails' |
|
247 | c.active = 'emails' | |
249 | self.__load_data() |
|
248 | self.__load_data() | |
250 |
|
249 | |||
251 | c.user_email_map = UserEmailMap.query()\ |
|
250 | c.user_email_map = UserEmailMap.query()\ | |
252 | .filter(UserEmailMap.user == c.user).all() |
|
251 | .filter(UserEmailMap.user == c.user).all() | |
253 | return render('admin/my_account/my_account.html') |
|
252 | return render('admin/my_account/my_account.html') | |
254 |
|
253 | |||
255 | @auth.CSRFRequired() |
|
254 | @auth.CSRFRequired() | |
256 | def my_account_emails_add(self): |
|
255 | def my_account_emails_add(self): | |
257 | email = request.POST.get('new_email') |
|
256 | email = request.POST.get('new_email') | |
258 |
|
257 | |||
259 | try: |
|
258 | try: | |
260 | UserModel().add_extra_email(c.rhodecode_user.user_id, email) |
|
259 | UserModel().add_extra_email(c.rhodecode_user.user_id, email) | |
261 | Session().commit() |
|
260 | Session().commit() | |
262 | h.flash(_("Added new email address `%s` for user account") % email, |
|
261 | h.flash(_("Added new email address `%s` for user account") % email, | |
263 | category='success') |
|
262 | category='success') | |
264 | except formencode.Invalid as error: |
|
263 | except formencode.Invalid as error: | |
265 | msg = error.error_dict['email'] |
|
264 | msg = error.error_dict['email'] | |
266 | h.flash(msg, category='error') |
|
265 | h.flash(msg, category='error') | |
267 | except Exception: |
|
266 | except Exception: | |
268 | log.exception("Exception in my_account_emails") |
|
267 | log.exception("Exception in my_account_emails") | |
269 | h.flash(_('An error occurred during email saving'), |
|
268 | h.flash(_('An error occurred during email saving'), | |
270 | category='error') |
|
269 | category='error') | |
271 | return redirect(url('my_account_emails')) |
|
270 | return redirect(url('my_account_emails')) | |
272 |
|
271 | |||
273 | @auth.CSRFRequired() |
|
272 | @auth.CSRFRequired() | |
274 | def my_account_emails_delete(self): |
|
273 | def my_account_emails_delete(self): | |
275 | email_id = request.POST.get('del_email_id') |
|
274 | email_id = request.POST.get('del_email_id') | |
276 | user_model = UserModel() |
|
275 | user_model = UserModel() | |
277 | user_model.delete_extra_email(c.rhodecode_user.user_id, email_id) |
|
276 | user_model.delete_extra_email(c.rhodecode_user.user_id, email_id) | |
278 | Session().commit() |
|
277 | Session().commit() | |
279 | h.flash(_("Removed email address from user account"), |
|
278 | h.flash(_("Removed email address from user account"), | |
280 | category='success') |
|
279 | category='success') | |
281 | return redirect(url('my_account_emails')) |
|
280 | return redirect(url('my_account_emails')) | |
282 |
|
281 | |||
283 | def my_account_pullrequests(self): |
|
282 | def my_account_pullrequests(self): | |
284 | c.active = 'pullrequests' |
|
283 | c.active = 'pullrequests' | |
285 | self.__load_data() |
|
284 | self.__load_data() | |
286 | c.show_closed = request.GET.get('pr_show_closed') |
|
285 | c.show_closed = request.GET.get('pr_show_closed') | |
287 |
|
286 | |||
288 | def _filter(pr): |
|
287 | def _filter(pr): | |
289 | s = sorted(pr, key=lambda o: o.created_on, reverse=True) |
|
288 | s = sorted(pr, key=lambda o: o.created_on, reverse=True) | |
290 | if not c.show_closed: |
|
289 | if not c.show_closed: | |
291 | s = filter(lambda p: p.status != PullRequest.STATUS_CLOSED, s) |
|
290 | s = filter(lambda p: p.status != PullRequest.STATUS_CLOSED, s) | |
292 | return s |
|
291 | return s | |
293 |
|
292 | |||
294 | c.my_pull_requests = _filter( |
|
293 | c.my_pull_requests = _filter( | |
295 | PullRequest.query().filter( |
|
294 | PullRequest.query().filter( | |
296 | PullRequest.user_id == c.rhodecode_user.user_id).all()) |
|
295 | PullRequest.user_id == c.rhodecode_user.user_id).all()) | |
297 | my_prs = [ |
|
296 | my_prs = [ | |
298 | x.pull_request for x in PullRequestReviewers.query().filter( |
|
297 | x.pull_request for x in PullRequestReviewers.query().filter( | |
299 | PullRequestReviewers.user_id == c.rhodecode_user.user_id).all()] |
|
298 | PullRequestReviewers.user_id == c.rhodecode_user.user_id).all()] | |
300 | c.participate_in_pull_requests = _filter(my_prs) |
|
299 | c.participate_in_pull_requests = _filter(my_prs) | |
301 | return render('admin/my_account/my_account.html') |
|
300 | return render('admin/my_account/my_account.html') | |
302 |
|
301 | |||
303 | def my_account_auth_tokens(self): |
|
302 | def my_account_auth_tokens(self): | |
304 | c.active = 'auth_tokens' |
|
303 | c.active = 'auth_tokens' | |
305 | self.__load_data() |
|
304 | self.__load_data() | |
306 | show_expired = True |
|
305 | show_expired = True | |
307 | c.lifetime_values = [ |
|
306 | c.lifetime_values = [ | |
308 | (str(-1), _('forever')), |
|
307 | (str(-1), _('forever')), | |
309 | (str(5), _('5 minutes')), |
|
308 | (str(5), _('5 minutes')), | |
310 | (str(60), _('1 hour')), |
|
309 | (str(60), _('1 hour')), | |
311 | (str(60 * 24), _('1 day')), |
|
310 | (str(60 * 24), _('1 day')), | |
312 | (str(60 * 24 * 30), _('1 month')), |
|
311 | (str(60 * 24 * 30), _('1 month')), | |
313 | ] |
|
312 | ] | |
314 | c.lifetime_options = [(c.lifetime_values, _("Lifetime"))] |
|
313 | c.lifetime_options = [(c.lifetime_values, _("Lifetime"))] | |
315 | c.role_values = [(x, AuthTokenModel.cls._get_role_name(x)) |
|
314 | c.role_values = [(x, AuthTokenModel.cls._get_role_name(x)) | |
316 | for x in AuthTokenModel.cls.ROLES] |
|
315 | for x in AuthTokenModel.cls.ROLES] | |
317 | c.role_options = [(c.role_values, _("Role"))] |
|
316 | c.role_options = [(c.role_values, _("Role"))] | |
318 | c.user_auth_tokens = AuthTokenModel().get_auth_tokens( |
|
317 | c.user_auth_tokens = AuthTokenModel().get_auth_tokens( | |
319 | c.rhodecode_user.user_id, show_expired=show_expired) |
|
318 | c.rhodecode_user.user_id, show_expired=show_expired) | |
320 | return render('admin/my_account/my_account.html') |
|
319 | return render('admin/my_account/my_account.html') | |
321 |
|
320 | |||
322 | @auth.CSRFRequired() |
|
321 | @auth.CSRFRequired() | |
323 | def my_account_auth_tokens_add(self): |
|
322 | def my_account_auth_tokens_add(self): | |
324 | lifetime = safe_int(request.POST.get('lifetime'), -1) |
|
323 | lifetime = safe_int(request.POST.get('lifetime'), -1) | |
325 | description = request.POST.get('description') |
|
324 | description = request.POST.get('description') | |
326 | role = request.POST.get('role') |
|
325 | role = request.POST.get('role') | |
327 | AuthTokenModel().create(c.rhodecode_user.user_id, description, lifetime, |
|
326 | AuthTokenModel().create(c.rhodecode_user.user_id, description, lifetime, | |
328 | role) |
|
327 | role) | |
329 | Session().commit() |
|
328 | Session().commit() | |
330 | h.flash(_("Auth token successfully created"), category='success') |
|
329 | h.flash(_("Auth token successfully created"), category='success') | |
331 | return redirect(url('my_account_auth_tokens')) |
|
330 | return redirect(url('my_account_auth_tokens')) | |
332 |
|
331 | |||
333 | @auth.CSRFRequired() |
|
332 | @auth.CSRFRequired() | |
334 | def my_account_auth_tokens_delete(self): |
|
333 | def my_account_auth_tokens_delete(self): | |
335 | auth_token = request.POST.get('del_auth_token') |
|
334 | auth_token = request.POST.get('del_auth_token') | |
336 | user_id = c.rhodecode_user.user_id |
|
335 | user_id = c.rhodecode_user.user_id | |
337 | if request.POST.get('del_auth_token_builtin'): |
|
336 | if request.POST.get('del_auth_token_builtin'): | |
338 | user = User.get(user_id) |
|
337 | user = User.get(user_id) | |
339 | if user: |
|
338 | if user: | |
340 | user.api_key = generate_auth_token(user.username) |
|
339 | user.api_key = generate_auth_token(user.username) | |
341 | Session().add(user) |
|
340 | Session().add(user) | |
342 | Session().commit() |
|
341 | Session().commit() | |
343 | h.flash(_("Auth token successfully reset"), category='success') |
|
342 | h.flash(_("Auth token successfully reset"), category='success') | |
344 | elif auth_token: |
|
343 | elif auth_token: | |
345 | AuthTokenModel().delete(auth_token, c.rhodecode_user.user_id) |
|
344 | AuthTokenModel().delete(auth_token, c.rhodecode_user.user_id) | |
346 | Session().commit() |
|
345 | Session().commit() | |
347 | h.flash(_("Auth token successfully deleted"), category='success') |
|
346 | h.flash(_("Auth token successfully deleted"), category='success') | |
348 |
|
347 | |||
349 | return redirect(url('my_account_auth_tokens')) |
|
348 | return redirect(url('my_account_auth_tokens')) | |
350 |
|
||||
351 | def my_account_oauth(self): |
|
|||
352 | c.active = 'oauth' |
|
|||
353 | self.__load_data() |
|
|||
354 | c.user_oauth_tokens = ExternalIdentity().by_local_user_id( |
|
|||
355 | c.rhodecode_user.user_id).all() |
|
|||
356 | settings = SettingsModel().get_all_settings() |
|
|||
357 | c.social_plugins = SettingsModel().list_enabled_social_plugins( |
|
|||
358 | settings) |
|
|||
359 | return render('admin/my_account/my_account.html') |
|
|||
360 |
|
||||
361 | @auth.CSRFRequired() |
|
|||
362 | def my_account_oauth_delete(self): |
|
|||
363 | token = ExternalIdentity.by_external_id_and_provider( |
|
|||
364 | request.params.get('external_id'), |
|
|||
365 | request.params.get('provider_name'), |
|
|||
366 | local_user_id=c.rhodecode_user.user_id |
|
|||
367 | ) |
|
|||
368 | if token: |
|
|||
369 | Session().delete(token) |
|
|||
370 | Session().commit() |
|
|||
371 | h.flash(_("OAuth token successfully deleted"), category='success') |
|
|||
372 |
|
||||
373 | return redirect(url('my_account_oauth')) |
|
@@ -1,47 +1,51 b'' | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 | <%inherit file="/base/base.html"/> |
|
2 | <%inherit file="/base/base.html"/> | |
3 |
|
3 | |||
4 | <%def name="title()"> |
|
4 | <%def name="title()"> | |
5 | ${_('My account')} ${c.rhodecode_user.username} |
|
5 | ${_('My account')} ${c.rhodecode_user.username} | |
6 | %if c.rhodecode_name: |
|
6 | %if c.rhodecode_name: | |
7 | · ${h.branding(c.rhodecode_name)} |
|
7 | · ${h.branding(c.rhodecode_name)} | |
8 | %endif |
|
8 | %endif | |
9 | </%def> |
|
9 | </%def> | |
10 |
|
10 | |||
11 | <%def name="breadcrumbs_links()"> |
|
11 | <%def name="breadcrumbs_links()"> | |
12 | ${_('My Account')} |
|
12 | ${_('My Account')} | |
13 | </%def> |
|
13 | </%def> | |
14 |
|
14 | |||
15 | <%def name="menu_bar_nav()"> |
|
15 | <%def name="menu_bar_nav()"> | |
16 | ${self.menu_items(active='admin')} |
|
16 | ${self.menu_items(active='admin')} | |
17 | </%def> |
|
17 | </%def> | |
18 |
|
18 | |||
19 | <%def name="main()"> |
|
19 | <%def name="main()"> | |
20 | <div class="box"> |
|
20 | <div class="box"> | |
21 | <div class="title"> |
|
21 | <div class="title"> | |
22 | ${self.breadcrumbs()} |
|
22 | ${self.breadcrumbs()} | |
23 | </div> |
|
23 | </div> | |
24 |
|
24 | |||
25 | <div class="sidebar-col-wrapper scw-small"> |
|
25 | <div class="sidebar-col-wrapper scw-small"> | |
26 | ##main |
|
26 | ##main | |
27 | <div class="sidebar"> |
|
27 | <div class="sidebar"> | |
28 | <ul class="nav nav-pills nav-stacked"> |
|
28 | <ul class="nav nav-pills nav-stacked"> | |
29 | <li class="${'active' if c.active=='profile' or c.active=='profile_edit' else ''}"><a href="${h.url('my_account')}">${_('My Profile')}</a></li> |
|
29 | <li class="${'active' if c.active=='profile' or c.active=='profile_edit' else ''}"><a href="${h.url('my_account')}">${_('My Profile')}</a></li> | |
30 | <li class="${'active' if c.active=='password' else ''}"><a href="${h.url('my_account_password')}">${_('Password')}</a></li> |
|
30 | <li class="${'active' if c.active=='password' else ''}"><a href="${h.url('my_account_password')}">${_('Password')}</a></li> | |
31 | <li class="${'active' if c.active=='auth_tokens' else ''}"><a href="${h.url('my_account_auth_tokens')}">${_('Auth Tokens')}</a></li> |
|
31 | <li class="${'active' if c.active=='auth_tokens' else ''}"><a href="${h.url('my_account_auth_tokens')}">${_('Auth Tokens')}</a></li> | |
32 | <li class="${'active' if c.active=='oauth' else ''}"><a href="${h.url('my_account_oauth')}">${_('OAuth Identities')}</a></li> |
|
32 | ## TODO: Find a better integration of oauth views into navigation. | |
|
33 | %try: | |||
|
34 | <li class="${'active' if c.active=='oauth' else ''}"><a href="${h.route_path('my_account_oauth')}">${_('OAuth Identities')}</a></li> | |||
|
35 | %except KeyError: | |||
|
36 | %endtry | |||
33 | <li class="${'active' if c.active=='emails' else ''}"><a href="${h.url('my_account_emails')}">${_('My Emails')}</a></li> |
|
37 | <li class="${'active' if c.active=='emails' else ''}"><a href="${h.url('my_account_emails')}">${_('My Emails')}</a></li> | |
34 | <li class="${'active' if c.active=='repos' else ''}"><a href="${h.url('my_account_repos')}">${_('My Repositories')}</a></li> |
|
38 | <li class="${'active' if c.active=='repos' else ''}"><a href="${h.url('my_account_repos')}">${_('My Repositories')}</a></li> | |
35 | <li class="${'active' if c.active=='watched' else ''}"><a href="${h.url('my_account_watched')}">${_('Watched')}</a></li> |
|
39 | <li class="${'active' if c.active=='watched' else ''}"><a href="${h.url('my_account_watched')}">${_('Watched')}</a></li> | |
36 | <li class="${'active' if c.active=='pullrequests' else ''}"><a href="${h.url('my_account_pullrequests')}">${_('Pull Requests')}</a></li> |
|
40 | <li class="${'active' if c.active=='pullrequests' else ''}"><a href="${h.url('my_account_pullrequests')}">${_('Pull Requests')}</a></li> | |
37 | <li class="${'active' if c.active=='perms' else ''}"><a href="${h.url('my_account_perms')}">${_('My Permissions')}</a></li> |
|
41 | <li class="${'active' if c.active=='perms' else ''}"><a href="${h.url('my_account_perms')}">${_('My Permissions')}</a></li> | |
38 | </ul> |
|
42 | </ul> | |
39 | </div> |
|
43 | </div> | |
40 |
|
44 | |||
41 | <div class="main-content-full-width"> |
|
45 | <div class="main-content-full-width"> | |
42 | <%include file="/admin/my_account/my_account_${c.active}.html"/> |
|
46 | <%include file="/admin/my_account/my_account_${c.active}.html"/> | |
43 | </div> |
|
47 | </div> | |
44 | </div> |
|
48 | </div> | |
45 | </div> |
|
49 | </div> | |
46 |
|
50 | |||
47 | </%def> |
|
51 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now