Make all default URLS customizable
authorSverre Rabbelier <srabbelier@gmail.com>
Tue, 24 Feb 2009 18:58:22 +0000
changeset 1480 d2d9087d712f
parent 1479 bc738f92a4d8
child 1481 0ccf92d073e8
Make all default URLS customizable Patch by: SVerre Rabbelier
app/soc/views/helper/params.py
app/soc/views/models/document.py
app/soc/views/models/user.py
--- a/app/soc/views/helper/params.py	Tue Feb 24 12:52:19 2009 +0000
+++ b/app/soc/views/helper/params.py	Tue Feb 24 18:58:22 2009 +0000
@@ -147,20 +147,27 @@
 
   new_params['django_patterns'] = None
   new_params['extra_django_patterns'] = []
-  new_params['django_patterns_defaults'] = [
-      (r'^%(url_name)s/(?P<access_type>show)/%(key_fields)s$',
-          'soc.views.models.%(module_name)s.public', 'Show %(name_short)s'),
-      (r'^%(url_name)s/(?P<access_type>admin)/%(key_fields)s$',
-          'soc.views.models.%(module_name)s.admin', 'Show %(name_short)s (admin)'),
-      (r'^%(url_name)s/(?P<access_type>export)/%(key_fields)s$',
-          'soc.views.models.%(module_name)s.export', 'Export %(name_short)s'),
-      (r'^%(url_name)s/(?P<access_type>delete)/%(key_fields)s$',
-          'soc.views.models.%(module_name)s.delete', 'Delete %(name_short)s'),
-      (r'^%(url_name)s/(?P<access_type>edit)/%(key_fields)s$',
-          'soc.views.models.%(module_name)s.edit', 'Edit %(name_short)s'),
-      (r'^%(url_name)s/(?P<access_type>pick)$',
-          'soc.views.models.%(module_name)s.pick', 'Pick %(name_short)s'),
-      ]
+  new_params['django_patterns_defaults'] = []
+
+  if not params.get('no_edit'):
+    new_params['django_patterns_defaults'] += [
+        (r'^%(url_name)s/(?P<access_type>edit)/%(key_fields)s$',
+          'soc.views.models.%(module_name)s.edit', 'Edit %(name_short)s')]
+
+  if not params.get('no_delete'):
+    new_params['django_patterns_defaults'] += [
+        (r'^%(url_name)s/(?P<access_type>delete)/%(key_fields)s$',
+          'soc.views.models.%(module_name)s.delete', 'Delete %(name_short)s')]
+
+  if not params.get('no_show'):
+    new_params['django_patterns_defaults'] += [
+        (r'^%(url_name)s/(?P<access_type>show)/%(key_fields)s$',
+          'soc.views.models.%(module_name)s.public', 'Show %(name_short)s')]
+
+  if not params.get('no_admin'):
+    new_params['django_patterns_defaults'] += [
+        (r'^%(url_name)s/(?P<access_type>admin)/%(key_fields)s$',
+          'soc.views.models.%(module_name)s.admin', 'Show %(name_short)s (admin)')]
 
   if not params.get('no_create_raw'):
     new_params['django_patterns_defaults'] += [
@@ -182,6 +189,16 @@
         (r'^%(url_name)s/(?P<access_type>list)$',
           'soc.views.models.%(module_name)s.list', 'List %(name_plural)s')]
 
+  if params.get('pickable'):
+    new_params['django_patterns_defaults'] += [
+        (r'^%(url_name)s/(?P<access_type>pick)$',
+          'soc.views.models.%(module_name)s.pick', 'Pick %(name_short)s')]
+
+  if params.get('export_content_type'):
+    new_params['django_patterns_defaults'] += [
+        (r'^%(url_name)s/(?P<access_type>export)/%(key_fields)s$',
+          'soc.views.models.%(module_name)s.export', 'Export %(name_short)s')]
+
   if params.get('sans_link_id_create'):
     new_params['django_patterns_defaults'] += [
         (r'^%(url_name)s/(?P<access_type>create)/%(sans_link_id)s$',
--- a/app/soc/views/models/document.py	Tue Feb 24 12:52:19 2009 +0000
+++ b/app/soc/views/models/document.py	Tue Feb 24 18:58:22 2009 +0000
@@ -73,6 +73,7 @@
     new_params['rights'] = rights
 
     new_params['name'] = "Document"
+    new_params['pickable'] = True
 
     new_params['export_content_type'] = 'text/text'
     new_params['export_extension'] = '.html'
--- a/app/soc/views/models/user.py	Tue Feb 24 12:52:19 2009 +0000
+++ b/app/soc/views/models/user.py	Tue Feb 24 18:58:22 2009 +0000
@@ -69,6 +69,7 @@
     new_params['name'] = "User"
 
     new_params['edit_template'] = 'soc/user/edit.html'
+    new_params['pickable'] = True
 
     new_params['sidebar_heading'] = 'Users'