Now clicking cancel button returns user to previous page. Fixes issue 569.
If you don't want that behaviour you can define cancel_redirect and user will be redirected to given url on "Cancel" button click instead of redirecting to previous page.
Patch by: Daniel Hans & Pawel Solyga
--- a/app/soc/templates/soc/club_admin/manage.html Wed May 20 12:32:36 2009 +0200
+++ b/app/soc/templates/soc/club_admin/manage.html Thu May 21 13:25:11 2009 +0200
@@ -23,7 +23,17 @@
<td>
Please select the appropriate action:</br>
<input type="button" onclick="location.href='/{{ url_name }}/manage/{{ entity.scope_path }}/{{ entity.link_id }}?resign=true'" value="Resign"/>
- <input type="button" onclick="location.href='{{ cancel_redirect }}'" value="Cancel"/>
+ {% if cancel_redirect %}
+ <input type="button"
+ {% if entity %}
+ onclick="location.href='{{ cancel_redirect }}'"
+ {% else %}
+ onClick="javascript: history.go(-1)">
+ {% endif %}
+ value="Cancel"/>
+ {% else %}
+ <input type="button" value="Back to Previous Page" onClick="javascript:history.go(-1)">
+ {% endif %}
</td>
</tr>
{% endblock %}
--- a/app/soc/templates/soc/club_member/manage.html Wed May 20 12:32:36 2009 +0200
+++ b/app/soc/templates/soc/club_member/manage.html Thu May 21 13:25:11 2009 +0200
@@ -23,7 +23,17 @@
<td>
Please select the appropriate action:</br>
<input type="button" onclick="location.href='/{{ url_name }}/manage/{{ entity.scope_path }}/{{ entity.link_id }}?resign=true'" value="Resign"/>
- <input type="button" onclick="location.href='{{ cancel_redirect }}'" value="Cancel"/>
+ {% if cancel_redirect %}
+ <input type="button"
+ {% if entity %}
+ onclick="location.href='{{ cancel_redirect }}'"
+ {% else %}
+ onClick="javascript: history.go(-1)">
+ {% endif %}
+ value="Cancel"/>
+ {% else %}
+ <input type="button" value="Back to Previous Page" onClick="javascript:history.go(-1)">
+ {% endif %}
</td>
</tr>
{% endblock %}
--- a/app/soc/templates/soc/host/manage.html Wed May 20 12:32:36 2009 +0200
+++ b/app/soc/templates/soc/host/manage.html Thu May 21 13:25:11 2009 +0200
@@ -23,7 +23,17 @@
<td>
Please select the appropriate action:</br>
<input type="button" onclick="location.href='/{{ url_name }}/manage/{{ entity.scope_path }}/{{ entity.link_id }}?resign=true'" value="Resign"/>
- <input type="button" onclick="location.href='{{ cancel_redirect }}'" value="Cancel"/>
+ {% if cancel_redirect %}
+ <input type="button"
+ {% if entity %}
+ onclick="location.href='{{ cancel_redirect }}'"
+ {% else %}
+ onClick="javascript: history.go(-1)">
+ {% endif %}
+ value="Cancel"/>
+ {% else %}
+ <input type="button" value="Back to Previous Page" onClick="javascript:history.go(-1)">
+ {% endif %}
</td>
</tr>
{% endblock %}
--- a/app/soc/templates/soc/mentor/manage.html Wed May 20 12:32:36 2009 +0200
+++ b/app/soc/templates/soc/mentor/manage.html Thu May 21 13:25:11 2009 +0200
@@ -23,7 +23,17 @@
<td>
Please select the appropriate action:</br>
<input type="button" onclick="location.href='/{{ url_name }}/manage/{{ entity.scope_path }}/{{ entity.link_id }}?resign=true'" value="Resign"/>
- <input type="button" onclick="location.href='{{ cancel_redirect }}'" value="Cancel"/>
+ {% if cancel_redirect %}
+ <input type="button"
+ {% if entity %}
+ onclick="location.href='{{ cancel_redirect }}'"
+ {% else %}
+ onClick="javascript: history.go(-1)">
+ {% endif %}
+ value="Cancel"/>
+ {% else %}
+ <input type="button" value="Back to Previous Page" onClick="javascript:history.go(-1)">
+ {% endif %}
</td>
</tr>
{% endblock %}
--- a/app/soc/templates/soc/models/edit.html Wed May 20 12:32:36 2009 +0200
+++ b/app/soc/templates/soc/models/edit.html Thu May 21 13:25:11 2009 +0200
@@ -58,11 +58,17 @@
{% endif %}
{% endblock %}
<td>
- {% 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 %}
+ {% if cancel_redirect %}
+ <input type="button"
+ {% if entity %}
+ onclick="location.href='{{ cancel_redirect }}'"
+ {% else %}
+ onClick="javascript: history.go(-1)">
+ {% endif %}
+ value="Cancel"/>
+ {% else %}
+ <input type="button" value="Back to Previous Page" onClick="javascript:history.go(-1)">
+ {% endif %}
</td>
{% if entity %}
{% block delete_button %}
--- a/app/soc/templates/soc/org_admin/manage.html Wed May 20 12:32:36 2009 +0200
+++ b/app/soc/templates/soc/org_admin/manage.html Thu May 21 13:25:11 2009 +0200
@@ -23,7 +23,17 @@
<td>
Please select the appropriate action:</br>
<input type="button" onclick="location.href='/{{ url_name }}/manage/{{ entity.scope_path }}/{{ entity.link_id }}?resign=true'" value="Resign"/>
- <input type="button" onclick="location.href='{{ cancel_redirect }}'" value="Cancel"/>
+ {% if cancel_redirect %}
+ <input type="button"
+ {% if entity %}
+ onclick="location.href='{{ cancel_redirect }}'"
+ {% else %}
+ onClick="javascript: history.go(-1)">
+ {% endif %}
+ value="Cancel"/>
+ {% else %}
+ <input type="button" value="Back to Previous Page" onClick="javascript:history.go(-1)">
+ {% endif %}
</td>
</tr>
{% endblock %}
--- a/app/soc/templates/soc/student/manage.html Wed May 20 12:32:36 2009 +0200
+++ b/app/soc/templates/soc/student/manage.html Thu May 21 13:25:11 2009 +0200
@@ -23,7 +23,17 @@
<td>
Please select the appropriate action:</br>
<input type="button" onclick="location.href='/{{ url_name }}/manage/{{ entity.scope_path }}/{{ entity.link_id }}?resign=true'" value="Resign"/>
- <input type="button" onclick="location.href='{{ cancel_redirect }}'" value="Cancel"/>
+ {% if cancel_redirect %}
+ <input type="button"
+ {% if entity %}
+ onclick="location.href='{{ cancel_redirect }}'"
+ {% else %}
+ onClick="javascript: history.go(-1)">
+ {% endif %}
+ value="Cancel"/>
+ {% else %}
+ <input type="button" value="Back to Previous Page" onClick="javascript:history.go(-1)">
+ {% endif %}
</td>
</tr>
{% endblock %}
--- a/app/soc/views/helper/params.py Wed May 20 12:32:36 2009 +0200
+++ b/app/soc/views/helper/params.py Thu May 21 13:25:11 2009 +0200
@@ -128,7 +128,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['cancel_redirect'] = '/%(url_name)s/list' % params
new_params['public_redirect'] = None
new_params['sidebar'] = None
--- a/app/soc/views/models/base.py Wed May 20 12:32:36 2009 +0200
+++ b/app/soc/views/models/base.py Thu May 21 13:25:11 2009 +0200
@@ -914,7 +914,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['cancel_redirect'] = params.get('cancel_redirect')
context['return_url'] = request.path
if params.get('export_content_type') and entity:
--- a/app/soc/views/models/student_project.py Wed May 20 12:32:36 2009 +0200
+++ b/app/soc/views/models/student_project.py Thu May 21 13:25:11 2009 +0200
@@ -552,7 +552,7 @@
responses.useJavaScript(context, params['js_uses_all'])
context['page_name'] = page_name
# cancel should go to the public view
- params['edit_cancel_redirect'] = redirects.getPublicRedirect(entity, params)
+ params['cancel_redirect'] = redirects.getPublicRedirect(entity, params)
if request.POST:
return self.stEditPost(request, context, params, entity, **kwargs)