From 49a76c81feec423325157ed5983fe4da5b88ab79 Mon Sep 17 00:00:00 2001 From: Marcin Kuzminski Date: Mon, 24 Jul 2017 12:28:57 +0200 Subject: [PATCH] views: fixed some view names for better usage in view whitelist access --- rhodecode/apps/gist/views.py | 2 +- rhodecode/apps/my_account/__init__.py | 2 +- .../my_account/tests/test_my_account_password.py | 14 ++++++++++---- rhodecode/apps/my_account/views/my_account.py | 6 ++++-- rhodecode/apps/repository/views/repo_summary.py | 3 +++ rhodecode/apps/user_profile/views.py | 2 +- 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/rhodecode/apps/gist/views.py b/rhodecode/apps/gist/views.py index 8737e21e..69bedaa8 100644 --- a/rhodecode/apps/gist/views.py +++ b/rhodecode/apps/gist/views.py @@ -270,7 +270,7 @@ class GistView(BaseAppView): @view_config( route_name='gist_show_formatted_path', request_method='GET', renderer=None) - def show(self): + def gist_show(self): gist_id = self.request.matchdict['gist_id'] # TODO(marcink): expose those via matching dict diff --git a/rhodecode/apps/my_account/__init__.py b/rhodecode/apps/my_account/__init__.py index f74ac08d..0146159f 100644 --- a/rhodecode/apps/my_account/__init__.py +++ b/rhodecode/apps/my_account/__init__.py @@ -43,7 +43,7 @@ def includeme(config): config.add_route( name='my_account_password_update', - pattern=ADMIN_PREFIX + '/my_account/password') + pattern=ADMIN_PREFIX + '/my_account/password/update') # my account tokens config.add_route( diff --git a/rhodecode/apps/my_account/tests/test_my_account_password.py b/rhodecode/apps/my_account/tests/test_my_account_password.py index 16ebbda4..98e73d35 100644 --- a/rhodecode/apps/my_account/tests/test_my_account_password.py +++ b/rhodecode/apps/my_account/tests/test_my_account_password.py @@ -37,6 +37,8 @@ def route_path(name, **kwargs): 'home': '/', 'my_account_password': ADMIN_PREFIX + '/my_account/password', + 'my_account_password_update': + ADMIN_PREFIX + '/my_account/password/update', }[name].format(**kwargs) @@ -58,7 +60,8 @@ class TestMyAccountPassword(TestController): ('__end__', 'new_password:mapping'), ('csrf_token', self.csrf_token), ] - response = self.app.post(route_path('my_account_password'), form_data).follow() + response = self.app.post( + route_path('my_account_password_update'), form_data).follow() assert 'Successfully updated password' in response # check_password depends on user being in session @@ -91,7 +94,8 @@ class TestMyAccountPassword(TestController): ('__end__', 'new_password:mapping'), ('csrf_token', self.csrf_token), ] - response = self.app.post(route_path('my_account_password'), form_data) + response = self.app.post( + route_path('my_account_password_update'), form_data) assert_response = response.assert_response() assert assert_response.get_elements('.error-block') @@ -109,7 +113,8 @@ class TestMyAccountPassword(TestController): ('__end__', 'new_password:mapping'), ('csrf_token', self.csrf_token), ] - response = self.app.post(route_path('my_account_password'), form_data) + response = self.app.post( + route_path('my_account_password_update'), form_data) assert_session_flash( response, 'Error occurred during update of user password') @@ -129,7 +134,8 @@ class TestMyAccountPassword(TestController): ('__end__', 'new_password:mapping'), ('csrf_token', self.csrf_token), ] - self.app.post(route_path('my_account_password'), form_data) + self.app.post( + route_path('my_account_password_update'), form_data) response = self.app.get(route_path('home')) session = response.get_session_from_response() diff --git a/rhodecode/apps/my_account/views/my_account.py b/rhodecode/apps/my_account/views/my_account.py index 581ce22f..6368f9e4 100644 --- a/rhodecode/apps/my_account/views/my_account.py +++ b/rhodecode/apps/my_account/views/my_account.py @@ -90,7 +90,9 @@ class MyAccountView(BaseAppView, DataGridAppView): username=c.user.username) form = forms.Form( - schema, buttons=(forms.buttons.save, forms.buttons.reset)) + schema, + action=h.route_path('my_account_password_update'), + buttons=(forms.buttons.save, forms.buttons.reset)) c.form = form return self._get_template_context(c) @@ -99,7 +101,7 @@ class MyAccountView(BaseAppView, DataGridAppView): @NotAnonymous() @CSRFRequired() @view_config( - route_name='my_account_password', request_method='POST', + route_name='my_account_password_update', request_method='POST', renderer='rhodecode:templates/admin/my_account/my_account.mako') def my_account_password_update(self): _ = self.request.translate diff --git a/rhodecode/apps/repository/views/repo_summary.py b/rhodecode/apps/repository/views/repo_summary.py index f6d00224..bc10ff10 100644 --- a/rhodecode/apps/repository/views/repo_summary.py +++ b/rhodecode/apps/repository/views/repo_summary.py @@ -162,6 +162,9 @@ class RepoSummaryView(RepoAppView): @view_config( route_name='repo_summary_slash', request_method='GET', renderer='rhodecode:templates/summary/summary.mako') + @view_config( + route_name='repo_summary_explicit', request_method='GET', + renderer='rhodecode:templates/summary/summary.mako') def summary(self): c = self.load_default_context() diff --git a/rhodecode/apps/user_profile/views.py b/rhodecode/apps/user_profile/views.py index b2e7ef71..fd1a2e18 100644 --- a/rhodecode/apps/user_profile/views.py +++ b/rhodecode/apps/user_profile/views.py @@ -39,7 +39,7 @@ class UserProfileView(BaseAppView): @view_config( route_name='user_profile', request_method='GET', renderer='rhodecode:templates/users/user.mako') - def login(self): + def user_profile(self): # register local template context c = self._get_local_tmpl_context() c.active = 'user_profile'