##// END OF EJS Templates
ops: added redirect and exception ops view for testing.
marcink -
r1913:edd50f39 default
parent child Browse files
Show More
@@ -1,35 +1,41 b''
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Copyright (C) 2016-2017 RhodeCode GmbH
4 4 #
5 5 # This program is free software: you can redistribute it and/or modify
6 6 # it under the terms of the GNU Affero General Public License, version 3
7 7 # (only), as published by the Free Software Foundation.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU Affero General Public License
15 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16 #
17 17 # This program is dual-licensed. If you wish to learn more about the
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 21 from rhodecode.config.routing import ADMIN_PREFIX
22 22
23 23
24 24 def admin_routes(config):
25 25 config.add_route(
26 26 name='ops_ping',
27 27 pattern='/ping')
28 config.add_route(
29 name='ops_error_test',
30 pattern='/error')
31 config.add_route(
32 name='ops_redirect_test',
33 pattern='/redirect')
28 34
29 35
30 36 def includeme(config):
31 37
32 38 config.include(admin_routes, route_prefix=ADMIN_PREFIX + '/ops')
33 39
34 40 # Scan module for configuration decorators.
35 41 config.scan()
@@ -1,54 +1,77 b''
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Copyright (C) 2016-2017 RhodeCode GmbH
4 4 #
5 5 # This program is free software: you can redistribute it and/or modify
6 6 # it under the terms of the GNU Affero General Public License, version 3
7 7 # (only), as published by the Free Software Foundation.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU Affero General Public License
15 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16 #
17 17 # This program is dual-licensed. If you wish to learn more about the
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 import time
21 22 import logging
22 23
23 24 from pyramid.view import view_config
25 from pyramid.httpexceptions import HTTPFound
24 26
25 27 from rhodecode.apps._base import BaseAppView
26
28 from rhodecode.lib import helpers as h
27 29
28 30 log = logging.getLogger(__name__)
29 31
30 32
31 33 class OpsView(BaseAppView):
32 34
33 35 def load_default_context(self):
34 36 c = self._get_local_tmpl_context()
35 37 c.user = c.auth_user.get_instance()
36 38 self._register_global_c(c)
37 39 return c
38 40
39 41 @view_config(
40 42 route_name='ops_ping', request_method='GET',
41 43 renderer='json_ext')
42 44 def ops_ping(self):
43 45 data = {
44 46 'instance': self.request.registry.settings.get('instance_id'),
45 47 }
46 48 if getattr(self.request, 'user'):
47 49 data.update({
48 50 'caller_ip': self.request.user.ip_addr,
49 51 'caller_name': self.request.user.username,
50 52 })
51 53 return {'ok': data}
52 54
55 @view_config(
56 route_name='ops_error_test', request_method='GET',
57 renderer='json_ext')
58 def ops_error_test(self):
59 """
60 Test exception handling and emails on errors
61 """
62 class TestException(Exception):
63 pass
53 64
65 msg = ('RhodeCode Enterprise test exception. '
66 'Generation time: {}'.format(time.time()))
67 raise TestException(msg)
54 68
69 @view_config(
70 route_name='ops_redirect_test', request_method='GET',
71 renderer='json_ext')
72 def ops_redirect_test(self):
73 """
74 Test redirect handling
75 """
76 redirect_to = self.request.GET.get('to') or h.route_path('home')
77 raise HTTPFound(redirect_to)
@@ -1,176 +1,178 b''
1 1
2 2 /******************************************************************************
3 3 * *
4 4 * DO NOT CHANGE THIS FILE MANUALLY *
5 5 * *
6 6 * *
7 7 * This file is automatically generated when the app starts up with *
8 8 * generate_js_files = true *
9 9 * *
10 10 * To add a route here pass jsroute=True to the route definition in the app *
11 11 * *
12 12 ******************************************************************************/
13 13 function registerRCRoutes() {
14 14 // routes registration
15 15 pyroutes.register('new_repo', '/_admin/create_repository', []);
16 16 pyroutes.register('edit_user', '/_admin/users/%(user_id)s/edit', ['user_id']);
17 17 pyroutes.register('edit_user_group_members', '/_admin/user_groups/%(user_group_id)s/edit/members', ['user_group_id']);
18 18 pyroutes.register('toggle_following', '/_admin/toggle_following', []);
19 19 pyroutes.register('changeset_home', '/%(repo_name)s/changeset/%(revision)s', ['repo_name', 'revision']);
20 20 pyroutes.register('changeset_comment', '/%(repo_name)s/changeset/%(revision)s/comment', ['repo_name', 'revision']);
21 21 pyroutes.register('changeset_comment_preview', '/%(repo_name)s/changeset/comment/preview', ['repo_name']);
22 22 pyroutes.register('changeset_comment_delete', '/%(repo_name)s/changeset/comment/%(comment_id)s/delete', ['repo_name', 'comment_id']);
23 23 pyroutes.register('changeset_info', '/%(repo_name)s/changeset_info/%(revision)s', ['repo_name', 'revision']);
24 24 pyroutes.register('compare_url', '/%(repo_name)s/compare/%(source_ref_type)s@%(source_ref)s...%(target_ref_type)s@%(target_ref)s', ['repo_name', 'source_ref_type', 'source_ref', 'target_ref_type', 'target_ref']);
25 25 pyroutes.register('pullrequest_home', '/%(repo_name)s/pull-request/new', ['repo_name']);
26 26 pyroutes.register('pullrequest', '/%(repo_name)s/pull-request/new', ['repo_name']);
27 27 pyroutes.register('pullrequest_repo_refs', '/%(repo_name)s/pull-request/refs/%(target_repo_name)s', ['repo_name', 'target_repo_name']);
28 28 pyroutes.register('pullrequest_repo_destinations', '/%(repo_name)s/pull-request/repo-destinations', ['repo_name']);
29 29 pyroutes.register('pullrequest_show', '/%(repo_name)s/pull-request/%(pull_request_id)s', ['repo_name', 'pull_request_id']);
30 30 pyroutes.register('pullrequest_update', '/%(repo_name)s/pull-request/%(pull_request_id)s', ['repo_name', 'pull_request_id']);
31 31 pyroutes.register('pullrequest_comment', '/%(repo_name)s/pull-request-comment/%(pull_request_id)s', ['repo_name', 'pull_request_id']);
32 32 pyroutes.register('pullrequest_comment_delete', '/%(repo_name)s/pull-request-comment/%(comment_id)s/delete', ['repo_name', 'comment_id']);
33 33 pyroutes.register('changelog_home', '/%(repo_name)s/changelog', ['repo_name']);
34 34 pyroutes.register('changelog_file_home', '/%(repo_name)s/changelog/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']);
35 35 pyroutes.register('changelog_elements', '/%(repo_name)s/changelog_details', ['repo_name']);
36 36 pyroutes.register('files_home', '/%(repo_name)s/files/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']);
37 37 pyroutes.register('files_history_home', '/%(repo_name)s/history/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']);
38 38 pyroutes.register('files_authors_home', '/%(repo_name)s/authors/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']);
39 39 pyroutes.register('files_annotate_home', '/%(repo_name)s/annotate/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']);
40 40 pyroutes.register('files_annotate_previous', '/%(repo_name)s/annotate-previous/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']);
41 41 pyroutes.register('files_archive_home', '/%(repo_name)s/archive/%(fname)s', ['repo_name', 'fname']);
42 42 pyroutes.register('files_nodelist_home', '/%(repo_name)s/nodelist/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']);
43 43 pyroutes.register('files_nodetree_full', '/%(repo_name)s/nodetree_full/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']);
44 44 pyroutes.register('favicon', '/favicon.ico', []);
45 45 pyroutes.register('robots', '/robots.txt', []);
46 46 pyroutes.register('auth_home', '/_admin/auth*traverse', []);
47 47 pyroutes.register('global_integrations_new', '/_admin/integrations/new', []);
48 48 pyroutes.register('global_integrations_home', '/_admin/integrations', []);
49 49 pyroutes.register('global_integrations_list', '/_admin/integrations/%(integration)s', ['integration']);
50 50 pyroutes.register('global_integrations_create', '/_admin/integrations/%(integration)s/new', ['integration']);
51 51 pyroutes.register('global_integrations_edit', '/_admin/integrations/%(integration)s/%(integration_id)s', ['integration', 'integration_id']);
52 52 pyroutes.register('repo_group_integrations_home', '/%(repo_group_name)s/settings/integrations', ['repo_group_name']);
53 53 pyroutes.register('repo_group_integrations_list', '/%(repo_group_name)s/settings/integrations/%(integration)s', ['repo_group_name', 'integration']);
54 54 pyroutes.register('repo_group_integrations_new', '/%(repo_group_name)s/settings/integrations/new', ['repo_group_name']);
55 55 pyroutes.register('repo_group_integrations_create', '/%(repo_group_name)s/settings/integrations/%(integration)s/new', ['repo_group_name', 'integration']);
56 56 pyroutes.register('repo_group_integrations_edit', '/%(repo_group_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_group_name', 'integration', 'integration_id']);
57 57 pyroutes.register('repo_integrations_home', '/%(repo_name)s/settings/integrations', ['repo_name']);
58 58 pyroutes.register('repo_integrations_list', '/%(repo_name)s/settings/integrations/%(integration)s', ['repo_name', 'integration']);
59 59 pyroutes.register('repo_integrations_new', '/%(repo_name)s/settings/integrations/new', ['repo_name']);
60 60 pyroutes.register('repo_integrations_create', '/%(repo_name)s/settings/integrations/%(integration)s/new', ['repo_name', 'integration']);
61 61 pyroutes.register('repo_integrations_edit', '/%(repo_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_name', 'integration', 'integration_id']);
62 62 pyroutes.register('ops_ping', '/_admin/ops/ping', []);
63 pyroutes.register('ops_error_test', '/_admin/ops/error', []);
64 pyroutes.register('ops_redirect_test', '/_admin/ops/redirect', []);
63 65 pyroutes.register('admin_home', '/_admin', []);
64 66 pyroutes.register('admin_audit_logs', '/_admin/audit_logs', []);
65 67 pyroutes.register('pull_requests_global_0', '/_admin/pull_requests/%(pull_request_id)s', ['pull_request_id']);
66 68 pyroutes.register('pull_requests_global_1', '/_admin/pull-requests/%(pull_request_id)s', ['pull_request_id']);
67 69 pyroutes.register('pull_requests_global', '/_admin/pull-request/%(pull_request_id)s', ['pull_request_id']);
68 70 pyroutes.register('admin_settings_open_source', '/_admin/settings/open_source', []);
69 71 pyroutes.register('admin_settings_vcs_svn_generate_cfg', '/_admin/settings/vcs/svn_generate_cfg', []);
70 72 pyroutes.register('admin_settings_system', '/_admin/settings/system', []);
71 73 pyroutes.register('admin_settings_system_update', '/_admin/settings/system/updates', []);
72 74 pyroutes.register('admin_settings_sessions', '/_admin/settings/sessions', []);
73 75 pyroutes.register('admin_settings_sessions_cleanup', '/_admin/settings/sessions/cleanup', []);
74 76 pyroutes.register('admin_settings_process_management', '/_admin/settings/process_management', []);
75 77 pyroutes.register('admin_settings_process_management_signal', '/_admin/settings/process_management/signal', []);
76 78 pyroutes.register('admin_permissions_ips', '/_admin/permissions/ips', []);
77 79 pyroutes.register('users', '/_admin/users', []);
78 80 pyroutes.register('users_data', '/_admin/users_data', []);
79 81 pyroutes.register('edit_user_auth_tokens', '/_admin/users/%(user_id)s/edit/auth_tokens', ['user_id']);
80 82 pyroutes.register('edit_user_auth_tokens_add', '/_admin/users/%(user_id)s/edit/auth_tokens/new', ['user_id']);
81 83 pyroutes.register('edit_user_auth_tokens_delete', '/_admin/users/%(user_id)s/edit/auth_tokens/delete', ['user_id']);
82 84 pyroutes.register('edit_user_emails', '/_admin/users/%(user_id)s/edit/emails', ['user_id']);
83 85 pyroutes.register('edit_user_emails_add', '/_admin/users/%(user_id)s/edit/emails/new', ['user_id']);
84 86 pyroutes.register('edit_user_emails_delete', '/_admin/users/%(user_id)s/edit/emails/delete', ['user_id']);
85 87 pyroutes.register('edit_user_ips', '/_admin/users/%(user_id)s/edit/ips', ['user_id']);
86 88 pyroutes.register('edit_user_ips_add', '/_admin/users/%(user_id)s/edit/ips/new', ['user_id']);
87 89 pyroutes.register('edit_user_ips_delete', '/_admin/users/%(user_id)s/edit/ips/delete', ['user_id']);
88 90 pyroutes.register('edit_user_groups_management', '/_admin/users/%(user_id)s/edit/groups_management', ['user_id']);
89 91 pyroutes.register('edit_user_groups_management_updates', '/_admin/users/%(user_id)s/edit/edit_user_groups_management/updates', ['user_id']);
90 92 pyroutes.register('edit_user_audit_logs', '/_admin/users/%(user_id)s/edit/audit', ['user_id']);
91 93 pyroutes.register('channelstream_connect', '/_admin/channelstream/connect', []);
92 94 pyroutes.register('channelstream_subscribe', '/_admin/channelstream/subscribe', []);
93 95 pyroutes.register('channelstream_proxy', '/_channelstream', []);
94 96 pyroutes.register('login', '/_admin/login', []);
95 97 pyroutes.register('logout', '/_admin/logout', []);
96 98 pyroutes.register('register', '/_admin/register', []);
97 99 pyroutes.register('reset_password', '/_admin/password_reset', []);
98 100 pyroutes.register('reset_password_confirmation', '/_admin/password_reset_confirmation', []);
99 101 pyroutes.register('home', '/', []);
100 102 pyroutes.register('user_autocomplete_data', '/_users', []);
101 103 pyroutes.register('user_group_autocomplete_data', '/_user_groups', []);
102 104 pyroutes.register('repo_list_data', '/_repos', []);
103 105 pyroutes.register('goto_switcher_data', '/_goto_data', []);
104 106 pyroutes.register('repo_summary_explicit', '/%(repo_name)s/summary', ['repo_name']);
105 107 pyroutes.register('repo_summary_commits', '/%(repo_name)s/summary-commits', ['repo_name']);
106 108 pyroutes.register('repo_commit', '/%(repo_name)s/changeset/%(commit_id)s', ['repo_name', 'commit_id']);
107 109 pyroutes.register('repo_refs_data', '/%(repo_name)s/refs-data', ['repo_name']);
108 110 pyroutes.register('repo_refs_changelog_data', '/%(repo_name)s/refs-data-changelog', ['repo_name']);
109 111 pyroutes.register('repo_stats', '/%(repo_name)s/repo_stats/%(commit_id)s', ['repo_name', 'commit_id']);
110 112 pyroutes.register('tags_home', '/%(repo_name)s/tags', ['repo_name']);
111 113 pyroutes.register('branches_home', '/%(repo_name)s/branches', ['repo_name']);
112 114 pyroutes.register('bookmarks_home', '/%(repo_name)s/bookmarks', ['repo_name']);
113 115 pyroutes.register('pullrequest_show', '/%(repo_name)s/pull-request/%(pull_request_id)s', ['repo_name', 'pull_request_id']);
114 116 pyroutes.register('pullrequest_show_all', '/%(repo_name)s/pull-request', ['repo_name']);
115 117 pyroutes.register('pullrequest_show_all_data', '/%(repo_name)s/pull-request-data', ['repo_name']);
116 118 pyroutes.register('changeset_home', '/%(repo_name)s/changeset/%(revision)s', ['repo_name', 'revision']);
117 119 pyroutes.register('changeset_children', '/%(repo_name)s/changeset_children/%(revision)s', ['repo_name', 'revision']);
118 120 pyroutes.register('changeset_parents', '/%(repo_name)s/changeset_parents/%(revision)s', ['repo_name', 'revision']);
119 121 pyroutes.register('edit_repo', '/%(repo_name)s/settings', ['repo_name']);
120 122 pyroutes.register('edit_repo_advanced', '/%(repo_name)s/settings/advanced', ['repo_name']);
121 123 pyroutes.register('edit_repo_advanced_delete', '/%(repo_name)s/settings/advanced/delete', ['repo_name']);
122 124 pyroutes.register('edit_repo_advanced_locking', '/%(repo_name)s/settings/advanced/locking', ['repo_name']);
123 125 pyroutes.register('edit_repo_advanced_journal', '/%(repo_name)s/settings/advanced/journal', ['repo_name']);
124 126 pyroutes.register('edit_repo_advanced_fork', '/%(repo_name)s/settings/advanced/fork', ['repo_name']);
125 127 pyroutes.register('edit_repo_caches', '/%(repo_name)s/settings/caches', ['repo_name']);
126 128 pyroutes.register('edit_repo_perms', '/%(repo_name)s/settings/permissions', ['repo_name']);
127 129 pyroutes.register('repo_reviewers', '/%(repo_name)s/settings/review/rules', ['repo_name']);
128 130 pyroutes.register('repo_default_reviewers_data', '/%(repo_name)s/settings/review/default-reviewers', ['repo_name']);
129 131 pyroutes.register('repo_maintenance', '/%(repo_name)s/settings/maintenance', ['repo_name']);
130 132 pyroutes.register('repo_maintenance_execute', '/%(repo_name)s/settings/maintenance/execute', ['repo_name']);
131 133 pyroutes.register('strip', '/%(repo_name)s/settings/strip', ['repo_name']);
132 134 pyroutes.register('strip_check', '/%(repo_name)s/settings/strip_check', ['repo_name']);
133 135 pyroutes.register('strip_execute', '/%(repo_name)s/settings/strip_execute', ['repo_name']);
134 136 pyroutes.register('rss_feed_home', '/%(repo_name)s/feed/rss', ['repo_name']);
135 137 pyroutes.register('atom_feed_home', '/%(repo_name)s/feed/atom', ['repo_name']);
136 138 pyroutes.register('repo_summary', '/%(repo_name)s', ['repo_name']);
137 139 pyroutes.register('repo_summary_slash', '/%(repo_name)s/', ['repo_name']);
138 140 pyroutes.register('repo_group_home', '/%(repo_group_name)s', ['repo_group_name']);
139 141 pyroutes.register('repo_group_home_slash', '/%(repo_group_name)s/', ['repo_group_name']);
140 142 pyroutes.register('search', '/_admin/search', []);
141 143 pyroutes.register('search_repo', '/%(repo_name)s/search', ['repo_name']);
142 144 pyroutes.register('user_profile', '/_profiles/%(username)s', ['username']);
143 145 pyroutes.register('my_account_profile', '/_admin/my_account/profile', []);
144 146 pyroutes.register('my_account_edit', '/_admin/my_account/edit', []);
145 147 pyroutes.register('my_account_update', '/_admin/my_account/update', []);
146 148 pyroutes.register('my_account_password', '/_admin/my_account/password', []);
147 149 pyroutes.register('my_account_password_update', '/_admin/my_account/password', []);
148 150 pyroutes.register('my_account_auth_tokens', '/_admin/my_account/auth_tokens', []);
149 151 pyroutes.register('my_account_auth_tokens_add', '/_admin/my_account/auth_tokens/new', []);
150 152 pyroutes.register('my_account_auth_tokens_delete', '/_admin/my_account/auth_tokens/delete', []);
151 153 pyroutes.register('my_account_emails', '/_admin/my_account/emails', []);
152 154 pyroutes.register('my_account_emails_add', '/_admin/my_account/emails/new', []);
153 155 pyroutes.register('my_account_emails_delete', '/_admin/my_account/emails/delete', []);
154 156 pyroutes.register('my_account_repos', '/_admin/my_account/repos', []);
155 157 pyroutes.register('my_account_watched', '/_admin/my_account/watched', []);
156 158 pyroutes.register('my_account_perms', '/_admin/my_account/perms', []);
157 159 pyroutes.register('my_account_notifications', '/_admin/my_account/notifications', []);
158 160 pyroutes.register('my_account_notifications_toggle_visibility', '/_admin/my_account/toggle_visibility', []);
159 161 pyroutes.register('my_account_pullrequests', '/_admin/my_account/pull_requests', []);
160 162 pyroutes.register('my_account_pullrequests_data', '/_admin/my_account/pull_requests/data', []);
161 163 pyroutes.register('my_account_notifications_test_channelstream', '/_admin/my_account/test_channelstream', []);
162 164 pyroutes.register('gists_show', '/_admin/gists', []);
163 165 pyroutes.register('gists_new', '/_admin/gists/new', []);
164 166 pyroutes.register('gists_create', '/_admin/gists/create', []);
165 167 pyroutes.register('gist_show', '/_admin/gists/%(gist_id)s', ['gist_id']);
166 168 pyroutes.register('gist_delete', '/_admin/gists/%(gist_id)s/delete', ['gist_id']);
167 169 pyroutes.register('gist_edit', '/_admin/gists/%(gist_id)s/edit', ['gist_id']);
168 170 pyroutes.register('gist_edit_check_revision', '/_admin/gists/%(gist_id)s/edit/check_revision', ['gist_id']);
169 171 pyroutes.register('gist_update', '/_admin/gists/%(gist_id)s/update', ['gist_id']);
170 172 pyroutes.register('gist_show_rev', '/_admin/gists/%(gist_id)s/%(revision)s', ['gist_id', 'revision']);
171 173 pyroutes.register('gist_show_formatted', '/_admin/gists/%(gist_id)s/%(revision)s/%(format)s', ['gist_id', 'revision', 'format']);
172 174 pyroutes.register('gist_show_formatted_path', '/_admin/gists/%(gist_id)s/%(revision)s/%(format)s/%(f_path)s', ['gist_id', 'revision', 'format', 'f_path']);
173 175 pyroutes.register('debug_style_home', '/_admin/debug_style', []);
174 176 pyroutes.register('debug_style_template', '/_admin/debug_style/t/%(t_path)s', ['t_path']);
175 177 pyroutes.register('apiv2', '/_admin/api', []);
176 178 }
General Comments 0
You need to be logged in to leave comments. Login now