From 8c1a9c87986793731594b185994eba0c90b82c41 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sat, 6 Apr 2019 02:08:22 -0400 Subject: [PATCH] Fix multiple tag selection wizard step Signed-off-by: Roberto Rosario --- HISTORY.rst | 5 ++-- docs/releases/3.2.rst | 1 + mayan/apps/tags/tests/literals.py | 2 ++ mayan/apps/tags/tests/test_wizard_steps.py | 28 ++++++++++++++++++---- mayan/apps/tags/wizard_steps.py | 2 +- 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 01cf0be0d2..06355887cc 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,12 +1,13 @@ 3.2 (2019-04-XX) ================ -* Split sources models into separate modules +* Split sources models into separate modules. * Add support for subfolder scanning to watchfolders. Closes GitLab issue #498 and #563. * Updated the source check behavior to allow checking a source even when the source is disabled and to not deleted processed files during a check. -* Switch to full app paths +* Switch to full app paths. +* Fix multiple tag selection wizard step. 3.1.10 (2019-04-04) =================== diff --git a/docs/releases/3.2.rst b/docs/releases/3.2.rst index 15fb0ca755..12d440e0ce 100644 --- a/docs/releases/3.2.rst +++ b/docs/releases/3.2.rst @@ -24,6 +24,7 @@ Other changes ^^^^^^^^^^^^^ * Split source models into different modules. +* Fix multiple tag selection wizard step. Removals -------- diff --git a/mayan/apps/tags/tests/literals.py b/mayan/apps/tags/tests/literals.py index a1f714ab91..c1206eb2f1 100644 --- a/mayan/apps/tags/tests/literals.py +++ b/mayan/apps/tags/tests/literals.py @@ -5,6 +5,8 @@ TEST_TAG_LABEL_EDITED = 'test-tag-edited' TEST_TAG_COLOR = '#001122' TEST_TAG_COLOR_EDITED = '#221100' +TEST_TAG_LABEL_2 = 'test-tag-2' + TEST_TAG_INDEX_HAS_TAG = 'HAS_TAG' TEST_TAG_INDEX_NO_TAG = 'NO_TAG' TEST_TAG_INDEX_NODE_TEMPLATE = ''' diff --git a/mayan/apps/tags/tests/test_wizard_steps.py b/mayan/apps/tags/tests/test_wizard_steps.py index c82470c52c..7b4577fa9e 100644 --- a/mayan/apps/tags/tests/test_wizard_steps.py +++ b/mayan/apps/tags/tests/test_wizard_steps.py @@ -12,10 +12,12 @@ from mayan.apps.sources.tests.literals import ( from ..models import Tag -from .literals import TEST_TAG_COLOR, TEST_TAG_LABEL +from .literals import TEST_TAG_COLOR, TEST_TAG_LABEL, TEST_TAG_LABEL_2 class TaggedDocumentUploadTestCase(GenericDocumentViewTestCase): + auto_upload_document = False + def setUp(self): super(TaggedDocumentUploadTestCase, self).setUp() self.login_user() @@ -24,8 +26,6 @@ class TaggedDocumentUploadTestCase(GenericDocumentViewTestCase): uncompress=TEST_SOURCE_UNCOMPRESS_N ) - self.document.delete() - def _request_upload_interactive_document_create_view(self): with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object: return self.post( @@ -33,7 +33,7 @@ class TaggedDocumentUploadTestCase(GenericDocumentViewTestCase): data={ 'document_type_id': self.document_type.pk, 'source-file': file_object, - 'tags': self.tag.pk + 'tags': ','.join(map(str, Tag.objects.values_list('pk', flat=True))) } ) @@ -42,11 +42,31 @@ class TaggedDocumentUploadTestCase(GenericDocumentViewTestCase): color=TEST_TAG_COLOR, label=TEST_TAG_LABEL ) + def _create_tag_2(self): + self.tag_2 = Tag.objects.create( + color=TEST_TAG_COLOR, label=TEST_TAG_LABEL_2 + ) + def test_upload_interactive_view_with_access(self): self._create_tag() + self.grant_access( permission=permission_document_create, obj=self.document_type ) response = self._request_upload_interactive_document_create_view() self.assertEqual(response.status_code, 302) + self.assertTrue(self.tag in Document.objects.first().tags.all()) + + def test_upload_interactive_multiple_tags_view_with_access(self): + self._create_tag() + self._create_tag_2() + + self.grant_access( + permission=permission_document_create, obj=self.document_type + ) + response = self._request_upload_interactive_document_create_view() + self.assertEqual(response.status_code, 302) + + self.assertTrue(self.tag in Document.objects.first().tags.all()) + self.assertTrue(self.tag_2 in Document.objects.first().tags.all()) diff --git a/mayan/apps/tags/wizard_steps.py b/mayan/apps/tags/wizard_steps.py index 84dd5c6055..b1aab0a426 100644 --- a/mayan/apps/tags/wizard_steps.py +++ b/mayan/apps/tags/wizard_steps.py @@ -45,7 +45,7 @@ class WizardStepTags(WizardStep): furl_instance = furl(querystring) Tag = apps.get_model(app_label='tags', model_name='Tag') - for tag in Tag.objects.filter(pk__in=furl_instance.args.getlist('tags')): + for tag in Tag.objects.filter(pk__in=furl_instance.args['tags'].split(',')): tag.documents.add(document)