Ticket #11772: modelAdmin_model_modified_hook.2.diff
File modelAdmin_model_modified_hook.2.diff, 2.2 KB (added by , 15 years ago) |
---|
-
django/contrib/admin/options.py
562 562 """ 563 563 formset.save() 564 564 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 565 573 def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None): 566 574 opts = self.model._meta 567 575 app_label = opts.app_label … … 736 744 for formset in formsets: 737 745 self.save_formset(request, form, formset, change=False) 738 746 747 self.model_modified(request, 'add') 739 748 self.log_addition(request, new_object) 740 749 return self.response_add(request, new_object) 741 750 else: … … 832 841 for formset in formsets: 833 842 self.save_formset(request, form, formset, change=True) 834 843 844 self.model_modified(request, 'change') 835 845 change_message = self.construct_change_message(request, form, formsets) 836 846 self.log_change(request, new_object, change_message) 837 847 return self.response_change(request, new_object) … … 929 939 obj = self.save_form(request, form, change=True) 930 940 self.save_model(request, obj, form, change=True) 931 941 form.save_m2m() 942 self.model_modified(request, 'change') 932 943 change_msg = self.construct_change_message(request, form, None) 933 944 self.log_change(request, obj, change_msg) 934 945 changecount += 1 … … 1017 1028 self.log_deletion(request, obj, obj_display) 1018 1029 obj.delete() 1019 1030 1031 self.model_modified(request, 'delete') 1020 1032 self.message_user(request, _('The %(name)s "%(obj)s" was deleted successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj_display)}) 1021 1033 1022 1034 if not self.has_change_permission(request, None):