# HG changeset patch # User Mads Kiilerich # Date 1470313416 -7200 # Node ID 1fdff0d0516c0880c14eb57e086e9b1d7c042c77 # Parent 8805d3e688eb2aea68adf10370e16eacfee17f42 defaults: replace automatic 'routes' 'resource' routing by explicit 'connect' and use POST diff -r 8805d3e688eb -r 1fdff0d0516c kallithea/config/routing.py --- a/kallithea/config/routing.py Thu Aug 04 14:23:36 2016 +0200 +++ b/kallithea/config/routing.py Thu Aug 04 14:23:36 2016 +0200 @@ -269,9 +269,13 @@ action="permission_perms", conditions=dict(method=["GET"])) - #ADMIN DEFAULTS REST ROUTES - rmap.resource('default', 'defaults', - controller='admin/defaults', path_prefix=ADMIN_PREFIX) + #ADMIN DEFAULTS ROUTES + with rmap.submapper(path_prefix=ADMIN_PREFIX, + controller='admin/defaults') as m: + m.connect('defaults', 'defaults', + action="index") + m.connect('defaults_update', 'defaults/{id}/update', + action="update", conditions=dict(method=["POST"])) #ADMIN AUTH SETTINGS rmap.connect('auth_settings', '%s/auth' % ADMIN_PREFIX, diff -r 8805d3e688eb -r 1fdff0d0516c kallithea/controllers/admin/defaults.py --- a/kallithea/controllers/admin/defaults.py Thu Aug 04 14:23:36 2016 +0200 +++ b/kallithea/controllers/admin/defaults.py Thu Aug 04 14:23:36 2016 +0200 @@ -46,10 +46,6 @@ class DefaultsController(BaseController): - """REST Controller styled on the Atom Publishing Protocol""" - # To properly map this controller, ensure your config/routing.py - # file has a resource setup: - # map.resource('default', 'defaults') @LoginRequired() @HasPermissionAnyDecorator('hg.admin') @@ -57,8 +53,6 @@ super(DefaultsController, self).__before__() def index(self, format='html'): - """GET /defaults: All items in the collection""" - # url('defaults') c.backends = BACKENDS.keys() defaults = Setting.get_default_repo_settings() @@ -70,14 +64,6 @@ ) def update(self, id): - """PUT /defaults/id: Update an existing item""" - # Forms posted to this method should contain a hidden field: - # - # Or using helpers: - # h.form(url('default', id=ID), - # method='put') - # url('default', id=ID) - _form = DefaultsForm()() try: diff -r 8805d3e688eb -r 1fdff0d0516c kallithea/templates/admin/defaults/defaults.html --- a/kallithea/templates/admin/defaults/defaults.html Thu Aug 04 14:23:36 2016 +0200 +++ b/kallithea/templates/admin/defaults/defaults.html Thu Aug 04 14:23:36 2016 +0200 @@ -22,7 +22,7 @@ ${self.breadcrumbs()} - ${h.form(url('default', id='defaults'),method='put')} + ${h.form(url('defaults_update', id='defaults'))}
diff -r 8805d3e688eb -r 1fdff0d0516c kallithea/tests/functional/test_admin_defaults.py --- a/kallithea/tests/functional/test_admin_defaults.py Thu Aug 04 14:23:36 2016 +0200 +++ b/kallithea/tests/functional/test_admin_defaults.py Thu Aug 04 14:23:36 2016 +0200 @@ -22,7 +22,7 @@ 'default_repo_type': 'hg', '_authentication_token': self.authentication_token(), } - response = self.app.put(url('default', id='default'), params=params) + response = self.app.post(url('defaults_update', id='default'), params=params) self.checkSessionFlash(response, 'Default settings updated successfully') params.pop('_authentication_token') @@ -39,7 +39,7 @@ 'default_repo_type': 'git', '_authentication_token': self.authentication_token(), } - response = self.app.put(url('default', id='default'), params=params) + response = self.app.post(url('defaults_update', id='default'), params=params) self.checkSessionFlash(response, 'Default settings updated successfully') params.pop('_authentication_token')