Fixed redirection after creation to Just Work
Accomplished by generating a link to the creation page instead of
trying to deduct it from the current path.
--- a/app/soc/logic/site/map.py Sun Nov 16 22:11:16 2008 +0000
+++ b/app/soc/logic/site/map.py Sun Nov 16 22:11:58 2008 +0000
@@ -268,7 +268,7 @@
site_document_create = page.Page(
page.Url(
- r'^document/edit$',
+ r'^document/create$',
'soc.views.models.document.create'),
'Site: Create New Document',
'Create Site Document',
--- a/app/soc/views/models/base.py Sun Nov 16 22:11:16 2008 +0000
+++ b/app/soc/views/models/base.py Sun Nov 16 22:11:58 2008 +0000
@@ -82,8 +82,12 @@
new_rights = {}
new_rights['any_access'] = [access.checkIsUser]
+ new_params = {}
+ new_params['create_redirect'] = '/%s' % params['name_short'].lower()
+ new_params['missing_redirect'] = '/%s/create' % params['name_short'].lower()
+
self._rights = dicts.merge(rights, new_rights)
- self._params = params
+ self._params = dicts.merge(params, new_params)
def public(self, request, page_name=None, params=None, **kwargs):
"""Displays the public page for the entity specified by **kwargs
@@ -139,14 +143,15 @@
kwargs: not used for create()
"""
+ params = dicts.merge(params, self._params)
+
# Create page is an edit page with no key fields
empty_kwargs = {}
fields = self._logic.getKeyFieldNames()
for field in fields:
empty_kwargs[field] = None
- request.path = helper.requests.replaceSuffix(request.path,
- old_suffix='create')
+ request.path = params['create_redirect']
request.path = helper.requests.replaceSuffix(request.path,
old_suffix='edit',
new_suffix='edit')
@@ -188,7 +193,7 @@
error.message = error.message + self.DEF_CREATE_NEW_ENTITY_MSG % {
'entity_type_lower' : params['name'].lower(),
'entity_type' : params['name'],
- 'create' : params['create_redirect']
+ 'create' : params['missing_redirect']
}
return simple.errorResponse(request, page_name, error, template, context)
@@ -340,7 +345,7 @@
error.message = error.message + self.DEF_CREATE_NEW_ENTITY_MSG % {
'entity_type_lower' : params['name'].lower(),
'entity_type' : params['name'],
- 'create' : params['create_redirect']
+ 'create' : params['missing_redirect']
}
return simple.errorResponse(request, page_name, error, template, context)
--- a/app/soc/views/models/document.py Sun Nov 16 22:11:16 2008 +0000
+++ b/app/soc/views/models/document.py Sun Nov 16 22:11:58 2008 +0000
@@ -116,7 +116,6 @@
}
params['delete_redirect'] = '/document/list'
- params['create_redirect'] = 'soc/models/edit.html'
params['save_message'] = [ugettext_lazy('Profile saved.')]
--- a/app/soc/views/models/home_settings.py Sun Nov 16 22:11:16 2008 +0000
+++ b/app/soc/views/models/home_settings.py Sun Nov 16 22:11:58 2008 +0000
@@ -131,7 +131,6 @@
}
params['delete_redirect'] = '/home/list'
- params['create_redirect'] = '/home/edit'
params['save_message'] = [ugettext_lazy('Profile saved.')]
--- a/app/soc/views/models/host.py Sun Nov 16 22:11:16 2008 +0000
+++ b/app/soc/views/models/host.py Sun Nov 16 22:11:58 2008 +0000
@@ -108,7 +108,6 @@
}
params['delete_redirect'] = '/host/list'
- params['create_redirect'] = '/host/profile'
params['invite_redirect'] = '/host/list'
params['save_message'] = [ugettext_lazy('Profile saved.')]
--- a/app/soc/views/models/site_settings.py Sun Nov 16 22:11:16 2008 +0000
+++ b/app/soc/views/models/site_settings.py Sun Nov 16 22:11:58 2008 +0000
@@ -97,7 +97,6 @@
}
params['delete_redirect'] = '/site/list'
- params['create_redirect'] = '/site/edit'
params = dicts.merge(original_params, params)
rights = dicts.merge(original_rights, rights)
--- a/app/soc/views/models/sponsor.py Sun Nov 16 22:11:16 2008 +0000
+++ b/app/soc/views/models/sponsor.py Sun Nov 16 22:11:58 2008 +0000
@@ -116,7 +116,6 @@
}
params['delete_redirect'] = '/sponsor/list'
- params['create_redirect'] = '/sponsor/profile'
params['save_message'] = [ugettext_lazy('Profile saved.')]
--- a/app/soc/views/models/user.py Sun Nov 16 22:11:16 2008 +0000
+++ b/app/soc/views/models/user.py Sun Nov 16 22:11:58 2008 +0000
@@ -142,7 +142,6 @@
}
params['delete_redirect'] = '/user/list'
- params['create_redirect'] = '/user/create'
params['save_message'] = [ugettext_lazy('Profile saved.')]