diff --git a/HISTORY.rst b/HISTORY.rst index 57ecc7f660..c199dc10d8 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,5 +1,5 @@ -3.1.5 (2018-10-7) -================= +3.1.5 (2018-10-08) +================== * Consolidate some document indexing test code into a new mixin. * Split the code of the mountindex command to be able to add tests. * Fix the way the children of IndexInstanceNode are accessed. Fixes GitLab @@ -31,9 +31,12 @@ Thanks to TheOneValen @TheOneValen for the report. * Add shared cache class and add mounted index cache invalidation when document and index instance nodes are updated or deleted. +* Fix document metadata app view error when adding multiple optional + metadata types. Closes GitLab issue #521. Thanks to the TheOneValen + @TheOneValen for the report. -3.1.4 (2018-10-4) -================= +3.1.4 (2018-10-04) +================== * Fix the link to the documenation. Closes GitLab issue #516. Thanks to Matthias Urlichs @smurfix for the report. * Update related links. Add links to the new Wiki and Forum. diff --git a/docs/releases/3.1.5.rst b/docs/releases/3.1.5.rst index 66d8a617f6..a931043364 100644 --- a/docs/releases/3.1.5.rst +++ b/docs/releases/3.1.5.rst @@ -2,7 +2,7 @@ Mayan EDMS v3.1.5 release notes =============================== -Released: October 7, 2018 +Released: October 8, 2018 Index mirroring fixes ~~~~~~~~~~~~~~~~~~~~~ @@ -59,6 +59,9 @@ Other changes Thanks to TheOneValen @TheOneValen for the report. * Add shared cache class and add mounted index cache invalidation when document and index instance nodes are updated or deleted. +* Fix document metadata app view error when adding multiple optional + metadata types. Closes GitLab issue #521. Thanks to the TheOneValen + @TheOneValen for the report. Removals -------- @@ -128,5 +131,6 @@ Bugs fixed or issues closed * `GitLab issue #518 `_ mountindex broken (3.1.x) * `GitLab issue #519 `_ Mail body fetched despite setting not to +* `GitLab issue #521 `_ Adding multiple metadata at once fails .. _PyPI: https://pypi.python.org/pypi/mayan-edms/ diff --git a/mayan/apps/metadata/tests/test_views.py b/mayan/apps/metadata/tests/test_views.py index 703a2614e6..db88b27fe4 100644 --- a/mayan/apps/metadata/tests/test_views.py +++ b/mayan/apps/metadata/tests/test_views.py @@ -303,6 +303,35 @@ class DocumentMetadataTestCase(GenericDocumentViewTestCase): self.assertContains(response, 'Edit', status_code=200) + def test_single_document_multiple_metadata_add_view(self): + self.login_user() + + self.grant_permission(permission=permission_document_view) + self.grant_permission(permission=permission_metadata_document_add) + self.grant_permission(permission=permission_metadata_document_edit) + + metadata_type_2 = MetadataType.objects.create( + name=TEST_METADATA_TYPE_NAME_2, label=TEST_METADATA_TYPE_LABEL_2 + ) + + self.document_type.metadata.create( + metadata_type=metadata_type_2 + ) + + response = self.post( + 'metadata:metadata_add', args=(self.document.pk,), data={ + 'metadata_type': [self.metadata_type.pk, metadata_type_2.pk], + } + ) + + document_metadata_types = self.document.metadata.values_list( + 'metadata_type', flat=True + ) + self.assertTrue( + self.metadata_type.pk in document_metadata_types and + metadata_type_2.pk in document_metadata_types + ) + class MetadataTypeViewTestCase(DocumentTestMixin, MetadataTestsMixin, GenericViewTestCase): auto_create_document_type = False diff --git a/mayan/apps/metadata/views.py b/mayan/apps/metadata/views.py index 0fdcb222fa..f88ebdfe1f 100644 --- a/mayan/apps/metadata/views.py +++ b/mayan/apps/metadata/views.py @@ -161,13 +161,13 @@ class DocumentMetadataAddView(MultipleObjectFormActionView): metadata_type=metadata_type, ) except DocumentMetadata.DoesNotExist: - instance = DocumentMetadata( + document_metadata = DocumentMetadata( document=instance, metadata_type=metadata_type, ) - instance.save(_user=self.request.user) + document_metadata.save(_user=self.request.user) created = True - except ValidationError as exception: + except Exception as exception: messages.error( self.request, _(