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.

Backported from the development branch.

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 17b79e4114
commit 0ba84f256d
8 changed files with 164 additions and 35 deletions

View File

@@ -7,6 +7,7 @@ import uuid
from django.conf import settings
from django.core.files import File
from django.db import models, transaction
from django.template import Template, Context
from django.urls import reverse
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.timezone import now
@@ -395,7 +396,9 @@ class DocumentVersion(models.Model):
verbose_name_plural = _('Document version')
def __str__(self):
return '{0} - {1}'.format(self.document, self.timestamp)
return Template(
'{{ instance.document }} - {{ instance.timestamp }}'
).render(context=Context({'instance': self}))
def delete(self, *args, **kwargs):
for page in self.pages.all():
@@ -405,6 +408,9 @@ class DocumentVersion(models.Model):
return super(DocumentVersion, self).delete(*args, **kwargs)
def get_absolute_url(self):
return reverse('documents:document_version_view', args=(self.pk,))
def save(self, *args, **kwargs):
"""
Overloaded save method that updates the document version's checksum,
@@ -453,7 +459,7 @@ class DocumentVersion(models.Model):
else:
if new_document_version:
event_document_new_version.commit(
actor=user, target=self.document
actor=user, target=self, action_object=self.document
)
post_version_upload.send(sender=DocumentVersion, instance=self)