From e3ce2a9657245520676e8dfa0edc7410da01f6c1 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Thu, 1 Dec 2016 16:35:23 +0000 Subject: [PATCH] Tweaked the admin for doc.models.Document to capture a comment about changes made, and save those in the document history, using .save_with_history(). This makes the admin useful again for doing document changes. See issue #2067. - Legacy-Id: 12434 --- ietf/doc/admin.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ietf/doc/admin.py b/ietf/doc/admin.py index 5d4ebdb05..a9e81a749 100644 --- a/ietf/doc/admin.py +++ b/ietf/doc/admin.py @@ -80,6 +80,9 @@ class StatesField(forms.ModelMultipleChoiceField): class DocumentForm(forms.ModelForm): states = StatesField(queryset=State.objects.all(), required=False) + comment_about_changes = forms.CharField( + widget=forms.Textarea(attrs={'rows':10,'cols':40,'class':'vLargeTextField'}), + help_text="This comment about the changes made will be saved in the document history.") def __init__(self, *args, **kwargs): super(DocumentForm, self).__init__(*args, **kwargs) @@ -100,6 +103,15 @@ class DocumentAdmin(admin.ModelAdmin): inlines = [DocAliasInline, DocAuthorInline, RelatedDocumentInline, ] form = DocumentForm + def save_model(self, request, obj, form, change): + e = DocEvent.objects.create( + doc=obj, + by=request.user.person, + type='changed_document', + desc=form.cleaned_data.get('comment_about_changes'), + ) + obj.save_with_history([e]) + def state(self, instance): return self.get_state()