Fix document metadata app view error when adding multiple optional metadata types. Closes GitLab issue #521. Thanks to the TheOneValen @TheOneValen for the report.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-10-08 19:51:17 -04:00
parent 7ff974382b
commit 4ad84195e0
4 changed files with 44 additions and 8 deletions

View File

@@ -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.

View File

@@ -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 <https://gitlab.com/mayan-edms/mayan-edms/issues/518>`_ mountindex broken (3.1.x)
* `GitLab issue #519 <https://gitlab.com/mayan-edms/mayan-edms/issues/519>`_ Mail body fetched despite setting not to
* `GitLab issue #521 <https://gitlab.com/mayan-edms/mayan-edms/issues/521>`_ Adding multiple metadata at once fails
.. _PyPI: https://pypi.python.org/pypi/mayan-edms/

View File

@@ -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

View File

@@ -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,
_(