Allow for setting a edit_cancel_redirect
Defaults to list view for the entity but can be overriden by setting
the parameter manually. Falls back to history.go(-1) if not set.
Patch by: Sverre Rabbelier
--- a/app/soc/templates/soc/models/edit.html Wed Jan 28 14:16:46 2009 +0000
+++ b/app/soc/templates/soc/models/edit.html Wed Jan 28 14:18:31 2009 +0000
@@ -49,7 +49,11 @@
<input style="font-weight: bold" type="submit" value="Save Changes"/></span>
</td>
<td>
- <input type="button" onclick="location.href='/'" value="Cancel"/>
+ {% if edit_cancel_redirect %}
+ <input type="button" onclick="location.href='{{ edit_cancel_redirect }}'" value="Cancel"/>
+ {% else %}
+ <input type="button" value="Back to Previous Page" onClick="javascript: history.go(-1)">
+ {% endif %}
</td>
{% if entity %}
<td>
--- a/app/soc/views/helper/params.py Wed Jan 28 14:16:46 2009 +0000
+++ b/app/soc/views/helper/params.py Wed Jan 28 14:18:31 2009 +0000
@@ -100,6 +100,7 @@
new_params['missing_redirect'] = '/%(url_name)s/create' % params
new_params['delete_redirect'] = '/%(url_name)s/list' % params
new_params['invite_redirect'] = '/request/list'
+ new_params['edit_cancel_redirect'] = '/%(url_name)s/list' % params
new_params['sidebar'] = None
new_params['sidebar_grouping'] = 'main'
--- a/app/soc/views/models/base.py Wed Jan 28 14:16:46 2009 +0000
+++ b/app/soc/views/models/base.py Wed Jan 28 14:18:31 2009 +0000
@@ -707,6 +707,7 @@
context['entity_type_plural'] = params['name_plural']
context['entity_type_short'] = params['name_short']
context['entity_type_url'] = params['url_name']
+ context['edit_cancel_redirect'] = params.get('edit_cancel_redirect')
context['return_url'] = request.path
if params.get('export_content_type') and entity: