Ticket #11296: django_delete_objects_in_admin.diff
File django_delete_objects_in_admin.diff, 2.2 KB (added by , 15 years ago) |
---|
-
django/contrib/admin/util.py
71 71 except NoReverseMatch: 72 72 return '%s%s/%s/%s/' % ('../'*levels_to_root, app_label, module_name, pk) 73 73 74 def get_deleted_objects(deleted_objects, perms_needed, user, obj, opts, current_depth, admin_site, levels_to_root=4 ):74 def get_deleted_objects(deleted_objects, perms_needed, user, obj, opts, current_depth, admin_site, levels_to_root=4, opts_seen=[]): 75 75 """ 76 76 Helper function that recursively populates deleted_objects. 77 77 … … 85 85 nh = _nest_help # Bind to local variable for performance 86 86 if current_depth > 16: 87 87 return # Avoid recursing too deep. 88 opts_seen = []89 88 for related in opts.get_all_related_objects(): 90 89 has_admin = related.model in admin_site._registry 91 90 if related.opts in opts_seen: … … 119 118 admin_site, 120 119 levels_to_root), 121 120 escape(sub_obj))), []]) 122 get_deleted_objects(deleted_objects, perms_needed, user, sub_obj, related.opts, current_depth+2, admin_site )121 get_deleted_objects(deleted_objects, perms_needed, user, sub_obj, related.opts, current_depth+2, admin_site, opts_seen=opts_seen) 123 122 else: 124 123 has_related_objs = False 125 124 for sub_obj in getattr(obj, rel_opts_name).all(): … … 139 138 admin_site, 140 139 levels_to_root), 141 140 escape(sub_obj))), []]) 142 get_deleted_objects(deleted_objects, perms_needed, user, sub_obj, related.opts, current_depth+2, admin_site )141 get_deleted_objects(deleted_objects, perms_needed, user, sub_obj, related.opts, current_depth+2, admin_site, opts_seen=opts_seen) 143 142 # If there were related objects, and the user doesn't have 144 143 # permission to delete them, add the missing perm to perms_needed. 145 144 if has_admin and has_related_objs: