Ticket #11772: modelAdmin_model_modified_hook.2.diff

File modelAdmin_model_modified_hook.2.diff, 2.2 KB (added by Rupe, 6 years ago)

Added hook to the changelist_view() bulk update

  • django/contrib/admin/options.py

     
    562562        """
    563563        formset.save()
    564564
     565    def model_modified(self, request, changeType):
     566        """
     567        A hook to allow actions to happen on the modification of data.
     568
     569        changeType values: add, change, delete
     570        """
     571        pass
     572       
    565573    def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None):
    566574        opts = self.model._meta
    567575        app_label = opts.app_label
     
    736744                for formset in formsets:
    737745                    self.save_formset(request, form, formset, change=False)
    738746
     747                self.model_modified(request, 'add')
    739748                self.log_addition(request, new_object)
    740749                return self.response_add(request, new_object)
    741750        else:
     
    832841                for formset in formsets:
    833842                    self.save_formset(request, form, formset, change=True)
    834843
     844                self.model_modified(request, 'change')
    835845                change_message = self.construct_change_message(request, form, formsets)
    836846                self.log_change(request, new_object, change_message)
    837847                return self.response_change(request, new_object)
     
    929939                        obj = self.save_form(request, form, change=True)
    930940                        self.save_model(request, obj, form, change=True)
    931941                        form.save_m2m()
     942                        self.model_modified(request, 'change')
    932943                        change_msg = self.construct_change_message(request, form, None)
    933944                        self.log_change(request, obj, change_msg)
    934945                        changecount += 1
     
    10171028            self.log_deletion(request, obj, obj_display)
    10181029            obj.delete()
    10191030
     1031            self.model_modified(request, 'delete')
    10201032            self.message_user(request, _('The %(name)s "%(obj)s" was deleted successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj_display)})
    10211033
    10221034            if not self.has_change_permission(request, None):
Back to Top