@@ -80,6 +80,9 @@ def clean(self, value):
8080
8181class DocumentForm (forms .ModelForm ):
8282 states = StatesField (queryset = State .objects .all (), required = False )
83+ comment_about_changes = forms .CharField (
84+ widget = forms .Textarea (attrs = {'rows' :10 ,'cols' :40 ,'class' :'vLargeTextField' }),
85+ help_text = "This comment about the changes made will be saved in the document history." )
8386
8487 def __init__ (self , * args , ** kwargs ):
8588 super (DocumentForm , self ).__init__ (* args , ** kwargs )
@@ -100,6 +103,15 @@ class DocumentAdmin(admin.ModelAdmin):
100103 inlines = [DocAliasInline , DocAuthorInline , RelatedDocumentInline , ]
101104 form = DocumentForm
102105
106+ def save_model (self , request , obj , form , change ):
107+ e = DocEvent .objects .create (
108+ doc = obj ,
109+ by = request .user .person ,
110+ type = 'changed_document' ,
111+ desc = form .cleaned_data .get ('comment_about_changes' ),
112+ )
113+ obj .save_with_history ([e ])
114+
103115 def state (self , instance ):
104116 return self .get_state ()
105117
0 commit comments