Ticket #1416: admin.2.diff

File admin.2.diff, 5.4 KB (added by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu>, 19 years ago)

new patch

  • django/contrib/admin/views/main.py

     
    249249            # Here, we distinguish between different save types by checking for
    250250            # the presence of keys in request.POST.
    251251            if request.POST.has_key("_continue"):
    252                 request.user.message_set.add(message=msg + ' ' + _("You may edit it again below."))
     252                request.user.message_set.create(message=msg + ' ' + _("You may edit it again below."))
    253253                if request.POST.has_key("_popup"):
    254254                    post_url_continue += "?_popup=1"
    255255                return HttpResponseRedirect(post_url_continue % pk_value)
     
    257257                return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, %s, "%s");</script>' % \
    258258                    (pk_value, str(new_object).replace('"', '\\"')))
    259259            elif request.POST.has_key("_addanother"):
    260                 request.user.message_set.add(message=msg + ' ' + (_("You may add another %s below.") % opts.verbose_name))
     260                request.user.message_set.create(message=msg + ' ' + (_("You may add another %s below.") % opts.verbose_name))
    261261                return HttpResponseRedirect(request.path)
    262262            else:
    263                 request.user.message_set.add(message=msg)
     263                request.user.message_set.create(message=msg)
    264264                return HttpResponseRedirect(post_url)
    265265    else:
    266266        # Add default data.
     
    333333
    334334            msg = _('The %(name)s "%(obj)s" was changed successfully.') % {'name': opts.verbose_name, 'obj': new_object}
    335335            if request.POST.has_key("_continue"):
    336                 request.user.message_set.add(message=msg + ' ' + _("You may edit it again below."))
     336                request.user.message_set.create(message=msg + ' ' + _("You may edit it again below."))
    337337                if request.REQUEST.has_key('_popup'):
    338338                    return HttpResponseRedirect(request.path + "?_popup=1")
    339339                else:
    340340                    return HttpResponseRedirect(request.path)
    341341            elif request.POST.has_key("_saveasnew"):
    342                 request.user.message_set.add(message=_('The %(name)s "%(obj)s" was added successfully. You may edit it again below.') % {'name': opts.verbose_name, 'obj': new_object})
     342                request.user.message_set.create(message=_('The %(name)s "%(obj)s" was added successfully. You may edit it again below.') % {'name': opts.verbose_name, 'obj': new_object})
    343343                return HttpResponseRedirect("../%s/" % pk_value)
    344344            elif request.POST.has_key("_addanother"):
    345                 request.user.message_set.add(message=msg + ' ' + (_("You may add another %s below.") % opts.verbose_name))
     345                request.user.message_set.create(message=msg + ' ' + (_("You may add another %s below.") % opts.verbose_name))
    346346                return HttpResponseRedirect("../add/")
    347347            else:
    348                 request.user.message_set.add(message=msg)
     348                request.user.message_set.create(message=msg)
    349349                return HttpResponseRedirect("../")
    350350    else:
    351351        # Populate new_data with a "flattened" version of the current data.
     
    493493        obj_display = str(obj)
    494494        obj.delete()
    495495        LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(model).id, object_id, obj_display, DELETION)
    496         request.user.message_set.add(message=_('The %(name)s "%(obj)s" was deleted successfully.') % {'name': opts.verbose_name, 'obj': obj_display})
     496        request.user.message_set.create(message=_('The %(name)s "%(obj)s" was deleted successfully.') % {'name': opts.verbose_name, 'obj': obj_display})
    497497        return HttpResponseRedirect("../../")
    498498    extra_context = {
    499499        "title": _("Are you sure?"),
     
    504504    }
    505505    return render_to_response(["admin/%s/%s/delete_confirmation" % (app_label, opts.object_name.lower() ),
    506506                               "admin/%s/delete_confirmation" % app_label ,
    507                                "admin/delete_confirmation"], extra_context, context_instance=Context(request))
     507                               "admin/delete_confirmation"], extra_context, context_instance=template.RequestContext(request))
    508508delete_stage = staff_member_required(delete_stage)
    509509
    510510def history(request, app_label, model_name, object_id):
     
    512512    object_id = unquote(object_id)
    513513    if model is None:
    514514        raise Http404, "App %r, model %r, not found" % (app_label, model_name)
     515    opts = model._meta
    515516    action_list = LogEntry.objects.filter(object_id=object_id,
    516517        content_type__id__exact=ContentType.objects.get_for_model(model).id).select_related().order_by('action_time')
    517518    # If no history was found, see whether this object even exists.
     
    524525    }
    525526    return render_to_response(["admin/%s/%s/object_history" % (app_label, opts.object_name.lower() ),
    526527                               "admin/%s/object_history" % app_label ,
    527                                "admin/object_history"], extra_context, context_instance=Context(request))
     528                               "admin/object_history"], extra_context, context_instance=template.RequestContext(request))
    528529history = staff_member_required(history)
    529530
    530531class ChangeList(object):
Back to Top