Update documents app
Rename the DeletedDocument proxy model to a TrashedDocument. Rename the deleted_document views to trashed_document. Rename the document and deleted_document URL parameters to trashed_document. Update URL parameters to the '_id' form. Add keyword arguments. Update use of .filter_by_access(). Enclose trashed document restore method in a transaction. Sort arguments. Update app for compliance with MERCs 5 and 6. Add document page view tests. Add favorite document view tests. Movernize tests. Replace use of urlencode with furl. Update views to use ExternalObjectMixin. Refactor the document and version download views. Rename the DocumentDocumentTypeEditView to DocumentChangeTypeView. Move the trashed document views to their own module. Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
@@ -31,8 +31,8 @@ from ..signals import post_document_type_change
|
||||
from .document_type_models import DocumentType
|
||||
|
||||
__all__ = (
|
||||
'Document', 'DeletedDocument', 'DuplicatedDocument', 'FavoriteDocument',
|
||||
'RecentDocument'
|
||||
'Document', 'DuplicatedDocument', 'FavoriteDocument', 'RecentDocument',
|
||||
'TrashedDocument'
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -137,7 +137,7 @@ class Document(models.Model):
|
||||
def get_absolute_url(self):
|
||||
return reverse(
|
||||
viewname='documents:document_preview',
|
||||
kwargs={'document_pk': self.pk}
|
||||
kwargs={'document_id': self.pk}
|
||||
)
|
||||
|
||||
def get_api_image_url(self, *args, **kwargs):
|
||||
@@ -279,13 +279,6 @@ class Document(models.Model):
|
||||
return DocumentPage.objects.none()
|
||||
|
||||
|
||||
class DeletedDocument(Document):
|
||||
objects = TrashCanManager()
|
||||
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class DuplicatedDocument(models.Model):
|
||||
document = models.ForeignKey(
|
||||
@@ -316,9 +309,9 @@ class DuplicatedDocumentProxy(Document):
|
||||
verbose_name_plural = _('Duplicated documents')
|
||||
|
||||
def get_duplicate_count(self, user):
|
||||
queryset = AccessControlList.objects.filter_by_access(
|
||||
permission=permission_document_view, user=user,
|
||||
queryset=self.get_duplicates()
|
||||
queryset = AccessControlList.objects.restrict_queryset(
|
||||
permission=permission_document_view, queryset=self.get_duplicates(),
|
||||
user=user
|
||||
)
|
||||
return queryset.count()
|
||||
|
||||
@@ -382,3 +375,10 @@ class RecentDocument(models.Model):
|
||||
def natural_key(self):
|
||||
return (self.datetime_accessed, self.document.natural_key(), self.user.natural_key())
|
||||
natural_key.dependencies = ['documents.Document', settings.AUTH_USER_MODEL]
|
||||
|
||||
|
||||
class TrashedDocument(Document):
|
||||
objects = TrashCanManager()
|
||||
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
Reference in New Issue
Block a user