Show More
@@ -1,463 +1,467 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2016-2018 RhodeCode GmbH |
|
3 | # Copyright (C) 2016-2018 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 | from rhodecode.apps._base import add_route_with_slash |
|
20 | from rhodecode.apps._base import add_route_with_slash | |
21 |
|
21 | |||
22 |
|
22 | |||
23 | def includeme(config): |
|
23 | def includeme(config): | |
24 |
|
24 | |||
25 | # repo creating checks, special cases that aren't repo routes |
|
25 | # repo creating checks, special cases that aren't repo routes | |
26 | config.add_route( |
|
26 | config.add_route( | |
27 | name='repo_creating', |
|
27 | name='repo_creating', | |
28 | pattern='/{repo_name:.*?[^/]}/repo_creating') |
|
28 | pattern='/{repo_name:.*?[^/]}/repo_creating') | |
29 |
|
29 | |||
30 | config.add_route( |
|
30 | config.add_route( | |
31 | name='repo_creating_check', |
|
31 | name='repo_creating_check', | |
32 | pattern='/{repo_name:.*?[^/]}/repo_creating_check') |
|
32 | pattern='/{repo_name:.*?[^/]}/repo_creating_check') | |
33 |
|
33 | |||
34 | # Summary |
|
34 | # Summary | |
35 | # NOTE(marcink): one additional route is defined in very bottom, catch |
|
35 | # NOTE(marcink): one additional route is defined in very bottom, catch | |
36 | # all pattern |
|
36 | # all pattern | |
37 | config.add_route( |
|
37 | config.add_route( | |
38 | name='repo_summary_explicit', |
|
38 | name='repo_summary_explicit', | |
39 | pattern='/{repo_name:.*?[^/]}/summary', repo_route=True) |
|
39 | pattern='/{repo_name:.*?[^/]}/summary', repo_route=True) | |
40 | config.add_route( |
|
40 | config.add_route( | |
41 | name='repo_summary_commits', |
|
41 | name='repo_summary_commits', | |
42 | pattern='/{repo_name:.*?[^/]}/summary-commits', repo_route=True) |
|
42 | pattern='/{repo_name:.*?[^/]}/summary-commits', repo_route=True) | |
43 |
|
43 | |||
44 | # Commits |
|
44 | # Commits | |
45 | config.add_route( |
|
45 | config.add_route( | |
46 | name='repo_commit', |
|
46 | name='repo_commit', | |
47 | pattern='/{repo_name:.*?[^/]}/changeset/{commit_id}', repo_route=True) |
|
47 | pattern='/{repo_name:.*?[^/]}/changeset/{commit_id}', repo_route=True) | |
48 |
|
48 | |||
49 | config.add_route( |
|
49 | config.add_route( | |
50 | name='repo_commit_children', |
|
50 | name='repo_commit_children', | |
51 | pattern='/{repo_name:.*?[^/]}/changeset_children/{commit_id}', repo_route=True) |
|
51 | pattern='/{repo_name:.*?[^/]}/changeset_children/{commit_id}', repo_route=True) | |
52 |
|
52 | |||
53 | config.add_route( |
|
53 | config.add_route( | |
54 | name='repo_commit_parents', |
|
54 | name='repo_commit_parents', | |
55 | pattern='/{repo_name:.*?[^/]}/changeset_parents/{commit_id}', repo_route=True) |
|
55 | pattern='/{repo_name:.*?[^/]}/changeset_parents/{commit_id}', repo_route=True) | |
56 |
|
56 | |||
57 | config.add_route( |
|
57 | config.add_route( | |
58 | name='repo_commit_raw', |
|
58 | name='repo_commit_raw', | |
59 | pattern='/{repo_name:.*?[^/]}/changeset-diff/{commit_id}', repo_route=True) |
|
59 | pattern='/{repo_name:.*?[^/]}/changeset-diff/{commit_id}', repo_route=True) | |
60 |
|
60 | |||
61 | config.add_route( |
|
61 | config.add_route( | |
62 | name='repo_commit_patch', |
|
62 | name='repo_commit_patch', | |
63 | pattern='/{repo_name:.*?[^/]}/changeset-patch/{commit_id}', repo_route=True) |
|
63 | pattern='/{repo_name:.*?[^/]}/changeset-patch/{commit_id}', repo_route=True) | |
64 |
|
64 | |||
65 | config.add_route( |
|
65 | config.add_route( | |
66 | name='repo_commit_download', |
|
66 | name='repo_commit_download', | |
67 | pattern='/{repo_name:.*?[^/]}/changeset-download/{commit_id}', repo_route=True) |
|
67 | pattern='/{repo_name:.*?[^/]}/changeset-download/{commit_id}', repo_route=True) | |
68 |
|
68 | |||
69 | config.add_route( |
|
69 | config.add_route( | |
70 | name='repo_commit_data', |
|
70 | name='repo_commit_data', | |
71 | pattern='/{repo_name:.*?[^/]}/changeset-data/{commit_id}', repo_route=True) |
|
71 | pattern='/{repo_name:.*?[^/]}/changeset-data/{commit_id}', repo_route=True) | |
72 |
|
72 | |||
73 | config.add_route( |
|
73 | config.add_route( | |
74 | name='repo_commit_comment_create', |
|
74 | name='repo_commit_comment_create', | |
75 | pattern='/{repo_name:.*?[^/]}/changeset/{commit_id}/comment/create', repo_route=True) |
|
75 | pattern='/{repo_name:.*?[^/]}/changeset/{commit_id}/comment/create', repo_route=True) | |
76 |
|
76 | |||
77 | config.add_route( |
|
77 | config.add_route( | |
78 | name='repo_commit_comment_preview', |
|
78 | name='repo_commit_comment_preview', | |
79 | pattern='/{repo_name:.*?[^/]}/changeset/{commit_id}/comment/preview', repo_route=True) |
|
79 | pattern='/{repo_name:.*?[^/]}/changeset/{commit_id}/comment/preview', repo_route=True) | |
80 |
|
80 | |||
81 | config.add_route( |
|
81 | config.add_route( | |
82 | name='repo_commit_comment_delete', |
|
82 | name='repo_commit_comment_delete', | |
83 | pattern='/{repo_name:.*?[^/]}/changeset/{commit_id}/comment/{comment_id}/delete', repo_route=True) |
|
83 | pattern='/{repo_name:.*?[^/]}/changeset/{commit_id}/comment/{comment_id}/delete', repo_route=True) | |
84 |
|
84 | |||
85 | # still working url for backward compat. |
|
85 | # still working url for backward compat. | |
86 | config.add_route( |
|
86 | config.add_route( | |
87 | name='repo_commit_raw_deprecated', |
|
87 | name='repo_commit_raw_deprecated', | |
88 | pattern='/{repo_name:.*?[^/]}/raw-changeset/{commit_id}', repo_route=True) |
|
88 | pattern='/{repo_name:.*?[^/]}/raw-changeset/{commit_id}', repo_route=True) | |
89 |
|
89 | |||
90 | # Files |
|
90 | # Files | |
91 | config.add_route( |
|
91 | config.add_route( | |
92 | name='repo_archivefile', |
|
92 | name='repo_archivefile', | |
93 | pattern='/{repo_name:.*?[^/]}/archive/{fname}', repo_route=True) |
|
93 | pattern='/{repo_name:.*?[^/]}/archive/{fname}', repo_route=True) | |
94 |
|
94 | |||
95 | config.add_route( |
|
95 | config.add_route( | |
96 | name='repo_files_diff', |
|
96 | name='repo_files_diff', | |
97 | pattern='/{repo_name:.*?[^/]}/diff/{f_path:.*}', repo_route=True) |
|
97 | pattern='/{repo_name:.*?[^/]}/diff/{f_path:.*}', repo_route=True) | |
98 | config.add_route( # legacy route to make old links work |
|
98 | config.add_route( # legacy route to make old links work | |
99 | name='repo_files_diff_2way_redirect', |
|
99 | name='repo_files_diff_2way_redirect', | |
100 | pattern='/{repo_name:.*?[^/]}/diff-2way/{f_path:.*}', repo_route=True) |
|
100 | pattern='/{repo_name:.*?[^/]}/diff-2way/{f_path:.*}', repo_route=True) | |
101 |
|
101 | |||
102 | config.add_route( |
|
102 | config.add_route( | |
103 | name='repo_files', |
|
103 | name='repo_files', | |
104 | pattern='/{repo_name:.*?[^/]}/files/{commit_id}/{f_path:.*}', repo_route=True) |
|
104 | pattern='/{repo_name:.*?[^/]}/files/{commit_id}/{f_path:.*}', repo_route=True) | |
105 | config.add_route( |
|
105 | config.add_route( | |
106 | name='repo_files:default_path', |
|
106 | name='repo_files:default_path', | |
107 | pattern='/{repo_name:.*?[^/]}/files/{commit_id}/', repo_route=True) |
|
107 | pattern='/{repo_name:.*?[^/]}/files/{commit_id}/', repo_route=True) | |
108 | config.add_route( |
|
108 | config.add_route( | |
109 | name='repo_files:default_commit', |
|
109 | name='repo_files:default_commit', | |
110 | pattern='/{repo_name:.*?[^/]}/files', repo_route=True) |
|
110 | pattern='/{repo_name:.*?[^/]}/files', repo_route=True) | |
111 |
|
111 | |||
112 | config.add_route( |
|
112 | config.add_route( | |
113 | name='repo_files:rendered', |
|
113 | name='repo_files:rendered', | |
114 | pattern='/{repo_name:.*?[^/]}/render/{commit_id}/{f_path:.*}', repo_route=True) |
|
114 | pattern='/{repo_name:.*?[^/]}/render/{commit_id}/{f_path:.*}', repo_route=True) | |
115 |
|
115 | |||
116 | config.add_route( |
|
116 | config.add_route( | |
117 | name='repo_files:annotated', |
|
117 | name='repo_files:annotated', | |
118 | pattern='/{repo_name:.*?[^/]}/annotate/{commit_id}/{f_path:.*}', repo_route=True) |
|
118 | pattern='/{repo_name:.*?[^/]}/annotate/{commit_id}/{f_path:.*}', repo_route=True) | |
119 | config.add_route( |
|
119 | config.add_route( | |
120 | name='repo_files:annotated_previous', |
|
120 | name='repo_files:annotated_previous', | |
121 | pattern='/{repo_name:.*?[^/]}/annotate-previous/{commit_id}/{f_path:.*}', repo_route=True) |
|
121 | pattern='/{repo_name:.*?[^/]}/annotate-previous/{commit_id}/{f_path:.*}', repo_route=True) | |
122 |
|
122 | |||
123 | config.add_route( |
|
123 | config.add_route( | |
124 | name='repo_nodetree_full', |
|
124 | name='repo_nodetree_full', | |
125 | pattern='/{repo_name:.*?[^/]}/nodetree_full/{commit_id}/{f_path:.*}', repo_route=True) |
|
125 | pattern='/{repo_name:.*?[^/]}/nodetree_full/{commit_id}/{f_path:.*}', repo_route=True) | |
126 | config.add_route( |
|
126 | config.add_route( | |
127 | name='repo_nodetree_full:default_path', |
|
127 | name='repo_nodetree_full:default_path', | |
128 | pattern='/{repo_name:.*?[^/]}/nodetree_full/{commit_id}/', repo_route=True) |
|
128 | pattern='/{repo_name:.*?[^/]}/nodetree_full/{commit_id}/', repo_route=True) | |
129 |
|
129 | |||
130 | config.add_route( |
|
130 | config.add_route( | |
131 | name='repo_files_nodelist', |
|
131 | name='repo_files_nodelist', | |
132 | pattern='/{repo_name:.*?[^/]}/nodelist/{commit_id}/{f_path:.*}', repo_route=True) |
|
132 | pattern='/{repo_name:.*?[^/]}/nodelist/{commit_id}/{f_path:.*}', repo_route=True) | |
133 |
|
133 | |||
134 | config.add_route( |
|
134 | config.add_route( | |
135 | name='repo_file_raw', |
|
135 | name='repo_file_raw', | |
136 | pattern='/{repo_name:.*?[^/]}/raw/{commit_id}/{f_path:.*}', repo_route=True) |
|
136 | pattern='/{repo_name:.*?[^/]}/raw/{commit_id}/{f_path:.*}', repo_route=True) | |
137 |
|
137 | |||
138 | config.add_route( |
|
138 | config.add_route( | |
139 | name='repo_file_download', |
|
139 | name='repo_file_download', | |
140 | pattern='/{repo_name:.*?[^/]}/download/{commit_id}/{f_path:.*}', repo_route=True) |
|
140 | pattern='/{repo_name:.*?[^/]}/download/{commit_id}/{f_path:.*}', repo_route=True) | |
141 | config.add_route( # backward compat to keep old links working |
|
141 | config.add_route( # backward compat to keep old links working | |
142 | name='repo_file_download:legacy', |
|
142 | name='repo_file_download:legacy', | |
143 | pattern='/{repo_name:.*?[^/]}/rawfile/{commit_id}/{f_path:.*}', |
|
143 | pattern='/{repo_name:.*?[^/]}/rawfile/{commit_id}/{f_path:.*}', | |
144 | repo_route=True) |
|
144 | repo_route=True) | |
145 |
|
145 | |||
146 | config.add_route( |
|
146 | config.add_route( | |
147 | name='repo_file_history', |
|
147 | name='repo_file_history', | |
148 | pattern='/{repo_name:.*?[^/]}/history/{commit_id}/{f_path:.*}', repo_route=True) |
|
148 | pattern='/{repo_name:.*?[^/]}/history/{commit_id}/{f_path:.*}', repo_route=True) | |
149 |
|
149 | |||
150 | config.add_route( |
|
150 | config.add_route( | |
151 | name='repo_file_authors', |
|
151 | name='repo_file_authors', | |
152 | pattern='/{repo_name:.*?[^/]}/authors/{commit_id}/{f_path:.*}', repo_route=True) |
|
152 | pattern='/{repo_name:.*?[^/]}/authors/{commit_id}/{f_path:.*}', repo_route=True) | |
153 |
|
153 | |||
154 | config.add_route( |
|
154 | config.add_route( | |
155 | name='repo_files_remove_file', |
|
155 | name='repo_files_remove_file', | |
156 | pattern='/{repo_name:.*?[^/]}/remove_file/{commit_id}/{f_path:.*}', |
|
156 | pattern='/{repo_name:.*?[^/]}/remove_file/{commit_id}/{f_path:.*}', | |
157 | repo_route=True) |
|
157 | repo_route=True) | |
158 | config.add_route( |
|
158 | config.add_route( | |
159 | name='repo_files_delete_file', |
|
159 | name='repo_files_delete_file', | |
160 | pattern='/{repo_name:.*?[^/]}/delete_file/{commit_id}/{f_path:.*}', |
|
160 | pattern='/{repo_name:.*?[^/]}/delete_file/{commit_id}/{f_path:.*}', | |
161 | repo_route=True) |
|
161 | repo_route=True) | |
162 | config.add_route( |
|
162 | config.add_route( | |
163 | name='repo_files_edit_file', |
|
163 | name='repo_files_edit_file', | |
164 | pattern='/{repo_name:.*?[^/]}/edit_file/{commit_id}/{f_path:.*}', |
|
164 | pattern='/{repo_name:.*?[^/]}/edit_file/{commit_id}/{f_path:.*}', | |
165 | repo_route=True) |
|
165 | repo_route=True) | |
166 | config.add_route( |
|
166 | config.add_route( | |
167 | name='repo_files_update_file', |
|
167 | name='repo_files_update_file', | |
168 | pattern='/{repo_name:.*?[^/]}/update_file/{commit_id}/{f_path:.*}', |
|
168 | pattern='/{repo_name:.*?[^/]}/update_file/{commit_id}/{f_path:.*}', | |
169 | repo_route=True) |
|
169 | repo_route=True) | |
170 | config.add_route( |
|
170 | config.add_route( | |
171 | name='repo_files_add_file', |
|
171 | name='repo_files_add_file', | |
172 | pattern='/{repo_name:.*?[^/]}/add_file/{commit_id}/{f_path:.*}', |
|
172 | pattern='/{repo_name:.*?[^/]}/add_file/{commit_id}/{f_path:.*}', | |
173 | repo_route=True) |
|
173 | repo_route=True) | |
174 | config.add_route( |
|
174 | config.add_route( | |
175 | name='repo_files_create_file', |
|
175 | name='repo_files_create_file', | |
176 | pattern='/{repo_name:.*?[^/]}/create_file/{commit_id}/{f_path:.*}', |
|
176 | pattern='/{repo_name:.*?[^/]}/create_file/{commit_id}/{f_path:.*}', | |
177 | repo_route=True) |
|
177 | repo_route=True) | |
178 |
|
178 | |||
179 | # Refs data |
|
179 | # Refs data | |
180 | config.add_route( |
|
180 | config.add_route( | |
181 | name='repo_refs_data', |
|
181 | name='repo_refs_data', | |
182 | pattern='/{repo_name:.*?[^/]}/refs-data', repo_route=True) |
|
182 | pattern='/{repo_name:.*?[^/]}/refs-data', repo_route=True) | |
183 |
|
183 | |||
184 | config.add_route( |
|
184 | config.add_route( | |
185 | name='repo_refs_changelog_data', |
|
185 | name='repo_refs_changelog_data', | |
186 | pattern='/{repo_name:.*?[^/]}/refs-data-changelog', repo_route=True) |
|
186 | pattern='/{repo_name:.*?[^/]}/refs-data-changelog', repo_route=True) | |
187 |
|
187 | |||
188 | config.add_route( |
|
188 | config.add_route( | |
189 | name='repo_stats', |
|
189 | name='repo_stats', | |
190 | pattern='/{repo_name:.*?[^/]}/repo_stats/{commit_id}', repo_route=True) |
|
190 | pattern='/{repo_name:.*?[^/]}/repo_stats/{commit_id}', repo_route=True) | |
191 |
|
191 | |||
192 | # Changelog |
|
192 | # Changelog | |
193 | config.add_route( |
|
193 | config.add_route( | |
194 | name='repo_changelog', |
|
194 | name='repo_changelog', | |
195 | pattern='/{repo_name:.*?[^/]}/changelog', repo_route=True) |
|
195 | pattern='/{repo_name:.*?[^/]}/changelog', repo_route=True) | |
196 | config.add_route( |
|
196 | config.add_route( | |
197 | name='repo_changelog_file', |
|
197 | name='repo_changelog_file', | |
198 | pattern='/{repo_name:.*?[^/]}/changelog/{commit_id}/{f_path:.*}', repo_route=True) |
|
198 | pattern='/{repo_name:.*?[^/]}/changelog/{commit_id}/{f_path:.*}', repo_route=True) | |
199 | config.add_route( |
|
199 | config.add_route( | |
200 | name='repo_changelog_elements', |
|
200 | name='repo_changelog_elements', | |
201 | pattern='/{repo_name:.*?[^/]}/changelog_elements', repo_route=True) |
|
201 | pattern='/{repo_name:.*?[^/]}/changelog_elements', repo_route=True) | |
202 | config.add_route( |
|
202 | config.add_route( | |
203 | name='repo_changelog_elements_file', |
|
203 | name='repo_changelog_elements_file', | |
204 | pattern='/{repo_name:.*?[^/]}/changelog_elements/{commit_id}/{f_path:.*}', repo_route=True) |
|
204 | pattern='/{repo_name:.*?[^/]}/changelog_elements/{commit_id}/{f_path:.*}', repo_route=True) | |
205 |
|
205 | |||
206 | # Compare |
|
206 | # Compare | |
207 | config.add_route( |
|
207 | config.add_route( | |
208 | name='repo_compare_select', |
|
208 | name='repo_compare_select', | |
209 | pattern='/{repo_name:.*?[^/]}/compare', repo_route=True) |
|
209 | pattern='/{repo_name:.*?[^/]}/compare', repo_route=True) | |
210 |
|
210 | |||
211 | config.add_route( |
|
211 | config.add_route( | |
212 | name='repo_compare', |
|
212 | name='repo_compare', | |
213 | pattern='/{repo_name:.*?[^/]}/compare/{source_ref_type}@{source_ref:.*?}...{target_ref_type}@{target_ref:.*?}', repo_route=True) |
|
213 | pattern='/{repo_name:.*?[^/]}/compare/{source_ref_type}@{source_ref:.*?}...{target_ref_type}@{target_ref:.*?}', repo_route=True) | |
214 |
|
214 | |||
215 | # Tags |
|
215 | # Tags | |
216 | config.add_route( |
|
216 | config.add_route( | |
217 | name='tags_home', |
|
217 | name='tags_home', | |
218 | pattern='/{repo_name:.*?[^/]}/tags', repo_route=True) |
|
218 | pattern='/{repo_name:.*?[^/]}/tags', repo_route=True) | |
219 |
|
219 | |||
220 | # Branches |
|
220 | # Branches | |
221 | config.add_route( |
|
221 | config.add_route( | |
222 | name='branches_home', |
|
222 | name='branches_home', | |
223 | pattern='/{repo_name:.*?[^/]}/branches', repo_route=True) |
|
223 | pattern='/{repo_name:.*?[^/]}/branches', repo_route=True) | |
224 |
|
224 | |||
225 | # Bookmarks |
|
225 | # Bookmarks | |
226 | config.add_route( |
|
226 | config.add_route( | |
227 | name='bookmarks_home', |
|
227 | name='bookmarks_home', | |
228 | pattern='/{repo_name:.*?[^/]}/bookmarks', repo_route=True) |
|
228 | pattern='/{repo_name:.*?[^/]}/bookmarks', repo_route=True) | |
229 |
|
229 | |||
230 | # Forks |
|
230 | # Forks | |
231 | config.add_route( |
|
231 | config.add_route( | |
232 | name='repo_fork_new', |
|
232 | name='repo_fork_new', | |
233 | pattern='/{repo_name:.*?[^/]}/fork', repo_route=True, |
|
233 | pattern='/{repo_name:.*?[^/]}/fork', repo_route=True, | |
234 | repo_accepted_types=['hg', 'git']) |
|
234 | repo_accepted_types=['hg', 'git']) | |
235 |
|
235 | |||
236 | config.add_route( |
|
236 | config.add_route( | |
237 | name='repo_fork_create', |
|
237 | name='repo_fork_create', | |
238 | pattern='/{repo_name:.*?[^/]}/fork/create', repo_route=True, |
|
238 | pattern='/{repo_name:.*?[^/]}/fork/create', repo_route=True, | |
239 | repo_accepted_types=['hg', 'git']) |
|
239 | repo_accepted_types=['hg', 'git']) | |
240 |
|
240 | |||
241 | config.add_route( |
|
241 | config.add_route( | |
242 | name='repo_forks_show_all', |
|
242 | name='repo_forks_show_all', | |
243 | pattern='/{repo_name:.*?[^/]}/forks', repo_route=True, |
|
243 | pattern='/{repo_name:.*?[^/]}/forks', repo_route=True, | |
244 | repo_accepted_types=['hg', 'git']) |
|
244 | repo_accepted_types=['hg', 'git']) | |
245 | config.add_route( |
|
245 | config.add_route( | |
246 | name='repo_forks_data', |
|
246 | name='repo_forks_data', | |
247 | pattern='/{repo_name:.*?[^/]}/forks/data', repo_route=True, |
|
247 | pattern='/{repo_name:.*?[^/]}/forks/data', repo_route=True, | |
248 | repo_accepted_types=['hg', 'git']) |
|
248 | repo_accepted_types=['hg', 'git']) | |
249 |
|
249 | |||
250 | # Pull Requests |
|
250 | # Pull Requests | |
251 | config.add_route( |
|
251 | config.add_route( | |
252 | name='pullrequest_show', |
|
252 | name='pullrequest_show', | |
253 | pattern='/{repo_name:.*?[^/]}/pull-request/{pull_request_id:\d+}', |
|
253 | pattern='/{repo_name:.*?[^/]}/pull-request/{pull_request_id:\d+}', | |
254 | repo_route=True) |
|
254 | repo_route=True) | |
255 |
|
255 | |||
256 | config.add_route( |
|
256 | config.add_route( | |
257 | name='pullrequest_show_all', |
|
257 | name='pullrequest_show_all', | |
258 | pattern='/{repo_name:.*?[^/]}/pull-request', |
|
258 | pattern='/{repo_name:.*?[^/]}/pull-request', | |
259 | repo_route=True, repo_accepted_types=['hg', 'git']) |
|
259 | repo_route=True, repo_accepted_types=['hg', 'git']) | |
260 |
|
260 | |||
261 | config.add_route( |
|
261 | config.add_route( | |
262 | name='pullrequest_show_all_data', |
|
262 | name='pullrequest_show_all_data', | |
263 | pattern='/{repo_name:.*?[^/]}/pull-request-data', |
|
263 | pattern='/{repo_name:.*?[^/]}/pull-request-data', | |
264 | repo_route=True, repo_accepted_types=['hg', 'git']) |
|
264 | repo_route=True, repo_accepted_types=['hg', 'git']) | |
265 |
|
265 | |||
266 | config.add_route( |
|
266 | config.add_route( | |
267 | name='pullrequest_repo_refs', |
|
267 | name='pullrequest_repo_refs', | |
268 | pattern='/{repo_name:.*?[^/]}/pull-request/refs/{target_repo_name:.*?[^/]}', |
|
268 | pattern='/{repo_name:.*?[^/]}/pull-request/refs/{target_repo_name:.*?[^/]}', | |
269 | repo_route=True) |
|
269 | repo_route=True) | |
270 |
|
270 | |||
271 | config.add_route( |
|
271 | config.add_route( | |
272 | name='pullrequest_repo_destinations', |
|
272 | name='pullrequest_repo_destinations', | |
273 | pattern='/{repo_name:.*?[^/]}/pull-request/repo-destinations', |
|
273 | pattern='/{repo_name:.*?[^/]}/pull-request/repo-destinations', | |
274 | repo_route=True) |
|
274 | repo_route=True) | |
275 |
|
275 | |||
276 | config.add_route( |
|
276 | config.add_route( | |
277 | name='pullrequest_new', |
|
277 | name='pullrequest_new', | |
278 | pattern='/{repo_name:.*?[^/]}/pull-request/new', |
|
278 | pattern='/{repo_name:.*?[^/]}/pull-request/new', | |
279 | repo_route=True, repo_accepted_types=['hg', 'git']) |
|
279 | repo_route=True, repo_accepted_types=['hg', 'git']) | |
280 |
|
280 | |||
281 | config.add_route( |
|
281 | config.add_route( | |
282 | name='pullrequest_create', |
|
282 | name='pullrequest_create', | |
283 | pattern='/{repo_name:.*?[^/]}/pull-request/create', |
|
283 | pattern='/{repo_name:.*?[^/]}/pull-request/create', | |
284 | repo_route=True, repo_accepted_types=['hg', 'git']) |
|
284 | repo_route=True, repo_accepted_types=['hg', 'git']) | |
285 |
|
285 | |||
286 | config.add_route( |
|
286 | config.add_route( | |
287 | name='pullrequest_update', |
|
287 | name='pullrequest_update', | |
288 | pattern='/{repo_name:.*?[^/]}/pull-request/{pull_request_id:\d+}/update', |
|
288 | pattern='/{repo_name:.*?[^/]}/pull-request/{pull_request_id:\d+}/update', | |
289 | repo_route=True) |
|
289 | repo_route=True) | |
290 |
|
290 | |||
291 | config.add_route( |
|
291 | config.add_route( | |
292 | name='pullrequest_merge', |
|
292 | name='pullrequest_merge', | |
293 | pattern='/{repo_name:.*?[^/]}/pull-request/{pull_request_id:\d+}/merge', |
|
293 | pattern='/{repo_name:.*?[^/]}/pull-request/{pull_request_id:\d+}/merge', | |
294 | repo_route=True) |
|
294 | repo_route=True) | |
295 |
|
295 | |||
296 | config.add_route( |
|
296 | config.add_route( | |
297 | name='pullrequest_delete', |
|
297 | name='pullrequest_delete', | |
298 | pattern='/{repo_name:.*?[^/]}/pull-request/{pull_request_id:\d+}/delete', |
|
298 | pattern='/{repo_name:.*?[^/]}/pull-request/{pull_request_id:\d+}/delete', | |
299 | repo_route=True) |
|
299 | repo_route=True) | |
300 |
|
300 | |||
301 | config.add_route( |
|
301 | config.add_route( | |
302 | name='pullrequest_comment_create', |
|
302 | name='pullrequest_comment_create', | |
303 | pattern='/{repo_name:.*?[^/]}/pull-request/{pull_request_id:\d+}/comment', |
|
303 | pattern='/{repo_name:.*?[^/]}/pull-request/{pull_request_id:\d+}/comment', | |
304 | repo_route=True) |
|
304 | repo_route=True) | |
305 |
|
305 | |||
306 | config.add_route( |
|
306 | config.add_route( | |
307 | name='pullrequest_comment_delete', |
|
307 | name='pullrequest_comment_delete', | |
308 | pattern='/{repo_name:.*?[^/]}/pull-request/{pull_request_id:\d+}/comment/{comment_id}/delete', |
|
308 | pattern='/{repo_name:.*?[^/]}/pull-request/{pull_request_id:\d+}/comment/{comment_id}/delete', | |
309 | repo_route=True, repo_accepted_types=['hg', 'git']) |
|
309 | repo_route=True, repo_accepted_types=['hg', 'git']) | |
310 |
|
310 | |||
311 | # Settings |
|
311 | # Settings | |
312 | config.add_route( |
|
312 | config.add_route( | |
313 | name='edit_repo', |
|
313 | name='edit_repo', | |
314 | pattern='/{repo_name:.*?[^/]}/settings', repo_route=True) |
|
314 | pattern='/{repo_name:.*?[^/]}/settings', repo_route=True) | |
315 | # update is POST on edit_repo |
|
315 | # update is POST on edit_repo | |
316 |
|
316 | |||
317 | # Settings advanced |
|
317 | # Settings advanced | |
318 | config.add_route( |
|
318 | config.add_route( | |
319 | name='edit_repo_advanced', |
|
319 | name='edit_repo_advanced', | |
320 | pattern='/{repo_name:.*?[^/]}/settings/advanced', repo_route=True) |
|
320 | pattern='/{repo_name:.*?[^/]}/settings/advanced', repo_route=True) | |
321 | config.add_route( |
|
321 | config.add_route( | |
322 | name='edit_repo_advanced_delete', |
|
322 | name='edit_repo_advanced_delete', | |
323 | pattern='/{repo_name:.*?[^/]}/settings/advanced/delete', repo_route=True) |
|
323 | pattern='/{repo_name:.*?[^/]}/settings/advanced/delete', repo_route=True) | |
324 | config.add_route( |
|
324 | config.add_route( | |
325 | name='edit_repo_advanced_locking', |
|
325 | name='edit_repo_advanced_locking', | |
326 | pattern='/{repo_name:.*?[^/]}/settings/advanced/locking', repo_route=True) |
|
326 | pattern='/{repo_name:.*?[^/]}/settings/advanced/locking', repo_route=True) | |
327 | config.add_route( |
|
327 | config.add_route( | |
328 | name='edit_repo_advanced_journal', |
|
328 | name='edit_repo_advanced_journal', | |
329 | pattern='/{repo_name:.*?[^/]}/settings/advanced/journal', repo_route=True) |
|
329 | pattern='/{repo_name:.*?[^/]}/settings/advanced/journal', repo_route=True) | |
330 | config.add_route( |
|
330 | config.add_route( | |
331 | name='edit_repo_advanced_fork', |
|
331 | name='edit_repo_advanced_fork', | |
332 | pattern='/{repo_name:.*?[^/]}/settings/advanced/fork', repo_route=True) |
|
332 | pattern='/{repo_name:.*?[^/]}/settings/advanced/fork', repo_route=True) | |
333 |
|
333 | |||
|
334 | config.add_route( | |||
|
335 | name='edit_repo_advanced_hooks', | |||
|
336 | pattern='/{repo_name:.*?[^/]}/settings/advanced/hooks', repo_route=True) | |||
|
337 | ||||
334 | # Caches |
|
338 | # Caches | |
335 | config.add_route( |
|
339 | config.add_route( | |
336 | name='edit_repo_caches', |
|
340 | name='edit_repo_caches', | |
337 | pattern='/{repo_name:.*?[^/]}/settings/caches', repo_route=True) |
|
341 | pattern='/{repo_name:.*?[^/]}/settings/caches', repo_route=True) | |
338 |
|
342 | |||
339 | # Permissions |
|
343 | # Permissions | |
340 | config.add_route( |
|
344 | config.add_route( | |
341 | name='edit_repo_perms', |
|
345 | name='edit_repo_perms', | |
342 | pattern='/{repo_name:.*?[^/]}/settings/permissions', repo_route=True) |
|
346 | pattern='/{repo_name:.*?[^/]}/settings/permissions', repo_route=True) | |
343 |
|
347 | |||
344 | # Maintenance |
|
348 | # Maintenance | |
345 | config.add_route( |
|
349 | config.add_route( | |
346 | name='edit_repo_maintenance', |
|
350 | name='edit_repo_maintenance', | |
347 | pattern='/{repo_name:.*?[^/]}/settings/maintenance', repo_route=True) |
|
351 | pattern='/{repo_name:.*?[^/]}/settings/maintenance', repo_route=True) | |
348 |
|
352 | |||
349 | config.add_route( |
|
353 | config.add_route( | |
350 | name='edit_repo_maintenance_execute', |
|
354 | name='edit_repo_maintenance_execute', | |
351 | pattern='/{repo_name:.*?[^/]}/settings/maintenance/execute', repo_route=True) |
|
355 | pattern='/{repo_name:.*?[^/]}/settings/maintenance/execute', repo_route=True) | |
352 |
|
356 | |||
353 | # Fields |
|
357 | # Fields | |
354 | config.add_route( |
|
358 | config.add_route( | |
355 | name='edit_repo_fields', |
|
359 | name='edit_repo_fields', | |
356 | pattern='/{repo_name:.*?[^/]}/settings/fields', repo_route=True) |
|
360 | pattern='/{repo_name:.*?[^/]}/settings/fields', repo_route=True) | |
357 | config.add_route( |
|
361 | config.add_route( | |
358 | name='edit_repo_fields_create', |
|
362 | name='edit_repo_fields_create', | |
359 | pattern='/{repo_name:.*?[^/]}/settings/fields/create', repo_route=True) |
|
363 | pattern='/{repo_name:.*?[^/]}/settings/fields/create', repo_route=True) | |
360 | config.add_route( |
|
364 | config.add_route( | |
361 | name='edit_repo_fields_delete', |
|
365 | name='edit_repo_fields_delete', | |
362 | pattern='/{repo_name:.*?[^/]}/settings/fields/{field_id}/delete', repo_route=True) |
|
366 | pattern='/{repo_name:.*?[^/]}/settings/fields/{field_id}/delete', repo_route=True) | |
363 |
|
367 | |||
364 | # Locking |
|
368 | # Locking | |
365 | config.add_route( |
|
369 | config.add_route( | |
366 | name='repo_edit_toggle_locking', |
|
370 | name='repo_edit_toggle_locking', | |
367 | pattern='/{repo_name:.*?[^/]}/settings/toggle_locking', repo_route=True) |
|
371 | pattern='/{repo_name:.*?[^/]}/settings/toggle_locking', repo_route=True) | |
368 |
|
372 | |||
369 | # Remote |
|
373 | # Remote | |
370 | config.add_route( |
|
374 | config.add_route( | |
371 | name='edit_repo_remote', |
|
375 | name='edit_repo_remote', | |
372 | pattern='/{repo_name:.*?[^/]}/settings/remote', repo_route=True) |
|
376 | pattern='/{repo_name:.*?[^/]}/settings/remote', repo_route=True) | |
373 | config.add_route( |
|
377 | config.add_route( | |
374 | name='edit_repo_remote_pull', |
|
378 | name='edit_repo_remote_pull', | |
375 | pattern='/{repo_name:.*?[^/]}/settings/remote/pull', repo_route=True) |
|
379 | pattern='/{repo_name:.*?[^/]}/settings/remote/pull', repo_route=True) | |
376 | config.add_route( |
|
380 | config.add_route( | |
377 | name='edit_repo_remote_push', |
|
381 | name='edit_repo_remote_push', | |
378 | pattern='/{repo_name:.*?[^/]}/settings/remote/push', repo_route=True) |
|
382 | pattern='/{repo_name:.*?[^/]}/settings/remote/push', repo_route=True) | |
379 |
|
383 | |||
380 | # Statistics |
|
384 | # Statistics | |
381 | config.add_route( |
|
385 | config.add_route( | |
382 | name='edit_repo_statistics', |
|
386 | name='edit_repo_statistics', | |
383 | pattern='/{repo_name:.*?[^/]}/settings/statistics', repo_route=True) |
|
387 | pattern='/{repo_name:.*?[^/]}/settings/statistics', repo_route=True) | |
384 | config.add_route( |
|
388 | config.add_route( | |
385 | name='edit_repo_statistics_reset', |
|
389 | name='edit_repo_statistics_reset', | |
386 | pattern='/{repo_name:.*?[^/]}/settings/statistics/update', repo_route=True) |
|
390 | pattern='/{repo_name:.*?[^/]}/settings/statistics/update', repo_route=True) | |
387 |
|
391 | |||
388 | # Issue trackers |
|
392 | # Issue trackers | |
389 | config.add_route( |
|
393 | config.add_route( | |
390 | name='edit_repo_issuetracker', |
|
394 | name='edit_repo_issuetracker', | |
391 | pattern='/{repo_name:.*?[^/]}/settings/issue_trackers', repo_route=True) |
|
395 | pattern='/{repo_name:.*?[^/]}/settings/issue_trackers', repo_route=True) | |
392 | config.add_route( |
|
396 | config.add_route( | |
393 | name='edit_repo_issuetracker_test', |
|
397 | name='edit_repo_issuetracker_test', | |
394 | pattern='/{repo_name:.*?[^/]}/settings/issue_trackers/test', repo_route=True) |
|
398 | pattern='/{repo_name:.*?[^/]}/settings/issue_trackers/test', repo_route=True) | |
395 | config.add_route( |
|
399 | config.add_route( | |
396 | name='edit_repo_issuetracker_delete', |
|
400 | name='edit_repo_issuetracker_delete', | |
397 | pattern='/{repo_name:.*?[^/]}/settings/issue_trackers/delete', repo_route=True) |
|
401 | pattern='/{repo_name:.*?[^/]}/settings/issue_trackers/delete', repo_route=True) | |
398 | config.add_route( |
|
402 | config.add_route( | |
399 | name='edit_repo_issuetracker_update', |
|
403 | name='edit_repo_issuetracker_update', | |
400 | pattern='/{repo_name:.*?[^/]}/settings/issue_trackers/update', repo_route=True) |
|
404 | pattern='/{repo_name:.*?[^/]}/settings/issue_trackers/update', repo_route=True) | |
401 |
|
405 | |||
402 | # VCS Settings |
|
406 | # VCS Settings | |
403 | config.add_route( |
|
407 | config.add_route( | |
404 | name='edit_repo_vcs', |
|
408 | name='edit_repo_vcs', | |
405 | pattern='/{repo_name:.*?[^/]}/settings/vcs', repo_route=True) |
|
409 | pattern='/{repo_name:.*?[^/]}/settings/vcs', repo_route=True) | |
406 | config.add_route( |
|
410 | config.add_route( | |
407 | name='edit_repo_vcs_update', |
|
411 | name='edit_repo_vcs_update', | |
408 | pattern='/{repo_name:.*?[^/]}/settings/vcs/update', repo_route=True) |
|
412 | pattern='/{repo_name:.*?[^/]}/settings/vcs/update', repo_route=True) | |
409 |
|
413 | |||
410 | # svn pattern |
|
414 | # svn pattern | |
411 | config.add_route( |
|
415 | config.add_route( | |
412 | name='edit_repo_vcs_svn_pattern_delete', |
|
416 | name='edit_repo_vcs_svn_pattern_delete', | |
413 | pattern='/{repo_name:.*?[^/]}/settings/vcs/svn_pattern/delete', repo_route=True) |
|
417 | pattern='/{repo_name:.*?[^/]}/settings/vcs/svn_pattern/delete', repo_route=True) | |
414 |
|
418 | |||
415 | # Repo Review Rules (EE feature) |
|
419 | # Repo Review Rules (EE feature) | |
416 | config.add_route( |
|
420 | config.add_route( | |
417 | name='repo_reviewers', |
|
421 | name='repo_reviewers', | |
418 | pattern='/{repo_name:.*?[^/]}/settings/review/rules', repo_route=True) |
|
422 | pattern='/{repo_name:.*?[^/]}/settings/review/rules', repo_route=True) | |
419 |
|
423 | |||
420 | config.add_route( |
|
424 | config.add_route( | |
421 | name='repo_default_reviewers_data', |
|
425 | name='repo_default_reviewers_data', | |
422 | pattern='/{repo_name:.*?[^/]}/settings/review/default-reviewers', repo_route=True) |
|
426 | pattern='/{repo_name:.*?[^/]}/settings/review/default-reviewers', repo_route=True) | |
423 |
|
427 | |||
424 | # Repo Automation (EE feature) |
|
428 | # Repo Automation (EE feature) | |
425 | config.add_route( |
|
429 | config.add_route( | |
426 | name='repo_automation', |
|
430 | name='repo_automation', | |
427 | pattern='/{repo_name:.*?[^/]}/settings/automation', repo_route=True) |
|
431 | pattern='/{repo_name:.*?[^/]}/settings/automation', repo_route=True) | |
428 |
|
432 | |||
429 | # Strip |
|
433 | # Strip | |
430 | config.add_route( |
|
434 | config.add_route( | |
431 | name='edit_repo_strip', |
|
435 | name='edit_repo_strip', | |
432 | pattern='/{repo_name:.*?[^/]}/settings/strip', repo_route=True) |
|
436 | pattern='/{repo_name:.*?[^/]}/settings/strip', repo_route=True) | |
433 |
|
437 | |||
434 | config.add_route( |
|
438 | config.add_route( | |
435 | name='strip_check', |
|
439 | name='strip_check', | |
436 | pattern='/{repo_name:.*?[^/]}/settings/strip_check', repo_route=True) |
|
440 | pattern='/{repo_name:.*?[^/]}/settings/strip_check', repo_route=True) | |
437 |
|
441 | |||
438 | config.add_route( |
|
442 | config.add_route( | |
439 | name='strip_execute', |
|
443 | name='strip_execute', | |
440 | pattern='/{repo_name:.*?[^/]}/settings/strip_execute', repo_route=True) |
|
444 | pattern='/{repo_name:.*?[^/]}/settings/strip_execute', repo_route=True) | |
441 |
|
445 | |||
442 | # Audit logs |
|
446 | # Audit logs | |
443 | config.add_route( |
|
447 | config.add_route( | |
444 | name='edit_repo_audit_logs', |
|
448 | name='edit_repo_audit_logs', | |
445 | pattern='/{repo_name:.*?[^/]}/settings/audit_logs', repo_route=True) |
|
449 | pattern='/{repo_name:.*?[^/]}/settings/audit_logs', repo_route=True) | |
446 |
|
450 | |||
447 | # ATOM/RSS Feed |
|
451 | # ATOM/RSS Feed | |
448 | config.add_route( |
|
452 | config.add_route( | |
449 | name='rss_feed_home', |
|
453 | name='rss_feed_home', | |
450 | pattern='/{repo_name:.*?[^/]}/feed/rss', repo_route=True) |
|
454 | pattern='/{repo_name:.*?[^/]}/feed/rss', repo_route=True) | |
451 |
|
455 | |||
452 | config.add_route( |
|
456 | config.add_route( | |
453 | name='atom_feed_home', |
|
457 | name='atom_feed_home', | |
454 | pattern='/{repo_name:.*?[^/]}/feed/atom', repo_route=True) |
|
458 | pattern='/{repo_name:.*?[^/]}/feed/atom', repo_route=True) | |
455 |
|
459 | |||
456 | # NOTE(marcink): needs to be at the end for catch-all |
|
460 | # NOTE(marcink): needs to be at the end for catch-all | |
457 | add_route_with_slash( |
|
461 | add_route_with_slash( | |
458 | config, |
|
462 | config, | |
459 | name='repo_summary', |
|
463 | name='repo_summary', | |
460 | pattern='/{repo_name:.*?[^/]}', repo_route=True) |
|
464 | pattern='/{repo_name:.*?[^/]}', repo_route=True) | |
461 |
|
465 | |||
462 | # Scan module for configuration decorators. |
|
466 | # Scan module for configuration decorators. | |
463 | config.scan('.views', ignore='.tests') |
|
467 | config.scan('.views', ignore='.tests') |
@@ -1,233 +1,247 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2011-2018 RhodeCode GmbH |
|
3 | # Copyright (C) 2011-2018 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 | import logging |
|
21 | import logging | |
22 |
|
22 | |||
23 | from pyramid.view import view_config |
|
23 | from pyramid.view import view_config | |
24 | from pyramid.httpexceptions import HTTPFound |
|
24 | from pyramid.httpexceptions import HTTPFound | |
25 |
|
25 | |||
26 | from rhodecode.apps._base import RepoAppView |
|
26 | from rhodecode.apps._base import RepoAppView | |
27 | from rhodecode.lib import helpers as h |
|
27 | from rhodecode.lib import helpers as h | |
28 | from rhodecode.lib import audit_logger |
|
28 | from rhodecode.lib import audit_logger | |
29 | from rhodecode.lib.auth import ( |
|
29 | from rhodecode.lib.auth import ( | |
30 | LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired, |
|
30 | LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired, | |
31 | HasRepoPermissionAny) |
|
31 | HasRepoPermissionAny) | |
32 | from rhodecode.lib.exceptions import AttachedForksError |
|
32 | from rhodecode.lib.exceptions import AttachedForksError | |
33 | from rhodecode.lib.utils2 import safe_int |
|
33 | from rhodecode.lib.utils2 import safe_int | |
34 | from rhodecode.lib.vcs import RepositoryError |
|
34 | from rhodecode.lib.vcs import RepositoryError | |
35 | from rhodecode.model.db import Session, UserFollowing, User, Repository |
|
35 | from rhodecode.model.db import Session, UserFollowing, User, Repository | |
36 | from rhodecode.model.repo import RepoModel |
|
36 | from rhodecode.model.repo import RepoModel | |
37 | from rhodecode.model.scm import ScmModel |
|
37 | from rhodecode.model.scm import ScmModel | |
38 |
|
38 | |||
39 | log = logging.getLogger(__name__) |
|
39 | log = logging.getLogger(__name__) | |
40 |
|
40 | |||
41 |
|
41 | |||
42 | class RepoSettingsView(RepoAppView): |
|
42 | class RepoSettingsView(RepoAppView): | |
43 |
|
43 | |||
44 | def load_default_context(self): |
|
44 | def load_default_context(self): | |
45 | c = self._get_local_tmpl_context() |
|
45 | c = self._get_local_tmpl_context() | |
46 |
|
||||
47 |
|
||||
48 | return c |
|
46 | return c | |
49 |
|
47 | |||
50 | @LoginRequired() |
|
48 | @LoginRequired() | |
51 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
49 | @HasRepoPermissionAnyDecorator('repository.admin') | |
52 | @view_config( |
|
50 | @view_config( | |
53 | route_name='edit_repo_advanced', request_method='GET', |
|
51 | route_name='edit_repo_advanced', request_method='GET', | |
54 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
52 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
55 | def edit_advanced(self): |
|
53 | def edit_advanced(self): | |
56 | c = self.load_default_context() |
|
54 | c = self.load_default_context() | |
57 | c.active = 'advanced' |
|
55 | c.active = 'advanced' | |
58 |
|
56 | |||
59 | c.default_user_id = User.get_default_user().user_id |
|
57 | c.default_user_id = User.get_default_user().user_id | |
60 | c.in_public_journal = UserFollowing.query() \ |
|
58 | c.in_public_journal = UserFollowing.query() \ | |
61 | .filter(UserFollowing.user_id == c.default_user_id) \ |
|
59 | .filter(UserFollowing.user_id == c.default_user_id) \ | |
62 | .filter(UserFollowing.follows_repository == self.db_repo).scalar() |
|
60 | .filter(UserFollowing.follows_repository == self.db_repo).scalar() | |
63 |
|
61 | |||
64 | c.has_origin_repo_read_perm = False |
|
62 | c.has_origin_repo_read_perm = False | |
65 | if self.db_repo.fork: |
|
63 | if self.db_repo.fork: | |
66 | c.has_origin_repo_read_perm = h.HasRepoPermissionAny( |
|
64 | c.has_origin_repo_read_perm = h.HasRepoPermissionAny( | |
67 | 'repository.write', 'repository.read', 'repository.admin')( |
|
65 | 'repository.write', 'repository.read', 'repository.admin')( | |
68 | self.db_repo.fork.repo_name, 'repo set as fork page') |
|
66 | self.db_repo.fork.repo_name, 'repo set as fork page') | |
69 |
|
67 | |||
70 | return self._get_template_context(c) |
|
68 | return self._get_template_context(c) | |
71 |
|
69 | |||
72 | @LoginRequired() |
|
70 | @LoginRequired() | |
73 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
71 | @HasRepoPermissionAnyDecorator('repository.admin') | |
74 | @CSRFRequired() |
|
72 | @CSRFRequired() | |
75 | @view_config( |
|
73 | @view_config( | |
76 | route_name='edit_repo_advanced_delete', request_method='POST', |
|
74 | route_name='edit_repo_advanced_delete', request_method='POST', | |
77 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
75 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
78 | def edit_advanced_delete(self): |
|
76 | def edit_advanced_delete(self): | |
79 | """ |
|
77 | """ | |
80 | Deletes the repository, or shows warnings if deletion is not possible |
|
78 | Deletes the repository, or shows warnings if deletion is not possible | |
81 | because of attached forks or other errors. |
|
79 | because of attached forks or other errors. | |
82 | """ |
|
80 | """ | |
83 | _ = self.request.translate |
|
81 | _ = self.request.translate | |
84 | handle_forks = self.request.POST.get('forks', None) |
|
82 | handle_forks = self.request.POST.get('forks', None) | |
85 |
|
83 | |||
86 | try: |
|
84 | try: | |
87 | _forks = self.db_repo.forks.count() |
|
85 | _forks = self.db_repo.forks.count() | |
88 | if _forks and handle_forks: |
|
86 | if _forks and handle_forks: | |
89 | if handle_forks == 'detach_forks': |
|
87 | if handle_forks == 'detach_forks': | |
90 | handle_forks = 'detach' |
|
88 | handle_forks = 'detach' | |
91 | h.flash(_('Detached %s forks') % _forks, category='success') |
|
89 | h.flash(_('Detached %s forks') % _forks, category='success') | |
92 | elif handle_forks == 'delete_forks': |
|
90 | elif handle_forks == 'delete_forks': | |
93 | handle_forks = 'delete' |
|
91 | handle_forks = 'delete' | |
94 | h.flash(_('Deleted %s forks') % _forks, category='success') |
|
92 | h.flash(_('Deleted %s forks') % _forks, category='success') | |
95 |
|
93 | |||
96 | old_data = self.db_repo.get_api_data() |
|
94 | old_data = self.db_repo.get_api_data() | |
97 | RepoModel().delete(self.db_repo, forks=handle_forks) |
|
95 | RepoModel().delete(self.db_repo, forks=handle_forks) | |
98 |
|
96 | |||
99 | repo = audit_logger.RepoWrap(repo_id=None, |
|
97 | repo = audit_logger.RepoWrap(repo_id=None, | |
100 | repo_name=self.db_repo.repo_name) |
|
98 | repo_name=self.db_repo.repo_name) | |
101 | audit_logger.store_web( |
|
99 | audit_logger.store_web( | |
102 | 'repo.delete', action_data={'old_data': old_data}, |
|
100 | 'repo.delete', action_data={'old_data': old_data}, | |
103 | user=self._rhodecode_user, repo=repo) |
|
101 | user=self._rhodecode_user, repo=repo) | |
104 |
|
102 | |||
105 | ScmModel().mark_for_invalidation(self.db_repo_name, delete=True) |
|
103 | ScmModel().mark_for_invalidation(self.db_repo_name, delete=True) | |
106 | h.flash( |
|
104 | h.flash( | |
107 | _('Deleted repository `%s`') % self.db_repo_name, |
|
105 | _('Deleted repository `%s`') % self.db_repo_name, | |
108 | category='success') |
|
106 | category='success') | |
109 | Session().commit() |
|
107 | Session().commit() | |
110 | except AttachedForksError: |
|
108 | except AttachedForksError: | |
111 | repo_advanced_url = h.route_path( |
|
109 | repo_advanced_url = h.route_path( | |
112 | 'edit_repo_advanced', repo_name=self.db_repo_name, |
|
110 | 'edit_repo_advanced', repo_name=self.db_repo_name, | |
113 | _anchor='advanced-delete') |
|
111 | _anchor='advanced-delete') | |
114 | delete_anchor = h.link_to(_('detach or delete'), repo_advanced_url) |
|
112 | delete_anchor = h.link_to(_('detach or delete'), repo_advanced_url) | |
115 | h.flash(_('Cannot delete `{repo}` it still contains attached forks. ' |
|
113 | h.flash(_('Cannot delete `{repo}` it still contains attached forks. ' | |
116 | 'Try using {delete_or_detach} option.') |
|
114 | 'Try using {delete_or_detach} option.') | |
117 | .format(repo=self.db_repo_name, delete_or_detach=delete_anchor), |
|
115 | .format(repo=self.db_repo_name, delete_or_detach=delete_anchor), | |
118 | category='warning') |
|
116 | category='warning') | |
119 |
|
117 | |||
120 | # redirect to advanced for forks handle action ? |
|
118 | # redirect to advanced for forks handle action ? | |
121 | raise HTTPFound(repo_advanced_url) |
|
119 | raise HTTPFound(repo_advanced_url) | |
122 |
|
120 | |||
123 | except Exception: |
|
121 | except Exception: | |
124 | log.exception("Exception during deletion of repository") |
|
122 | log.exception("Exception during deletion of repository") | |
125 | h.flash(_('An error occurred during deletion of `%s`') |
|
123 | h.flash(_('An error occurred during deletion of `%s`') | |
126 | % self.db_repo_name, category='error') |
|
124 | % self.db_repo_name, category='error') | |
127 | # redirect to advanced for more deletion options |
|
125 | # redirect to advanced for more deletion options | |
128 | raise HTTPFound( |
|
126 | raise HTTPFound( | |
129 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name, |
|
127 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name, | |
130 | _anchor='advanced-delete')) |
|
128 | _anchor='advanced-delete')) | |
131 |
|
129 | |||
132 | raise HTTPFound(h.route_path('home')) |
|
130 | raise HTTPFound(h.route_path('home')) | |
133 |
|
131 | |||
134 | @LoginRequired() |
|
132 | @LoginRequired() | |
135 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
133 | @HasRepoPermissionAnyDecorator('repository.admin') | |
136 | @CSRFRequired() |
|
134 | @CSRFRequired() | |
137 | @view_config( |
|
135 | @view_config( | |
138 | route_name='edit_repo_advanced_journal', request_method='POST', |
|
136 | route_name='edit_repo_advanced_journal', request_method='POST', | |
139 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
137 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
140 | def edit_advanced_journal(self): |
|
138 | def edit_advanced_journal(self): | |
141 | """ |
|
139 | """ | |
142 | Set's this repository to be visible in public journal, |
|
140 | Set's this repository to be visible in public journal, | |
143 | in other words making default user to follow this repo |
|
141 | in other words making default user to follow this repo | |
144 | """ |
|
142 | """ | |
145 | _ = self.request.translate |
|
143 | _ = self.request.translate | |
146 |
|
144 | |||
147 | try: |
|
145 | try: | |
148 | user_id = User.get_default_user().user_id |
|
146 | user_id = User.get_default_user().user_id | |
149 | ScmModel().toggle_following_repo(self.db_repo.repo_id, user_id) |
|
147 | ScmModel().toggle_following_repo(self.db_repo.repo_id, user_id) | |
150 | h.flash(_('Updated repository visibility in public journal'), |
|
148 | h.flash(_('Updated repository visibility in public journal'), | |
151 | category='success') |
|
149 | category='success') | |
152 | Session().commit() |
|
150 | Session().commit() | |
153 | except Exception: |
|
151 | except Exception: | |
154 | h.flash(_('An error occurred during setting this ' |
|
152 | h.flash(_('An error occurred during setting this ' | |
155 | 'repository in public journal'), |
|
153 | 'repository in public journal'), | |
156 | category='error') |
|
154 | category='error') | |
157 |
|
155 | |||
158 | raise HTTPFound( |
|
156 | raise HTTPFound( | |
159 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name)) |
|
157 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name)) | |
160 |
|
158 | |||
161 | @LoginRequired() |
|
159 | @LoginRequired() | |
162 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
160 | @HasRepoPermissionAnyDecorator('repository.admin') | |
163 | @CSRFRequired() |
|
161 | @CSRFRequired() | |
164 | @view_config( |
|
162 | @view_config( | |
165 | route_name='edit_repo_advanced_fork', request_method='POST', |
|
163 | route_name='edit_repo_advanced_fork', request_method='POST', | |
166 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
164 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
167 | def edit_advanced_fork(self): |
|
165 | def edit_advanced_fork(self): | |
168 | """ |
|
166 | """ | |
169 | Mark given repository as a fork of another |
|
167 | Mark given repository as a fork of another | |
170 | """ |
|
168 | """ | |
171 | _ = self.request.translate |
|
169 | _ = self.request.translate | |
172 |
|
170 | |||
173 | new_fork_id = safe_int(self.request.POST.get('id_fork_of')) |
|
171 | new_fork_id = safe_int(self.request.POST.get('id_fork_of')) | |
174 |
|
172 | |||
175 | # valid repo, re-check permissions |
|
173 | # valid repo, re-check permissions | |
176 | if new_fork_id: |
|
174 | if new_fork_id: | |
177 | repo = Repository.get(new_fork_id) |
|
175 | repo = Repository.get(new_fork_id) | |
178 | # ensure we have at least read access to the repo we mark |
|
176 | # ensure we have at least read access to the repo we mark | |
179 | perm_check = HasRepoPermissionAny( |
|
177 | perm_check = HasRepoPermissionAny( | |
180 | 'repository.read', 'repository.write', 'repository.admin') |
|
178 | 'repository.read', 'repository.write', 'repository.admin') | |
181 |
|
179 | |||
182 | if repo and perm_check(repo_name=repo.repo_name): |
|
180 | if repo and perm_check(repo_name=repo.repo_name): | |
183 | new_fork_id = repo.repo_id |
|
181 | new_fork_id = repo.repo_id | |
184 | else: |
|
182 | else: | |
185 | new_fork_id = None |
|
183 | new_fork_id = None | |
186 |
|
184 | |||
187 | try: |
|
185 | try: | |
188 | repo = ScmModel().mark_as_fork( |
|
186 | repo = ScmModel().mark_as_fork( | |
189 | self.db_repo_name, new_fork_id, self._rhodecode_user.user_id) |
|
187 | self.db_repo_name, new_fork_id, self._rhodecode_user.user_id) | |
190 | fork = repo.fork.repo_name if repo.fork else _('Nothing') |
|
188 | fork = repo.fork.repo_name if repo.fork else _('Nothing') | |
191 | Session().commit() |
|
189 | Session().commit() | |
192 | h.flash( |
|
190 | h.flash( | |
193 | _('Marked repo %s as fork of %s') % (self.db_repo_name, fork), |
|
191 | _('Marked repo %s as fork of %s') % (self.db_repo_name, fork), | |
194 | category='success') |
|
192 | category='success') | |
195 | except RepositoryError as e: |
|
193 | except RepositoryError as e: | |
196 | log.exception("Repository Error occurred") |
|
194 | log.exception("Repository Error occurred") | |
197 | h.flash(str(e), category='error') |
|
195 | h.flash(str(e), category='error') | |
198 | except Exception: |
|
196 | except Exception: | |
199 | log.exception("Exception while editing fork") |
|
197 | log.exception("Exception while editing fork") | |
200 | h.flash(_('An error occurred during this operation'), |
|
198 | h.flash(_('An error occurred during this operation'), | |
201 | category='error') |
|
199 | category='error') | |
202 |
|
200 | |||
203 | raise HTTPFound( |
|
201 | raise HTTPFound( | |
204 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name)) |
|
202 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name)) | |
205 |
|
203 | |||
206 | @LoginRequired() |
|
204 | @LoginRequired() | |
207 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
205 | @HasRepoPermissionAnyDecorator('repository.admin') | |
208 | @CSRFRequired() |
|
206 | @CSRFRequired() | |
209 | @view_config( |
|
207 | @view_config( | |
210 | route_name='edit_repo_advanced_locking', request_method='POST', |
|
208 | route_name='edit_repo_advanced_locking', request_method='POST', | |
211 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
209 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
212 | def edit_advanced_locking(self): |
|
210 | def edit_advanced_locking(self): | |
213 | """ |
|
211 | """ | |
214 | Toggle locking of repository |
|
212 | Toggle locking of repository | |
215 | """ |
|
213 | """ | |
216 | _ = self.request.translate |
|
214 | _ = self.request.translate | |
217 | set_lock = self.request.POST.get('set_lock') |
|
215 | set_lock = self.request.POST.get('set_lock') | |
218 | set_unlock = self.request.POST.get('set_unlock') |
|
216 | set_unlock = self.request.POST.get('set_unlock') | |
219 |
|
217 | |||
220 | try: |
|
218 | try: | |
221 | if set_lock: |
|
219 | if set_lock: | |
222 | Repository.lock(self.db_repo, self._rhodecode_user.user_id, |
|
220 | Repository.lock(self.db_repo, self._rhodecode_user.user_id, | |
223 | lock_reason=Repository.LOCK_WEB) |
|
221 | lock_reason=Repository.LOCK_WEB) | |
224 | h.flash(_('Locked repository'), category='success') |
|
222 | h.flash(_('Locked repository'), category='success') | |
225 | elif set_unlock: |
|
223 | elif set_unlock: | |
226 | Repository.unlock(self.db_repo) |
|
224 | Repository.unlock(self.db_repo) | |
227 | h.flash(_('Unlocked repository'), category='success') |
|
225 | h.flash(_('Unlocked repository'), category='success') | |
228 | except Exception as e: |
|
226 | except Exception as e: | |
229 | log.exception("Exception during unlocking") |
|
227 | log.exception("Exception during unlocking") | |
230 | h.flash(_('An error occurred during unlocking'), category='error') |
|
228 | h.flash(_('An error occurred during unlocking'), category='error') | |
231 |
|
229 | |||
232 | raise HTTPFound( |
|
230 | raise HTTPFound( | |
233 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name)) |
|
231 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name)) | |
|
232 | ||||
|
233 | @LoginRequired() | |||
|
234 | @HasRepoPermissionAnyDecorator('repository.admin') | |||
|
235 | @view_config( | |||
|
236 | route_name='edit_repo_advanced_hooks', request_method='GET', | |||
|
237 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |||
|
238 | def edit_advanced_install_hooks(self): | |||
|
239 | """ | |||
|
240 | Install Hooks for repository | |||
|
241 | """ | |||
|
242 | _ = self.request.translate | |||
|
243 | self.load_default_context() | |||
|
244 | self.rhodecode_vcs_repo.install_hooks(force=True) | |||
|
245 | h.flash(_('installed hooks repository'), category='success') | |||
|
246 | raise HTTPFound( | |||
|
247 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name)) |
General Comments 0
You need to be logged in to leave comments.
Login now