Ticket #1307: patch.diff

File patch.diff, 4.4 KB (added by mookai, 19 years ago)
  • models.py

     
    99
    1010class LogEntryManager(models.Manager):
    1111    def log_action(self, user_id, content_type_id, object_id, object_repr, action_flag, change_message=''):
    12         e = self.klass(None, None, user_id, content_type_id, object_id, object_repr[:200], action_flag, change_message)
     12        e = self.model(None, None, user_id, content_type_id, object_id, object_repr[:200], action_flag, change_message)
    1313        e.save()
    1414
    1515class LogEntry(models.Model):
  • views/main.py

     
    210210            # Here, we distinguish between different save types by checking for
    211211            # the presence of keys in request.POST.
    212212            if request.POST.has_key("_continue"):
    213                 request.user.add_message(msg + ' ' + _("You may edit it again below."))
     213                request.user.message_set.add(message=msg + ' ' + _("You may edit it again below."))
    214214                if request.POST.has_key("_popup"):
    215215                    post_url_continue += "?_popup=1"
    216216                return HttpResponseRedirect(post_url_continue % pk_value)
     
    218218                return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, %s, "%s");</script>' % \
    219219                    (pk_value, repr(new_object).replace('"', '\\"')))
    220220            elif request.POST.has_key("_addanother"):
    221                 request.user.add_message(msg + ' ' + (_("You may add another %s below.") % opts.verbose_name))
     221                request.user.message_set.add(message=msg + ' ' + (_("You may add another %s below.") % opts.verbose_name))
    222222                return HttpResponseRedirect(request.path)
    223223            else:
    224                 request.user.add_message(msg)
     224                request.user.message_set.add(message=msg)
    225225                return HttpResponseRedirect(post_url)
    226226    else:
    227227        # Add default data.
     
    293293
    294294            msg = _('The %(name)s "%(obj)s" was changed successfully.') % {'name': opts.verbose_name, 'obj': new_object}
    295295            if request.POST.has_key("_continue"):
    296                 request.user.add_message(msg + ' ' + _("You may edit it again below."))
     296                request.user.message_set.add(message=msg + ' ' + _("You may edit it again below."))
    297297                if request.REQUEST.has_key('_popup'):
    298298                    return HttpResponseRedirect(request.path + "?_popup=1")
    299299                else:
    300300                    return HttpResponseRedirect(request.path)
    301301            elif request.POST.has_key("_saveasnew"):
    302                 request.user.add_message(_('The %(name)s "%(obj)s" was added successfully. You may edit it again below.') % {'name': opts.verbose_name, 'obj': new_object})
     302                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})
    303303                return HttpResponseRedirect("../%s/" % pk_value)
    304304            elif request.POST.has_key("_addanother"):
    305                 request.user.add_message(msg + ' ' + (_("You may add another %s below.") % opts.verbose_name))
     305                request.user.message_set.add(message=msg + ' ' + (_("You may add another %s below.") % opts.verbose_name))
    306306                return HttpResponseRedirect("../add/")
    307307            else:
    308                 request.user.add_message(msg)
     308                request.user.message_set.add(message=msg)
    309309                return HttpResponseRedirect("../")
    310310    else:
    311311        # Populate new_data with a "flattened" version of the current data.
     
    452452        obj_display = str(obj)
    453453        obj.delete()
    454454        LogEntry.objects.log_action(request.user.id, opts.get_content_type_id(), object_id, obj_display, DELETION)
    455         request.user.add_message(_('The %(name)s "%(obj)s" was deleted successfully.') % {'name':opts.verbose_name, 'obj':obj_display})
     455        request.user.message_set.add(message=_('The %(name)s "%(obj)s" was deleted successfully.') % {'name':opts.verbose_name, 'obj':obj_display})
    456456        return HttpResponseRedirect("../../")
    457457    return render_to_response('admin/delete_confirmation', {
    458458        "title": _("Are you sure?"),
Back to Top