##// END OF EJS Templates
whitespace cleanup
marcink -
r2973:9937afa7 beta
parent child Browse files
Show More
@@ -1,31 +1,31 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 rhodecode.lib.middleware.errormator
3 rhodecode.lib.middleware.errormator
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
5
6 middleware to handle errormator publishing of errors
6 middleware to handle errormator publishing of errors
7
7
8 :created_on: October 18, 2012
8 :created_on: October 18, 2012
9 :author: marcink
9 :author: marcink
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
11 :license: GPLv3, see COPYING for more details.
12 """
12 """
13 # This program is free software: you can redistribute it and/or modify
13 # This program is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation, either version 3 of the License, or
15 # the Free Software Foundation, either version 3 of the License, or
16 # (at your option) any later version.
16 # (at your option) any later version.
17 #
17 #
18 # This program is distributed in the hope that it will be useful,
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
21 # GNU General Public License for more details.
22 #
22 #
23 # You should have received a copy of the GNU General Public License
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25
25
26 try:
26 try:
27 from errormator_client import make_errormator_middleware
27 from errormator_client import make_errormator_middleware
28 except ImportError:
28 except ImportError:
29 Errormator = None
29 Errormator = None
30 else:
30 else:
31 Errormator = make_errormator_middleware No newline at end of file
31 Errormator = make_errormator_middleware
@@ -1,47 +1,47 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 rhodecode.lib.middleware.sentry
3 rhodecode.lib.middleware.sentry
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
5
6 middleware to handle sentry/raven publishing of errors
6 middleware to handle sentry/raven publishing of errors
7
7
8 :created_on: September 18, 2012
8 :created_on: September 18, 2012
9 :author: marcink
9 :author: marcink
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
11 :license: GPLv3, see COPYING for more details.
12 """
12 """
13 # This program is free software: you can redistribute it and/or modify
13 # This program is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation, either version 3 of the License, or
15 # the Free Software Foundation, either version 3 of the License, or
16 # (at your option) any later version.
16 # (at your option) any later version.
17 #
17 #
18 # This program is distributed in the hope that it will be useful,
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
21 # GNU General Public License for more details.
22 #
22 #
23 # You should have received a copy of the GNU General Public License
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25
25
26 try:
26 try:
27 from raven.base import Client
27 from raven.base import Client
28 from raven.contrib.pylons import list_from_setting
28 from raven.contrib.pylons import list_from_setting
29 from raven.middleware import Sentry as Middleware
29 from raven.middleware import Sentry as Middleware
30 except ImportError:
30 except ImportError:
31 Sentry = None
31 Sentry = None
32 else:
32 else:
33 class Sentry(Middleware):
33 class Sentry(Middleware):
34 def __init__(self, app, config, client_cls=Client):
34 def __init__(self, app, config, client_cls=Client):
35 client = client_cls(
35 client = client_cls(
36 dsn=config.get('sentry.dsn'),
36 dsn=config.get('sentry.dsn'),
37 servers=list_from_setting(config, 'sentry.servers'),
37 servers=list_from_setting(config, 'sentry.servers'),
38 name=config.get('sentry.name'),
38 name=config.get('sentry.name'),
39 key=config.get('sentry.key'),
39 key=config.get('sentry.key'),
40 public_key=config.get('sentry.public_key'),
40 public_key=config.get('sentry.public_key'),
41 secret_key=config.get('sentry.secret_key'),
41 secret_key=config.get('sentry.secret_key'),
42 project=config.get('sentry.project'),
42 project=config.get('sentry.project'),
43 site=config.get('sentry.site'),
43 site=config.get('sentry.site'),
44 include_paths=list_from_setting(config, 'sentry.include_paths'),
44 include_paths=list_from_setting(config, 'sentry.include_paths'),
45 exclude_paths=list_from_setting(config, 'sentry.exclude_paths'),
45 exclude_paths=list_from_setting(config, 'sentry.exclude_paths'),
46 )
46 )
47 super(Sentry, self).__init__(app, client) No newline at end of file
47 super(Sentry, self).__init__(app, client)
@@ -1,47 +1,47 b''
1 %if c.user_repos:
1 %if c.user_repos:
2 <div id='repos_list_wrap' class="yui-skin-sam">
2 <div id='repos_list_wrap' class="yui-skin-sam">
3 <table id="repos_list">
3 <table id="repos_list">
4 <thead>
4 <thead>
5 <tr>
5 <tr>
6 <th></th>
6 <th></th>
7 <th class="left">${_('Name')}</th>
7 <th class="left">${_('Name')}</th>
8 <th class="left">${_('Revision')}</th>
8 <th class="left">${_('Revision')}</th>
9 <th class="left">${_('Action')}</th>
9 <th class="left">${_('Action')}</th>
10 <th class="left">${_('Action')}</th>
10 <th class="left">${_('Action')}</th>
11 </thead>
11 </thead>
12 <tbody>
12 <tbody>
13 <%namespace name="dt" file="/data_table/_dt_elements.html"/>
13 <%namespace name="dt" file="/data_table/_dt_elements.html"/>
14 %for repo in c.user_repos:
14 %for repo in c.user_repos:
15 <tr>
15 <tr>
16 ##QUICK MENU
16 ##QUICK MENU
17 <td class="quick_repo_menu">
17 <td class="quick_repo_menu">
18 ${dt.quick_menu(repo['name'])}
18 ${dt.quick_menu(repo['name'])}
19 </td>
19 </td>
20 ##REPO NAME AND ICONS
20 ##REPO NAME AND ICONS
21 <td class="reponame">
21 <td class="reponame">
22 ${dt.repo_name(repo['name'],repo['dbrepo']['repo_type'],repo['dbrepo']['private'],h.AttributeDict(repo['dbrepo_fork']))}
22 ${dt.repo_name(repo['name'],repo['dbrepo']['repo_type'],repo['dbrepo']['private'],h.AttributeDict(repo['dbrepo_fork']))}
23 </td>
23 </td>
24 ##LAST REVISION
24 ##LAST REVISION
25 <td>
25 <td>
26 ${dt.revision(repo['name'],repo['rev'],repo['tip'],repo['author'],repo['last_msg'])}
26 ${dt.revision(repo['name'],repo['rev'],repo['tip'],repo['author'],repo['last_msg'])}
27 </td>
27 </td>
28 ##
28 ##
29 <td><a href="${h.url('repo_settings_home',repo_name=repo['name'])}" title="${_('edit')}"><img class="icon" alt="${_('private')}" src="${h.url('/images/icons/application_form_edit.png')}"/></a></td>
29 <td><a href="${h.url('repo_settings_home',repo_name=repo['name'])}" title="${_('edit')}"><img class="icon" alt="${_('private')}" src="${h.url('/images/icons/application_form_edit.png')}"/></a></td>
30 <td>
30 <td>
31 ${h.form(url('repo_settings_delete', repo_name=repo['name']),method='delete')}
31 ${h.form(url('repo_settings_delete', repo_name=repo['name']),method='delete')}
32 ${h.submit('remove_%s' % repo['name'],'',class_="delete_icon action_button",onclick="return confirm('"+_('Confirm to delete this repository: %s') % repo['name']+"');")}
32 ${h.submit('remove_%s' % repo['name'],'',class_="delete_icon action_button",onclick="return confirm('"+_('Confirm to delete this repository: %s') % repo['name']+"');")}
33 ${h.end_form()}
33 ${h.end_form()}
34 </td>
34 </td>
35 </tr>
35 </tr>
36 %endfor
36 %endfor
37 </tbody>
37 </tbody>
38 </table>
38 </table>
39 </div>
39 </div>
40 %else:
40 %else:
41 <div style="padding:5px 0px 10px 0px;">
41 <div style="padding:5px 0px 10px 0px;">
42 ${_('No repositories yet')}
42 ${_('No repositories yet')}
43 %if h.HasPermissionAny('hg.admin','hg.create.repository')():
43 %if h.HasPermissionAny('hg.admin','hg.create.repository')():
44 ${h.link_to(_('create one now'),h.url('admin_settings_create_repository'),class_="ui-btn")}
44 ${h.link_to(_('create one now'),h.url('admin_settings_create_repository'),class_="ui-btn")}
45 %endif
45 %endif
46 </div>
46 </div>
47 %endif No newline at end of file
47 %endif
@@ -1,79 +1,78 b''
1 import time
1 import time
2 from rhodecode.tests import *
2 from rhodecode.tests import *
3 from rhodecode.model.meta import Session
3 from rhodecode.model.meta import Session
4 from rhodecode.model.db import User, RhodeCodeSetting, Repository
4 from rhodecode.model.db import User, RhodeCodeSetting, Repository
5 from rhodecode.lib.utils import set_rhodecode_config
5 from rhodecode.lib.utils import set_rhodecode_config
6
6
7
7
8 class TestHomeController(TestController):
8 class TestHomeController(TestController):
9
9
10 def test_index(self):
10 def test_index(self):
11 self.log_user()
11 self.log_user()
12 response = self.app.get(url(controller='home', action='index'))
12 response = self.app.get(url(controller='home', action='index'))
13 #if global permission is set
13 #if global permission is set
14 response.mustcontain('ADD REPOSITORY')
14 response.mustcontain('ADD REPOSITORY')
15 response.mustcontain('href="/%s/summary"' % HG_REPO)
15 response.mustcontain('href="/%s/summary"' % HG_REPO)
16
16
17 response.mustcontain("""<img class="icon" title="Mercurial repository" """
17 response.mustcontain("""<img class="icon" title="Mercurial repository" """
18 """alt="Mercurial repository" src="/images/icons/hg"""
18 """alt="Mercurial repository" src="/images/icons/hg"""
19 """icon.png"/>""")
19 """icon.png"/>""")
20 response.mustcontain("""<img class="icon" title="public repository" """
20 response.mustcontain("""<img class="icon" title="public repository" """
21 """alt="public repository" src="/images/icons/lock_"""
21 """alt="public repository" src="/images/icons/lock_"""
22 """open.png"/>""")
22 """open.png"/>""")
23
23
24 response.mustcontain(
24 response.mustcontain(
25 """<a title="Marcin Kuzminski &amp;lt;marcin@python-works.com&amp;gt;:\n
25 """<a title="Marcin Kuzminski &amp;lt;marcin@python-works.com&amp;gt;:\n
26 merge" class="tooltip" href="/vcs_test_hg/changeset/27cd5cce30c96924232"""
26 merge" class="tooltip" href="/vcs_test_hg/changeset/27cd5cce30c96924232"""
27 """dffcd24178a07ffeb5dfc">r173:27cd5cce30c9</a>"""
27 """dffcd24178a07ffeb5dfc">r173:27cd5cce30c9</a>"""
28 )
28 )
29
29
30 def test_repo_summary_with_anonymous_access_disabled(self):
30 def test_repo_summary_with_anonymous_access_disabled(self):
31 anon = User.get_by_username('default')
31 anon = User.get_by_username('default')
32 anon.active = False
32 anon.active = False
33 Session().add(anon)
33 Session().add(anon)
34 Session().commit()
34 Session().commit()
35 time.sleep(1.5) # must sleep for cache (1s to expire)
35 time.sleep(1.5) # must sleep for cache (1s to expire)
36 try:
36 try:
37 response = self.app.get(url(controller='summary',
37 response = self.app.get(url(controller='summary',
38 action='index', repo_name=HG_REPO),
38 action='index', repo_name=HG_REPO),
39 status=302)
39 status=302)
40 assert 'login' in response.location
40 assert 'login' in response.location
41
41
42 finally:
42 finally:
43 anon = User.get_by_username('default')
43 anon = User.get_by_username('default')
44 anon.active = True
44 anon.active = True
45 Session().add(anon)
45 Session().add(anon)
46 Session().commit()
46 Session().commit()
47
47
48 def test_index_with_anonymous_access_disabled(self):
48 def test_index_with_anonymous_access_disabled(self):
49 anon = User.get_by_username('default')
49 anon = User.get_by_username('default')
50 anon.active = False
50 anon.active = False
51 Session().add(anon)
51 Session().add(anon)
52 Session().commit()
52 Session().commit()
53 time.sleep(1.5) # must sleep for cache (1s to expire)
53 time.sleep(1.5) # must sleep for cache (1s to expire)
54 try:
54 try:
55 response = self.app.get(url(controller='home', action='index'),
55 response = self.app.get(url(controller='home', action='index'),
56 status=302)
56 status=302)
57 assert 'login' in response.location
57 assert 'login' in response.location
58 finally:
58 finally:
59 anon = User.get_by_username('default')
59 anon = User.get_by_username('default')
60 anon.active = True
60 anon.active = True
61 Session().add(anon)
61 Session().add(anon)
62 Session().commit()
62 Session().commit()
63
63
64 def test_index_with_lightweight_dashboard(self):
64 def test_index_with_lightweight_dashboard(self):
65 self.log_user()
65 self.log_user()
66
66
67 def set_l_dash(set_to):
67 def set_l_dash(set_to):
68 self.app.post(url('admin_setting', setting_id='visual'),
68 self.app.post(url('admin_setting', setting_id='visual'),
69 params=dict(_method='put',
69 params=dict(_method='put',
70 rhodecode_lightweight_dashboard=set_to,))
70 rhodecode_lightweight_dashboard=set_to,))
71
71
72 set_l_dash(True)
72 set_l_dash(True)
73
73
74 try:
74 try:
75 response = self.app.get(url(controller='home', action='index'))
75 response = self.app.get(url(controller='home', action='index'))
76 response.mustcontain("""var data = {"totalRecords": %s""" % len(Repository.getAll()))
76 response.mustcontain("""var data = {"totalRecords": %s""" % len(Repository.getAll()))
77 finally:
77 finally:
78 set_l_dash(False)
78 set_l_dash(False)
79
General Comments 0
You need to be logged in to leave comments. Login now