Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#1314 closed defect (fixed)

[patch] more bugfixes on admin for magic-removal branch

Reported by: jpaulofarias at gmail dot com Owned by: Adrian Holovaty
Component: contrib.admin Version: magic-removal
Severity: normal Keywords: admin
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Fixed more bugs I've found while trying magic-removal admin interface.

Index: django/contrib/admin/views/main.py
===================================================================
--- django/contrib/admin/views/main.py	(revision 2216)
+++ django/contrib/admin/views/main.py	(working copy)
@@ -218,7 +218,7 @@
                 return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, %s, "%s");</script>' % \
                     (pk_value, repr(new_object).replace('"', '\\"')))
             elif request.POST.has_key("_addanother"):
-                request.user.add_message(msg + ' ' + (_("You may add another %s below.") % opts.verbose_name))
+                request.user.message_set.add(message=msg + ' ' + (_("You may add another %s below.") % opts.verbose_name))
                 return HttpResponseRedirect(request.path)
             else:
                 request.user.add_message(msg)
@@ -387,7 +387,7 @@
                 _get_deleted_objects(deleted_objects, perms_needed, user, sub_obj, related.opts, current_depth+2)
         else:
             has_related_objs = False
-            for sub_obj in getattr(obj, 'get_%s_list' % rel_opts_name)():
+            for sub_obj in getattr(obj, '%s' % rel_opts_name).all():
                 has_related_objs = True
                 if related.field.rel.edit_inline or not related.opts.admin:
                     # Don't display link to edit, because it either has no
@@ -410,7 +410,7 @@
         opts_seen.append(related.opts)
         rel_opts_name = related.get_accessor_name()
         has_related_objs = False
-        for sub_obj in getattr(obj, 'get_%s_list' % rel_opts_name)():
+        for sub_obj in getattr(obj, '%s' % rel_opts_name).all():
             has_related_objs = True
             if related.field.rel.edit_inline or not related.opts.admin:
                 # Don't display link to edit, because it either has no
@@ -452,7 +452,7 @@
         obj_display = str(obj)
         obj.delete()
         LogEntry.objects.log_action(request.user.id, opts.get_content_type_id(), object_id, obj_display, DELETION)
-        request.user.add_message(_('The %(name)s "%(obj)s" was deleted successfully.') % {'name':opts.verbose_name, 'obj':obj_display})
+        request.user.message_set.add(message=_('The %(name)s "%(obj)s" was deleted successfully.') % {'name':opts.verbose_name, 'obj':obj_display})
         return HttpResponseRedirect("../../")
     return render_to_response('admin/delete_confirmation', {
         "title": _("Are you sure?"),
Index: django/db/models/base.py
===================================================================
--- django/db/models/base.py	(revision 2216)
+++ django/db/models/base.py	(working copy)
@@ -211,7 +211,7 @@
                 else:
                     sub_obj.__collect_sub_objects(seen_objs)
             else:
-                for sub_obj in getattr(self, 'get_%s_list' % rel_opts_name)():
+                for sub_obj in getattr(self, '%s_set' % rel_opts_name).all():
                     sub_obj.__collect_sub_objects(seen_objs)
 
     def delete(self):

Change History (2)

comment:1 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

(In [2217]) magic-removal: Fixed #1314 -- Made bugfixes for admin interface. Thanks, jpaulofarias

comment:2 by Adrian Holovaty, 18 years ago

milestone: Version 0.91

Milestone Version 0.91 deleted

Note: See TracTickets for help on using tickets.
Back to Top