Ticket #5490: urlquote.diff

File urlquote.diff, 2.8 KB (added by tlpinney, 16 years ago)
  • django/contrib/admin/models.py

    diff --git a/django/contrib/admin/models.py b/django/contrib/admin/models.py
    index 23c8661..49ed868 100644
    a b from django.contrib.auth.models import User  
    44from django.utils.translation import ugettext_lazy as _
    55from django.utils.encoding import smart_unicode
    66from django.utils.safestring import mark_safe
     7from django.utils.html import urlquote
     8
    79
    810ADDITION = 1
    911CHANGE = 2
    class LogEntry(models.Model):  
    4143    def is_deletion(self):
    4244        return self.action_flag == DELETION
    4345
     46
    4447    def get_edited_object(self):
    4548        "Returns the edited object represented by this log entry"
    4649        return self.content_type.get_object_for_this_type(pk=self.object_id)
    class LogEntry(models.Model):  
    5053        Returns the admin URL to edit the object represented by this log entry.
    5154        This is relative to the Django admin index page.
    5255        """
    53         return mark_safe(u"%s/%s/%s/" % (self.content_type.app_label, self.content_type.model, self.object_id))
     56        return mark_safe(u"%s/%s/%s/" % (self.content_type.app_label, self.content_type.model, urlquote(self.object_id)))
  • django/contrib/admin/templatetags/admin_list.py

    diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py
    index 1757906..e025de9 100644
    a b from django.contrib.admin.views.main import ORDER_VAR, ORDER_TYPE_VAR, PAGE_VAR,  
    44from django.core.exceptions import ObjectDoesNotExist
    55from django.db import models
    66from django.utils import dateformat
    7 from django.utils.html import escape, conditional_escape
     7from django.utils.html import escape, conditional_escape, urlquote
    88from django.utils.text import capfirst
    99from django.utils.safestring import mark_safe
    1010from django.utils.translation import get_date_formats, get_partial_date_formats, ugettext as _
    def items_for_result(cl, result):  
    194194            # Convert the pk to something that can be used in Javascript.
    195195            # Problem cases are long ints (23L) and non-ASCII strings.
    196196            result_id = repr(force_unicode(getattr(result, pk)))[1:]
     197
    197198            yield mark_safe(u'<%s%s><a href="%s"%s>%s</a></%s>' % \
    198                 (table_tag, row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %s); return false;"' % result_id or ''), conditional_escape(result_repr), table_tag))
     199                (table_tag, row_class, urlquote(url), (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %s); return false;"' % result_id or ''), conditional_escape(result_repr), table_tag))
    199200        else:
    200201            yield mark_safe(u'<td%s>%s</td>' % (row_class, conditional_escape(result_repr)))
    201202
Back to Top