Ticket #11772: modelAdmin_model_modified_hook.diff

File modelAdmin_model_modified_hook.diff, 1.8 KB (added by Joshua Russo, 15 years ago)
  • 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)
     
    10171027            self.log_deletion(request, obj, obj_display)
    10181028            obj.delete()
    10191029
     1030            self.model_modified(request, 'delete')
    10201031            self.message_user(request, _('The %(name)s "%(obj)s" was deleted successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj_display)})
    10211032
    10221033            if not self.has_change_permission(request, None):
Back to Top