Convert the document version list view to item view mode.

Add document version preview and thumbnail widgets.
Update the new version upload event have the version
as the target and the document as the action object.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2017-08-02 03:54:21 -04:00
parent 7a29b2496b
commit 48fc36d54e
8 changed files with 163 additions and 35 deletions

View File

@@ -56,6 +56,22 @@ class DocumentPreviewForm(forms.Form):
preview = forms.CharField(widget=DocumentPagesCarouselWidget())
class DocumentVersionPreviewForm(forms.Form):
def __init__(self, *args, **kwargs):
document_version = kwargs.pop('instance', None)
super(DocumentVersionPreviewForm, self).__init__(*args, **kwargs)
self.fields['preview'].initial = document_version
try:
self.fields['preview'].label = _(
'Document pages (%d)'
) % document_version.pages.count()
except AttributeError:
self.fields['preview'].label = _('Document version pages (%d)') % 0
preview = forms.CharField(widget=DocumentPagesCarouselWidget())
class DocumentForm(forms.ModelForm):
"""
Form sub classes from DocumentForm used only when editing a document