Ticket #5490: ecaping_url.patch
File ecaping_url.patch, 7.4 KB (added by , 17 years ago) |
---|
-
django/contrib/admin/models.py
49 49 Returns the admin URL to edit the object represented by this log entry. 50 50 This is relative to the Django admin index page. 51 51 """ 52 return u"%s/%s/%s/" % (self.content_type.app_label, self.content_type.model, self.object_id) 52 from django.contrib.admin.views.main import quote 53 return u"%s/%s/%s/" % (self.content_type.app_label, self.content_type.model, quote(self.object_id)) -
django/contrib/admin/options.py
190 190 def fieldsets_add(self, request): 191 191 "Hook for specifying fieldsets for the add form." 192 192 raise NotImplementedError 193 193 194 194 def fieldsets_change(self, request, obj): 195 195 "Hook for specifying fieldsets for the change form." 196 196 raise NotImplementedError … … 198 198 class ModelAdmin(BaseModelAdmin): 199 199 "Encapsulates all admin options and functionality for a given model." 200 200 __metaclass__ = forms.MediaDefiningClass 201 201 202 202 list_display = ('__str__',) 203 203 list_display_links = () 204 204 list_filter = () … … 256 256 js.extend(['js/getElementsBySelector.js', 'js/dom-drag.js' , 'js/admin/ordering.js']) 257 257 if self.filter_vertical or self.filter_horizontal: 258 258 js.extend(['js/SelectBox.js' , 'js/SelectFilter2.js']) 259 259 260 260 return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js]) 261 261 media = property(_media) 262 262 263 263 def has_add_permission(self, request): 264 264 "Returns True if the given request has permission to add an object." 265 265 opts = self.opts … … 394 394 Saves the object in the "change" stage and returns an HttpResponseRedirect. 395 395 396 396 `form` is a bound Form instance that's verified to be valid. 397 397 398 398 `formsets` is a sequence of InlineFormSet instances that are verified to be valid. 399 399 """ 400 400 from django.contrib.admin.models import LogEntry, CHANGE … … 545 545 #related.get_accessor_name()) 546 546 #orig_list = func() 547 547 #oldform.order_objects.extend(orig_list) 548 548 549 549 adminForm = AdminForm(form, self.fieldsets_change(request, obj), self.prepopulated_fields) 550 550 media = self.media + adminForm.media 551 551 for fs in inline_formsets: … … 601 601 "The 'delete' admin view for this model." 602 602 from django.contrib.contenttypes.models import ContentType 603 603 from django.contrib.admin.models import LogEntry, DELETION 604 from django.contrib.admin.views.main import quote 604 605 opts = self.model._meta 605 606 app_label = opts.app_label 606 607 … … 620 621 621 622 # Populate deleted_objects, a data structure of all related objects that 622 623 # will also be deleted. 623 deleted_objects = [u'%s: <a href="../../%s/">%s</a>' % (force_unicode(capfirst(opts.verbose_name)), object_id, escape(str(obj))), []]624 deleted_objects = [u'%s: <a href="../../%s/">%s</a>' % (force_unicode(capfirst(opts.verbose_name)), quote(object_id), escape(str(obj))), []] 624 625 perms_needed = sets.Set() 625 626 get_deleted_objects(deleted_objects, perms_needed, request.user, obj, opts, 1) 626 627 -
django/contrib/admin/util.py
12 12 13 13 def get_deleted_objects(deleted_objects, perms_needed, user, obj, opts, current_depth): 14 14 "Helper function that recursively populates deleted_objects." 15 from django.contrib.admin.views.main import quote 15 16 nh = _nest_help # Bind to local variable for performance 16 17 if current_depth > 16: 17 18 return # Avoid recursing too deep. … … 36 37 if related.field.rel.edit_inline or not related.opts.admin: 37 38 # Don't display link to edit, because it either has no 38 39 # admin or is edited inline. 39 nh(deleted_objects, current_depth, [u'%s: %s' % (force_unicode(capfirst(related.opts.verbose_name)), sub_obj), []])40 nh(deleted_objects, current_depth, [u'%s: %s' % (force_unicode(capfirst(related.opts.verbose_name)), escape(sub_obj)), []]) 40 41 else: 41 42 # Display a link to the admin page. 42 43 nh(deleted_objects, current_depth, [u'%s: <a href="../../../../%s/%s/%s/">%s</a>' % \ 43 44 (force_unicode(capfirst(related.opts.verbose_name)), related.opts.app_label, related.opts.object_name.lower(), 44 sub_obj._get_pk_val(), sub_obj), []])45 quote(sub_obj._get_pk_val()), escape(sub_obj)), []]) 45 46 get_deleted_objects(deleted_objects, perms_needed, user, sub_obj, related.opts, current_depth+2) 46 47 else: 47 48 has_related_objs = False … … 54 55 else: 55 56 # Display a link to the admin page. 56 57 nh(deleted_objects, current_depth, [u'%s: <a href="../../../../%s/%s/%s/">%s</a>' % \ 57 (force_unicode(capfirst(related.opts.verbose_name)), related.opts.app_label, related.opts.object_name.lower(), sub_obj._get_pk_val(), escape(sub_obj)), []])58 (force_unicode(capfirst(related.opts.verbose_name)), related.opts.app_label, related.opts.object_name.lower(), quote(sub_obj._get_pk_val()), escape(sub_obj)), []]) 58 59 get_deleted_objects(deleted_objects, perms_needed, user, sub_obj, related.opts, current_depth+2) 59 60 # If there were related objects, and the user doesn't have 60 61 # permission to delete them, add the missing perm to perms_needed. … … 87 88 nh(deleted_objects, current_depth, [ 88 89 (_('One or more %(fieldname)s in %(name)s:') % {'fieldname': force_unicode(related.field.verbose_name), 'name': force_unicode(related.opts.verbose_name)}) + \ 89 90 (u' <a href="../../../../%s/%s/%s/">%s</a>' % \ 90 (related.opts.app_label, related.opts.module_name, sub_obj._get_pk_val(), escape(sub_obj))), []])91 (related.opts.app_label, related.opts.module_name, quote(sub_obj._get_pk_val()), escape(sub_obj))), []]) 91 92 # If there were related objects, and the user doesn't have 92 93 # permission to change them, add the missing perm to perms_needed. 93 94 if related.opts.admin and has_related_objs: -
django/contrib/admin/views/main.py
43 43 quoting is slightly different so that it doesn't get automatically 44 44 unquoted by the Web browser. 45 45 """ 46 if type(s) != type(''): 47 return s 46 if not isinstance(s,basestring): return s 48 47 res = list(s) 49 48 for i in range(len(res)): 50 49 c = res[i] 51 if c in ':/_ ':50 if c in ':/_#?;@&=+$,"<>%': 52 51 res[i] = '_%02X' % ord(c) 53 52 return ''.join(res) 54 53