Move retention policies enforcement code to the DocumentType model manager. Add corresponding tests (test_auto_trashing and test_auto_delete).

This commit is contained in:
Roberto Rosario
2015-09-27 00:35:56 -04:00
parent 22a29eede3
commit 3e7cd0c1ea
4 changed files with 119 additions and 62 deletions

View File

@@ -100,6 +100,10 @@ class DocumentType(models.Model):
return super(DocumentType, self).delete(*args, **kwargs)
@property
def deleted_documents(self):
return DeletedDocument.objects.filter(document_type=self)
def new_document(self, file_object, label=None, description=None, language=None, _user=None):
try:
with transaction.atomic():