Fix multiple tag selection wizard step

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2019-04-06 02:08:22 -04:00
committed by Roberto Rosario
parent 97fb5f96a7
commit 4d8dc8e552
6 changed files with 48 additions and 8 deletions

View File

@@ -1,10 +1,10 @@
from __future__ import unicode_literals
TEST_TAG_LABEL = 'test-tag'
TEST_TAG_LABEL_2 = 'test-tag-2'
TEST_TAG_LABEL_EDITED = 'test-tag-edited'
TEST_TAG_COLOR = '#001122'
TEST_TAG_COLOR_EDITED = '#221100'
TEST_TAG_INDEX_HAS_TAG = 'HAS_TAG'
TEST_TAG_INDEX_NO_TAG = 'NO_TAG'
TEST_TAG_INDEX_NODE_TEMPLATE = '''

View File

@@ -3,7 +3,7 @@ from __future__ import unicode_literals
from ..models import Tag
from .literals import (
TEST_TAG_COLOR, TEST_TAG_COLOR_EDITED, TEST_TAG_LABEL,
TEST_TAG_COLOR, TEST_TAG_COLOR_EDITED, TEST_TAG_LABEL, TEST_TAG_LABEL_2
TEST_TAG_LABEL_EDITED
)
@@ -14,6 +14,11 @@ class TagTestMixin(object):
color=TEST_TAG_COLOR, label=TEST_TAG_LABEL
)
def _create_test_tag_2(self):
self.test_tag_2 = Tag.objects.create(
color=TEST_TAG_COLOR, label=TEST_TAG_LABEL_2
)
class TagAPITestMixin(object):
def _request_api_tag_create_view(self):

View File

@@ -15,6 +15,8 @@ from .mixins import TagTestMixin
class TaggedDocumentUploadTestCase(TagTestMixin, GenericDocumentViewTestCase):
auto_upload_document = False
def setUp(self):
super(TaggedDocumentUploadTestCase, self).setUp()
self.source = WebFormSource.objects.create(
@@ -22,8 +24,6 @@ class TaggedDocumentUploadTestCase(TagTestMixin, 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(
@@ -32,15 +32,30 @@ class TaggedDocumentUploadTestCase(TagTestMixin, GenericDocumentViewTestCase):
data={
'document_type_id': self.document_type.pk,
'source-file': file_object,
'tags': self.test_tag.pk
'tags': ','.join(map(str, Tag.objects.values_list('pk', flat=True)))
}
)
def test_upload_interactive_view_with_access(self):
self._create_test_tag()
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.test_tag in Document.objects.first().tags.all())
self.assertTrue(self.test_tag_2 in Document.objects.first().tags.all())

View File

@@ -49,7 +49,7 @@ class WizardStepTags(WizardStep):
furl_instance = furl(args=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)