From 5aa38868671478166df4c7c316768bded34c6f7f Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 2 Jul 2019 21:24:12 -0400 Subject: [PATCH] Fix cabinet upload wizard step Signed-off-by: Roberto Rosario --- mayan/apps/cabinets/tests/test_wizard_steps.py | 13 +++++++++++-- mayan/apps/cabinets/wizard_steps.py | 7 ++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/mayan/apps/cabinets/tests/test_wizard_steps.py b/mayan/apps/cabinets/tests/test_wizard_steps.py index 5fa5e471c1..d9feb3502d 100644 --- a/mayan/apps/cabinets/tests/test_wizard_steps.py +++ b/mayan/apps/cabinets/tests/test_wizard_steps.py @@ -1,5 +1,7 @@ from __future__ import unicode_literals +from django.utils.encoding import force_text + from mayan.apps.documents.models import Document from mayan.apps.documents.permissions import permission_document_create from mayan.apps.documents.tests import ( @@ -11,6 +13,7 @@ from mayan.apps.sources.tests.literals import ( ) from mayan.apps.sources.wizards import WizardStep +from ..models import Cabinet from ..wizard_steps import WizardStepCabinets from .mixins import CabinetTestMixin @@ -38,11 +41,14 @@ class CabinetDocumentUploadTestCase(CabinetTestMixin, GenericDocumentViewTestCas }, data={ 'document_type_id': self.test_document_type.pk, 'source-file': file_object, - 'cabinets': self.test_cabinet.pk + 'cabinets': ','.join( + map(force_text, Cabinet.objects.values_list('pk', flat=True)) + ) } ) def test_upload_interactive_view_with_access(self): + self._create_test_cabinet() self._create_test_cabinet() self.grant_access( obj=self.test_document_type, permission=permission_document_create @@ -51,7 +57,10 @@ class CabinetDocumentUploadTestCase(CabinetTestMixin, GenericDocumentViewTestCas self.assertEqual(response.status_code, 302) self.assertTrue( - self.test_cabinet in Document.objects.first().cabinets.all() + self.test_cabinets[0] in Document.objects.first().cabinets.all() + ) + self.assertTrue( + self.test_cabinets[1] in Document.objects.first().cabinets.all() ) def _request_wizard_view(self): diff --git a/mayan/apps/cabinets/wizard_steps.py b/mayan/apps/cabinets/wizard_steps.py index 230ad96564..eaa1f78965 100644 --- a/mayan/apps/cabinets/wizard_steps.py +++ b/mayan/apps/cabinets/wizard_steps.py @@ -51,7 +51,12 @@ class WizardStepCabinets(WizardStep): furl_instance = furl(querystring) Cabinet = apps.get_model(app_label='cabinets', model_name='Cabinet') - for cabinet in Cabinet.objects.filter(pk__in=furl_instance.args.getlist('cabinets')): + cabinet_id_list = furl_instance.args.get('cabinets', '') + + if cabinet_id_list: + cabinet_id_list = cabinet_id_list.split(',') + + for cabinet in Cabinet.objects.filter(pk__in=cabinet_id_list): cabinet.documents.add(document)