Change the way new document version are blocked, moving the logic to the documents app from the checkouts app signal handler. Disable the upload new document version button and have the new version upload view redirect to the document version list with a message. GitLab issue #231.

This commit is contained in:
Roberto Rosario
2015-10-23 06:06:59 -04:00
parent 414c55f824
commit da4c41c5b2
16 changed files with 395 additions and 141 deletions
+32 -1
View File
@@ -16,7 +16,9 @@ from user_management.tests.literals import (
)
from ..literals import DEFAULT_DELETE_PERIOD, DEFAULT_DELETE_TIME_UNIT
from ..models import DeletedDocument, Document, DocumentType, HASH_FUNCTION
from ..models import (
DeletedDocument, Document, DocumentType, NewVersionBlock, HASH_FUNCTION
)
from ..permissions import (
permission_document_download, permission_document_properties_edit,
permission_document_restore, permission_document_tools,
@@ -575,3 +577,32 @@ class DocumentTypeViewsTestCase(GenericDocumentViewTestCase):
DocumentType.objects.get(pk=self.document_type.pk).label,
TEST_DOCUMENT_TYPE_EDITED_LABEL
)
class NewDocumentVersionBlockViewTestCase(GenericDocumentViewTestCase):
def test_document_new_version_after_checkout(self):
"""
Gitlab issue #231
User shown option to upload new version of a document even though it
is blocked by checkout - v2.0.0b2
Expected results:
- Link to upload version view should not resolve
- Upload version view should reject request
"""
self.login(
username=TEST_ADMIN_USERNAME, password=TEST_ADMIN_PASSWORD
)
NewVersionBlock.objects.block(self.document)
response = self.post(
'sources:upload_version', args=(self.document.pk,),
follow=True
)
self.assertContains(
response, text='blocked from uploading',
status_code=200
)