Added a new create regexp in urls for just scope_path
Now that scope_path is properly defined we can add a url matching
just the scope path. This allows some other custom create regexps to
be removed/rewritten.
Note: It needs to be -after- the full key_name regexp, since for
arbitrarily nested scopes it would always match as just scope_path,
even if there are other fields needed after the scope.
Patch by: Sverre Rabbelier
--- a/app/soc/views/helper/params.py Sat Dec 06 14:23:53 2008 +0000
+++ b/app/soc/views/helper/params.py Sat Dec 06 14:24:26 2008 +0000
@@ -101,6 +101,7 @@
new_params['key_fields_prefix'] = []
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['django_patterns'] = None
new_params['extra_django_patterns'] = []
@@ -111,6 +112,8 @@
'soc.views.models.%(module_name)s.create', 'Create %(name_short)s'),
(r'^%(url_name)s/create/%(key_fields)s$',
'soc.views.models.%(module_name)s.create', 'Create %(name_short)s'),
+ (r'^%(url_name)s/create/%(scope)s$',
+ 'soc.views.models.%(module_name)s.create', 'Create %(name_short)s'),
(r'^%(url_name)s/delete/%(key_fields)s$',
'soc.views.models.%(module_name)s.delete', 'Delete %(name_short)s'),
(r'^%(url_name)s/edit/%(key_fields)s$',
@@ -246,7 +249,7 @@
for name in names:
if name == 'scope_path':
- pattern = getScopePattern(params)
+ pattern = params['scope_path_pattern']
else:
pattern = r'(?P<%s>%s)' % (name, linkable.LINK_ID_PATTERN_CORE)
patterns.append(pattern)
--- a/app/soc/views/models/program.py Sat Dec 06 14:23:53 2008 +0000
+++ b/app/soc/views/models/program.py Sat Dec 06 14:24:26 2008 +0000
@@ -69,10 +69,6 @@
'clean_link_id': cleaning.clean_link_id,
}
- new_params['extra_django_patterns'] = [
- (r'^%(url_name)s/create/(?P<scope_path>%(ulnp)s)$',
- 'soc.views.models.%(module_name)s.create', 'Create %(name_short)s')]
-
new_params['scope_redirect'] = redirects.getCreateRedirect
params = dicts.merge(params, new_params)
--- a/app/soc/views/sitemap/sitemap.py Sat Dec 06 14:23:53 2008 +0000
+++ b/app/soc/views/sitemap/sitemap.py Sat Dec 06 14:24:26 2008 +0000
@@ -60,7 +60,6 @@
# Construct defaults manualy
default_patterns = params['django_patterns_defaults']
default_patterns += params['extra_django_patterns']
- key_fields_pattern = params['key_fields_pattern']
patterns = []
@@ -72,7 +71,8 @@
'url_name': params['url_name'],
'lnp': params['link_id_arg_pattern'],
'ulnp': params['link_id_pattern_core'],
- 'key_fields': key_fields_pattern,
+ 'key_fields': params['key_fields_pattern'],
+ 'scope': params['scope_path_pattern'],
}
kwargs = {'page_name': name}