Updated page admin/add form to use the same method for redirection as the 1.3 user...
authorStephen Burrows <stephen.r.burrows@gmail.com>
Wed, 27 Apr 2011 16:33:58 +0000 (12:33 -0400)
committerStephen Burrows <stephen.r.burrows@gmail.com>
Wed, 27 Apr 2011 16:33:58 +0000 (12:33 -0400)
admin/pages.py
templates/admin/philo/page/add_form.html

index 13d4098..f9e96c0 100644 (file)
@@ -46,6 +46,12 @@ class PageAdmin(ViewAdmin):
        list_filter = ('template',)
        search_fields = ['title', 'contentlets__content']
        inlines = [ContentletInline, ContentReferenceInline] + ViewAdmin.inlines
+       
+       def response_add(self, request, obj, post_url_continue='../%s/'):
+               # Shamelessly cribbed from django/contrib/auth/admin.py:143
+               if '_addanother' not in request.POST and '_popup' not in request.POST:
+                       request.POST['_continue'] = 1
+               return super(PageAdmin, self).response_add(request, obj, post_url_continue)
 
 
 class TemplateAdmin(TreeAdmin):
index 67f6ec4..b2a6358 100644 (file)
@@ -1,29 +1,14 @@
 {% extends "admin/change_form.html" %}
 {% load i18n %}
 
-{% block extrahead %}{{ block.super }}
-<!-- This will break if anything ever changes and may not work in all browsers. Sad face. -->
-<script type='text/javascript'>
-(function($){
-       $(function(){
-               $('#page_form input[type=submit]').click(function(e){
-                       if (e.target.name == '_addanother') {
-                               hidden = document.getElementById('page_form')._continue[0]
-                               hidden.parentNode.removeChild(hidden)
-                       }
-               })
-       })
-}(django.jQuery));
-</script>
-{% endblock %}
-
 {% block form_top %}
-       <p>{% trans "First, choose a template. After saving, you'll be able to provide additional content for containers." %}</p>
-       <input type="hidden" name="_continue" value="1" />
+       {% if not is_popup %}
+               <p>{% trans "First, choose a template. After saving, you'll be able to provide additional content for containers." %}</p>
+       {% else %}
+               <p>{% trans "Choose a template" %}</p>
+       {% endif %}
 {% endblock %}
 
-{% block content %}
-{% with 0 as save_on_top %}
-{{ block.super }}
-{% endwith %}
+{% block after_field_sets %}
+<script type="text/javascript">document.getElementById("id_name").focus();</script>
 {% endblock %}
\ No newline at end of file