app/soc/views/helper/params.py
changeset 2385 174e946039e0
parent 2372 f1cbafd21f75
child 2894 4af34d6e2a2d
equal deleted inserted replaced
2383:6ca37aa4c33e 2385:174e946039e0
   150 
   150 
   151   new_params['django_patterns'] = None
   151   new_params['django_patterns'] = None
   152   new_params['extra_django_patterns'] = []
   152   new_params['extra_django_patterns'] = []
   153   new_params['django_patterns_defaults'] = []
   153   new_params['django_patterns_defaults'] = []
   154 
   154 
       
   155   # Defines the module package that the view is in. If it is not
       
   156   # already defined in the respective view, it defaults to 
       
   157   # soc.views.models
       
   158   if not params.get('module_package'):
       
   159     new_params['module_package'] = 'soc.views.models'
       
   160 
   155   if not params.get('no_edit'):
   161   if not params.get('no_edit'):
   156     new_params['django_patterns_defaults'] += [
   162     new_params['django_patterns_defaults'] += [
   157         (r'^%(url_name)s/(?P<access_type>edit)/%(key_fields)s$',
   163         (r'^%(url_name)s/(?P<access_type>edit)/%(key_fields)s$',
   158           'soc.views.models.%(module_name)s.edit', 'Edit %(name_short)s')]
   164           '%(module_package)s.%(module_name)s.edit', 'Edit %(name_short)s')]
   159 
   165 
   160   if not params.get('no_delete'):
   166   if not params.get('no_delete'):
   161     new_params['django_patterns_defaults'] += [
   167     new_params['django_patterns_defaults'] += [
   162         (r'^%(url_name)s/(?P<access_type>delete)/%(key_fields)s$',
   168         (r'^%(url_name)s/(?P<access_type>delete)/%(key_fields)s$',
   163           'soc.views.models.%(module_name)s.delete', 'Delete %(name_short)s')]
   169           '%(module_package)s.%(module_name)s.delete', 'Delete %(name_short)s')]
   164 
   170 
   165   if not params.get('no_show'):
   171   if not params.get('no_show'):
   166     new_params['django_patterns_defaults'] += [
   172     new_params['django_patterns_defaults'] += [
   167         (r'^%(url_name)s/(?P<access_type>show)/%(key_fields)s$',
   173         (r'^%(url_name)s/(?P<access_type>show)/%(key_fields)s$',
   168           'soc.views.models.%(module_name)s.public', 'Show %(name_short)s')]
   174           '%(module_package)s.%(module_name)s.public', 'Show %(name_short)s')]
   169 
   175 
   170   if not params.get('no_admin'):
   176   if not params.get('no_admin'):
   171     new_params['django_patterns_defaults'] += [
   177     new_params['django_patterns_defaults'] += [
   172         (r'^%(url_name)s/(?P<access_type>admin)/%(key_fields)s$',
   178         (r'^%(url_name)s/(?P<access_type>admin)/%(key_fields)s$',
   173           'soc.views.models.%(module_name)s.admin', 
   179           '%(module_package)s.%(module_name)s.admin', 
   174           'Show %(name_short)s (admin)')]
   180           'Show %(name_short)s (admin)')]
   175 
   181 
   176   if not params.get('no_create_raw'):
   182   if not params.get('no_create_raw'):
   177     new_params['django_patterns_defaults'] += [
   183     new_params['django_patterns_defaults'] += [
   178         (r'^%(url_name)s/(?P<access_type>create)$',
   184         (r'^%(url_name)s/(?P<access_type>create)$',
   179           'soc.views.models.%(module_name)s.create', 'Create %(name_short)s')]
   185           '%(module_package)s.%(module_name)s.create', 'Create %(name_short)s')]
   180 
   186 
   181   if not params.get('no_create_with_scope'):
   187   if not params.get('no_create_with_scope'):
   182     new_params['django_patterns_defaults'] += [
   188     new_params['django_patterns_defaults'] += [
   183         (r'^%(url_name)s/(?P<access_type>create)/%(scope)s$',
   189         (r'^%(url_name)s/(?P<access_type>create)/%(scope)s$',
   184         'soc.views.models.%(module_name)s.create', 'Create %(name_short)s')]
   190         '%(module_package)s.%(module_name)s.create', 'Create %(name_short)s')]
   185 
   191 
   186   if not params.get('no_create_with_key_fields'):
   192   if not params.get('no_create_with_key_fields'):
   187     new_params['django_patterns_defaults'] += [
   193     new_params['django_patterns_defaults'] += [
   188         (r'^%(url_name)s/(?P<access_type>create)/%(key_fields)s$',
   194         (r'^%(url_name)s/(?P<access_type>create)/%(key_fields)s$',
   189         'soc.views.models.%(module_name)s.create', 'Create %(name_short)s')]
   195         '%(module_package)s.%(module_name)s.create', 'Create %(name_short)s')]
   190 
   196 
   191   if not params.get('no_list_raw'):
   197   if not params.get('no_list_raw'):
   192     new_params['django_patterns_defaults'] += [
   198     new_params['django_patterns_defaults'] += [
   193         (r'^%(url_name)s/(?P<access_type>list)$',
   199         (r'^%(url_name)s/(?P<access_type>list)$',
   194           'soc.views.models.%(module_name)s.list', 'List %(name_plural)s')]
   200           '%(module_package)s.%(module_name)s.list', 'List %(name_plural)s')]
   195 
   201 
   196   if params.get('pickable'):
   202   if params.get('pickable'):
   197     new_params['django_patterns_defaults'] += [
   203     new_params['django_patterns_defaults'] += [
   198         (r'^%(url_name)s/(?P<access_type>pick)$',
   204         (r'^%(url_name)s/(?P<access_type>pick)$',
   199           'soc.views.models.%(module_name)s.pick', 'Pick %(name_short)s')]
   205           '%(module_package)s.%(module_name)s.pick', 'Pick %(name_short)s')]
   200 
   206 
   201   if params.get('export_content_type'):
   207   if params.get('export_content_type'):
   202     new_params['django_patterns_defaults'] += [
   208     new_params['django_patterns_defaults'] += [
   203         (r'^%(url_name)s/(?P<access_type>export)/%(key_fields)s$',
   209         (r'^%(url_name)s/(?P<access_type>export)/%(key_fields)s$',
   204           'soc.views.models.%(module_name)s.export', 'Export %(name_short)s')]
   210           '%(module_package)s.%(module_name)s.export', 'Export %(name_short)s')]
   205 
   211 
   206   if params.get('sans_link_id_create'):
   212   if params.get('sans_link_id_create'):
   207     new_params['django_patterns_defaults'] += [
   213     new_params['django_patterns_defaults'] += [
   208         (r'^%(url_name)s/(?P<access_type>create)/%(sans_link_id)s$',
   214         (r'^%(url_name)s/(?P<access_type>create)/%(sans_link_id)s$',
   209          'soc.views.models.%(module_name)s.create', 'Create %(name_short)s')]
   215          '%(module_package)s.%(module_name)s.create', 'Create %(name_short)s')]
   210 
   216 
   211   if params.get('sans_link_id_list'):
   217   if params.get('sans_link_id_list'):
   212     new_params['django_patterns_defaults'] += [
   218     new_params['django_patterns_defaults'] += [
   213         (r'^%(url_name)s/(?P<access_type>list)/%(sans_link_id)s$',
   219         (r'^%(url_name)s/(?P<access_type>list)/%(sans_link_id)s$',
   214          'soc.views.models.%(module_name)s.list', 'List %(name_plural)s')]
   220          '%(module_package)s.%(module_name)s.list', 'List %(name_plural)s')]
   215 
   221 
   216   if params.get('sans_link_id_public_list'):
   222   if params.get('sans_link_id_public_list'):
   217     new_params['django_patterns_defaults'] += [
   223     new_params['django_patterns_defaults'] += [
   218         (r'^%(url_name)s/(?P<access_type>list_public)/%(sans_link_id)s$',
   224         (r'^%(url_name)s/(?P<access_type>list_public)/%(sans_link_id)s$',
   219          'soc.views.models.%(module_name)s.list_public', 
   225          '%(module_package)s.%(module_name)s.list_public', 
   220          'List %(name_plural)s')]
   226          'List %(name_plural)s')]
   221 
   227 
   222   new_params['public_template'] = 'soc/%(module_name)s/public.html' % params
   228   new_params['public_template'] = 'soc/%(module_name)s/public.html' % params
   223   new_params['export_template'] = 'soc/export.html'
   229   new_params['export_template'] = 'soc/export.html'
   224   new_params['create_template'] = 'soc/models/edit.html'
   230   new_params['create_template'] = 'soc/models/edit.html'