Ticket #7982: ticket7982against8487.diff

File ticket7982against8487.diff, 4.6 KB (added by sebastian.hillig, 16 years ago)

Patch, not yet finished

  • django/contrib/admin/options.py

     
    180180    def __call__(self, request, url):
    181181        # Delegate to the appropriate method, based on the URL.
    182182        if url is None:
    183             return self.changelist_view(request)
     183            return HttpResponseRedirect("objects/")
     184        elif url.startswith('objects'):
     185            if url.endswith('objects'):
     186                return self.changelist_view(request)
     187            elif len(url.split("/")) == 3 and url.endswith('history'):
     188                return self.history_view(request, unquote(url[8:-8]))
     189            elif len(url.split("/")) == 3 and url.endswith('delete'):
     190                return self.delete_view(request, unquote(url[8:-7]))
     191            else:
     192                return self.change_view(request, unquote(url[8:]))
    184193        elif url.endswith('add'):
    185194            return self.add_view(request)
    186         elif url.endswith('history'):
    187             return self.history_view(request, unquote(url[:-8]))
    188         elif url.endswith('delete'):
    189             return self.delete_view(request, unquote(url[:-7]))
    190195        else:
    191             return self.change_view(request, unquote(url))
     196            return Http404("There is currently no view assigned to that address") #TODO: Replace me with something better
    192197
     198
    193199    def _media(self):
    194200        from django.conf import settings
    195201
     
    398404            "admin/change_form.html"
    399405        ], context, context_instance=template.RequestContext(request))
    400406   
    401     def response_add(self, request, obj, post_url_continue='../%s/'):
     407    def response_add(self, request, obj, post_url_continue='../objects/%s/'):
    402408        """
    403409        Determines the HttpResponse for the add_view stage.
    404410        """
     
    409415        # Here, we distinguish between different save types by checking for
    410416        # the presence of keys in request.POST.
    411417        if request.POST.has_key("_continue"):
     418            print pk_value
     419            print escape(pk_value)
     420            print force_unicode(pk_value)
    412421            self.message_user(request, msg + ' ' + _("You may edit it again below."))
    413422            if request.POST.has_key("_popup"):
    414423                post_url_continue += "?_popup=1"
    415             return HttpResponseRedirect(post_url_continue % pk_value)
     424            return HttpResponseRedirect(post_url_continue % escape(pk_value))
    416425       
    417426        if request.POST.has_key("_popup"):
    418427            return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script>' % \
     
    420429                (escape(pk_value), escape(obj)))
    421430        elif request.POST.has_key("_addanother"):
    422431            self.message_user(request, msg + ' ' + (_("You may add another %s below.") % force_unicode(opts.verbose_name)))
    423             return HttpResponseRedirect(request.path)
     432            return HttpResponseRedirect(request.path) #TODO: Fix this when save and add from an existing object
    424433        else:
    425434            self.message_user(request, msg)
    426435
  • django/contrib/admin/templates/admin/change_list.html

     
    55
    66{% block bodyclass %}change-list{% endblock %}
    77
    8 {% if not is_popup %}{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">{% trans "Home" %}</a> &rsaquo; <a href="../">{{ app_label|capfirst|escape }}</a> &rsaquo; {{ cl.opts.verbose_name_plural|capfirst|escape }}</div>{% endblock %}{% endif %}
     8{% if not is_popup %}{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../../">{% trans "Home" %}</a> &rsaquo; <a href="../../">{{ app_label|capfirst|escape }}</a> &rsaquo; {{ cl.opts.verbose_name_plural|capfirst|escape }} </div>{% endblock %}{% endif %}
    99
    1010{% block coltype %}flex{% endblock %}
    1111
     
    1313<div id="content-main">
    1414{% block object-tools %}
    1515{% if has_add_permission %}
    16 <ul class="object-tools"><li><a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">{% blocktrans with cl.opts.verbose_name|escape as name %}Add {{ name }}{% endblocktrans %}</a></li></ul>
     16<ul class="object-tools"><li><a href="../add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">{% blocktrans with cl.opts.verbose_name|escape as name %}Add {{ name }}{% endblocktrans %}</a></li></ul>
    1717{% endif %}
    1818{% endblock %}
    1919<div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
Back to Top