changeset 1348:dccba44ee176 beta

translated resource map into full routes map, added validation for repos_group id
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 26 May 2011 01:06:33 +0200
parents 43b8e161be3f
children 526120c77a38
files rhodecode/config/routing.py
diffstat 1 files changed, 38 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/config/routing.py	Wed May 25 10:27:29 2011 +0200
+++ b/rhodecode/config/routing.py	Thu May 26 01:06:33 2011 +0200
@@ -29,6 +29,13 @@
         repo_name = match_dict.get('repo_name')
         return not cr(repo_name, config['base_path'])
 
+
+    def check_int(environ, match_dict):
+        return match_dict.get('id').isdigit()
+
+
+
+
     # The ErrorController route (handles 404/500 error pages); it should
     # likely stay at the top, ensuring it can always be resolved
     rmap.connect('/error/{action}', controller='error')
@@ -104,9 +111,37 @@
              action="repo_pull", conditions=dict(method=["PUT"],
                                                         function=check_repo))
 
-    #ADMIN REPOS GROUP REST ROUTES
-    rmap.resource('repos_group', 'repos_groups',
-                  controller='admin/repos_groups', path_prefix=ADMIN_PREFIX)
+    with rmap.submapper(path_prefix=ADMIN_PREFIX,
+                        controller='admin/repos_groups') as m:
+        m.connect("repos_groups", "/repos_groups",
+                  action="create", conditions=dict(method=["POST"]))
+        m.connect("repos_groups", "/repos_groups",
+                  action="index", conditions=dict(method=["GET"]))
+        m.connect("formatted_repos_groups", "/repos_groups.{format}",
+                  action="index", conditions=dict(method=["GET"]))
+        m.connect("new_repos_group", "/repos_groups/new",
+                  action="new", conditions=dict(method=["GET"]))
+        m.connect("formatted_new_repos_group", "/repos_groups/new.{format}",
+                  action="new", conditions=dict(method=["GET"]))
+        m.connect("update_repos_group", "/repos_groups/{id}",
+                  action="update", conditions=dict(method=["PUT"],
+                                                   function=check_int))
+        m.connect("delete_repos_group", "/repos_groups/{id}",
+                  action="delete", conditions=dict(method=["DELETE"],
+                                                   function=check_int))
+        m.connect("edit_repos_group", "/repos_groups/{id}/edit",
+                  action="edit", conditions=dict(method=["GET"],
+                                                 function=check_int))
+        m.connect("formatted_edit_repos_group",
+                  "/repos_groups/{id}.{format}/edit",
+                  action="edit", conditions=dict(method=["GET"],
+                                                 function=check_int))
+        m.connect("repos_group", "/repos_groups/{id}",
+                  action="show", conditions=dict(method=["GET"],
+                                                 function=check_int))
+        m.connect("formatted_repos_group", "/repos_groups/{id}.{format}",
+                  action="show", conditions=dict(method=["GET"],
+                                                 function=check_int))
 
     #ADMIN USER REST ROUTES
     with rmap.submapper(path_prefix=ADMIN_PREFIX,