# HG changeset patch # User Sverre Rabbelier # Date 1234642970 0 # Node ID 8cf30dee8048ff644b53528429c32b5d1d6e6767 # Parent a666374587df61c66a56b18738d3b8f55472847a Factor out the 'key fields without link_id' logic from document Also make sure the to-be-removed is present before removing it when doing the field reordening. Patch by: Sverre Rabbelier diff -r a666374587df -r 8cf30dee8048 app/soc/views/helper/params.py --- a/app/soc/views/helper/params.py Sat Feb 14 20:22:17 2009 +0000 +++ b/app/soc/views/helper/params.py Sat Feb 14 20:22:50 2009 +0000 @@ -113,9 +113,14 @@ ] new_params['sidebar_additional'] = [] + names_sans_link_id = [i for i in logic.getKeyFieldNames() if i != 'link_id'] + sans_link_id_pattern = getPattern(names_sans_link_id, + linkable.SCOPE_PATH_ARG_PATTERN) + new_params['link_id_arg_pattern'] = linkable.LINK_ID_ARG_PATTERN new_params['link_id_pattern_core'] = linkable.LINK_ID_PATTERN_CORE new_params['scope_path_pattern'] = getScopePattern(params) + new_params['sans_link_id_pattern'] = sans_link_id_pattern new_params['django_patterns'] = None new_params['extra_django_patterns'] = [] @@ -152,6 +157,21 @@ (r'^%(url_name)s/(?Plist)$', 'soc.views.models.%(module_name)s.list', 'List %(name_plural)s')] + if params.get('sans_link_id_create'): + new_params['django_patterns_defaults'] += [ + (r'^%(url_name)s/(?Pcreate)/%(sans_link_id)s$', + 'soc.views.models.%(module_name)s.create', 'Create %(name_short)s')] + + if params.get('sans_link_id_list'): + new_params['django_patterns_defaults'] += [ + (r'^%(url_name)s/(?Plist)/%(sans_link_id)s$', + 'soc.views.models.%(module_name)s.list', 'List %(name_plural)s')] + + if params.get('sans_link_id_public_list'): + new_params['django_patterns_defaults'] += [ + (r'^%(url_name)s/(?Plist_public)/%(sans_link_id)s$', + 'soc.views.models.%(module_name)s.list_public', 'List %(name_plural)s')] + new_params['public_template'] = 'soc/%(module_name)s/public.html' % params new_params['export_template'] = 'soc/%(module_name)s/export.html' % params new_params['create_template'] = 'soc/models/edit.html' @@ -252,7 +272,8 @@ if 'extra_key_order' in params: for field in params['extra_key_order']: - create_form.base_fields.keyOrder.remove(field) + if field in create_form.base_fields.keyOrder: + create_form.base_fields.keyOrder.remove(field) create_form.base_fields.keyOrder.extend(params['extra_key_order']) return create_form diff -r a666374587df -r 8cf30dee8048 app/soc/views/models/document.py --- a/app/soc/views/models/document.py Sat Feb 14 20:22:17 2009 +0000 +++ b/app/soc/views/models/document.py Sat Feb 14 20:22:50 2009 +0000 @@ -76,21 +76,12 @@ new_params['export_content_type'] = 'text/text' - names = [i for i in document_logic.getKeyFieldNames() if i != 'link_id'] - create_pattern = params_helper.getPattern( - names, linkable.SCOPE_PATH_ARG_PATTERN) - - new_params['extra_django_patterns'] = [ - (r'^document/(?Pcreate)/%s$' % create_pattern, - 'soc.views.models.%(module_name)s.create', 'Create %(name_short)s'), - (r'^document/(?Plist)/%s$' % create_pattern, - 'soc.views.models.%(module_name)s.list', 'List %(name_plural)s') - ] - new_params['no_create_raw'] = True new_params['no_create_with_scope'] = True new_params['no_create_with_key_fields'] = True new_params['no_list_raw'] = True + new_params['sans_link_id_create'] = True + new_params['sans_link_id_list'] = True new_params['create_extra_dynafields'] = { 'content': forms.fields.CharField( diff -r a666374587df -r 8cf30dee8048 app/soc/views/sitemap/sitemap.py --- a/app/soc/views/sitemap/sitemap.py Sat Feb 14 20:22:17 2009 +0000 +++ b/app/soc/views/sitemap/sitemap.py Sat Feb 14 20:22:50 2009 +0000 @@ -74,6 +74,7 @@ 'ulnp': params['link_id_pattern_core'], 'key_fields': params['key_fields_pattern'], 'scope': params['scope_path_pattern'], + 'sans_link_id': params['sans_link_id_pattern'], } kwargs = {'page_name': name}