Code

Opened 8 years ago

Closed 8 years ago

Last modified 7 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
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: UI/UX:

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):

Attachments (0)

Change History (2)

comment:1 Changed 8 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:2 Changed 7 years ago by adrian

  • milestone Version 0.91 deleted

Milestone Version 0.91 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.