diff --git a/mayan/apps/metadata/tests/test_wizard_steps.py b/mayan/apps/metadata/tests/test_wizard_steps.py index 66ab9ffd1f..8d99c05531 100644 --- a/mayan/apps/metadata/tests/test_wizard_steps.py +++ b/mayan/apps/metadata/tests/test_wizard_steps.py @@ -21,24 +21,26 @@ from .mixins import MetadataTypeTestMixin class DocumentUploadMetadataTestCase(MetadataTypeTestMixin, GenericDocumentViewTestCase): + auto_upload_document = False + def setUp(self): super(DocumentUploadMetadataTestCase, self).setUp() - self.login_user() self.source = WebFormSource.objects.create( enabled=True, label=TEST_SOURCE_LABEL, uncompress=TEST_SOURCE_UNCOMPRESS_N ) - self.document.delete() + #self.document.delete() self.document_type.metadata_type_relations.create( metadata_type=self.metadata_type, required=True ) + self.upload_url = furl(reverse(viewname='sources:upload_interactive')) + def test_upload_interactive_with_unicode_metadata(self): - url = furl(reverse(viewname='sources:upload_interactive')) - url.args['metadata0_id'] = self.metadata_type.pk - url.args['metadata0_value'] = TEST_METADATA_VALUE_UNICODE + self.upload_url.args['metadata0_id'] = self.metadata_type.pk + self.upload_url.args['metadata0_value'] = TEST_METADATA_VALUE_UNICODE self.grant_access( permission=permission_document_create, obj=self.document_type @@ -47,7 +49,7 @@ class DocumentUploadMetadataTestCase(MetadataTypeTestMixin, GenericDocumentViewT # Upload the test document with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_descriptor: response = self.post( - path=url, data={ + path=self.upload_url, data={ 'document-language': 'eng', 'source-file': file_descriptor, 'document_type_id': self.document_type.pk, } @@ -60,9 +62,8 @@ class DocumentUploadMetadataTestCase(MetadataTypeTestMixin, GenericDocumentViewT ) def test_upload_interactive_with_ampersand_metadata(self): - url = furl(reverse(viewname='sources:upload_interactive')) - url.args['metadata0_id'] = self.metadata_type.pk - url.args['metadata0_value'] = TEST_METADATA_VALUE_WITH_AMPERSAND + self.upload_url.args['metadata0_id'] = self.metadata_type.pk + self.upload_url.args['metadata0_value'] = TEST_METADATA_VALUE_WITH_AMPERSAND self.grant_access( permission=permission_document_create, obj=self.document_type @@ -70,7 +71,7 @@ class DocumentUploadMetadataTestCase(MetadataTypeTestMixin, GenericDocumentViewT # Upload the test document with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_descriptor: response = self.post( - path=url, data={ + path=self.upload_url, data={ 'document-language': 'eng', 'source-file': file_descriptor, 'document_type_id': self.document_type.pk, } @@ -81,3 +82,17 @@ class DocumentUploadMetadataTestCase(MetadataTypeTestMixin, GenericDocumentViewT Document.objects.first().metadata.first().value, TEST_METADATA_VALUE_WITH_AMPERSAND ) + + def test_initial_step_conditions(self): + self.grant_access( + permission=permission_document_create, obj=self.document_type + ) + + response = self.post( + viewname='sources:document_create_multiple', data={ + 'document_type_selection-document_type': self.document_type.pk, + 'document_create_wizard-current_step': 0 + } + ) + + self.assertContains(response=response, text='Step 2', status_code=200) diff --git a/mayan/apps/metadata/wizard_steps.py b/mayan/apps/metadata/wizard_steps.py index 0d76500fb0..62c352c57f 100644 --- a/mayan/apps/metadata/wizard_steps.py +++ b/mayan/apps/metadata/wizard_steps.py @@ -26,7 +26,7 @@ class WizardStepMetadata(WizardStep): document_type = cleaned_data.get('document_type') if document_type: - return document_type.metadata.exists() + return document_type.metadata_type_relations.exists() @classmethod def get_form_initial(cls, wizard): @@ -35,7 +35,7 @@ class WizardStepMetadata(WizardStep): step_data = wizard.get_cleaned_data_for_step(WizardStepDocumentType.name) if step_data: document_type = step_data['document_type'] - for document_type_metadata_type in document_type.metadata.all(): + for document_type_metadata_type in document_type.metadata_type_relations.all(): initial.append( { 'document_type': document_type,