From dcc8b8b174cde4d282f3669548b75b4d4b2f187a Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 14 Jun 2019 00:31:46 -0400 Subject: [PATCH] Fix sub cabinet creation view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to Frédéric Sheedy (@fsheedy) for the report. Signed-off-by: Roberto Rosario --- docs/releases/3.2.1.rst | 103 ++++++++++++++++++++++++ docs/releases/index.rst | 1 + mayan/apps/cabinets/tests/mixins.py | 22 ++++- mayan/apps/cabinets/tests/test_views.py | 4 + mayan/apps/cabinets/views.py | 6 +- 5 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 docs/releases/3.2.1.rst diff --git a/docs/releases/3.2.1.rst b/docs/releases/3.2.1.rst new file mode 100644 index 0000000000..cf76e70b1a --- /dev/null +++ b/docs/releases/3.2.1.rst @@ -0,0 +1,103 @@ +Version 3.2.1 +============= + +Released: June 14, 2019 + + + +Changes +------- + +- Fix sub cabinet creation view. + + +Removals +-------- + +- None + + +Upgrading from a previous version +--------------------------------- + +If installed via Python's PIP +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Remove deprecated requirements:: + + $ curl https://gitlab.com/mayan-edms/mayan-edms/raw/master/removals.txt | pip uninstall -r /dev/stdin + +Type in the console:: + + $ pip install mayan-edms==3.2.1 + +the requirements will also be updated automatically. + + +Using Git +^^^^^^^^^ + +If you installed Mayan EDMS by cloning the Git repository issue the commands:: + + $ git reset --hard HEAD + $ git pull + +otherwise download the compressed archived and uncompress it overriding the +existing installation. + +Remove deprecated requirements:: + + $ pip uninstall -y -r removals.txt + +Next upgrade/add the new requirements:: + + $ pip install --upgrade -r requirements.txt + + +Common steps +^^^^^^^^^^^^ + +Perform these steps after updating the code from either step above. + +Make a backup of your supervisord file:: + + sudo cp /etc/supervisor/conf.d/mayan.conf /etc/supervisor/conf.d/mayan.conf.bck + +Update the supervisord configuration file. Replace the environment +variables values show here with your respective settings. This step will refresh +the supervisord configuration file with the new queues and the latest +recommended layout:: + + MAYAN_DATABASE_ENGINE=django.db.backends.postgresql MAYAN_DATABASE_NAME=mayan \ + MAYAN_DATABASE_PASSWORD=mayanuserpass MAYAN_DATABASE_USER=mayan \ + MAYAN_DATABASE_HOST=127.0.0.1 MAYAN_MEDIA_ROOT=/opt/mayan-edms/media \ + /opt/mayan-edms/bin/mayan-edms.py platformtemplate supervisord > /etc/supervisor/conf.d/mayan.conf + +Edit the supervisord configuration file and update any setting the template +generator missed:: + + vi /etc/supervisor/conf.d/mayan.conf + +Migrate existing database schema with:: + + $ mayan-edms.py performupgrade + +Add new static media:: + + $ mayan-edms.py preparestatic --noinput + +The upgrade procedure is now complete. + + +Backward incompatible changes +----------------------------- + +- None + + +Bugs fixed or issues closed +--------------------------- + +- :gitlab-issue:`601` Error when creating new cabinet level + +.. _PyPI: https://pypi.python.org/pypi/mayan-edms/ diff --git a/docs/releases/index.rst b/docs/releases/index.rst index b3d9a403a5..f28eff3a77 100644 --- a/docs/releases/index.rst +++ b/docs/releases/index.rst @@ -20,6 +20,7 @@ versions of the documentation contain the release notes for any later releases. .. toctree:: :maxdepth: 1 + 3.2.1 3.2 3.1.11 3.1.10 diff --git a/mayan/apps/cabinets/tests/mixins.py b/mayan/apps/cabinets/tests/mixins.py index 329d01ff9b..c1b15c6d8d 100644 --- a/mayan/apps/cabinets/tests/mixins.py +++ b/mayan/apps/cabinets/tests/mixins.py @@ -56,8 +56,14 @@ class CabinetAPIViewTestMixin(object): class CabinetTestMixin(object): + def setUp(self): + super(CabinetTestMixin, self).setUp() + if not hasattr(self, 'test_cabinets'): + self.test_cabinets = [] + def _create_test_cabinet(self): self.test_cabinet = Cabinet.objects.create(label=TEST_CABINET_LABEL) + self.test_cabinets.append(self.test_cabinet) def _create_test_cabinet_child(self): self.test_cabinet_child = Cabinet.objects.create( @@ -66,6 +72,11 @@ class CabinetTestMixin(object): class CabinetViewTestMixin(object): + def setUp(self): + super(CabinetViewTestMixin, self).setUp() + if not hasattr(self, 'test_cabinets'): + self.test_cabinets = [] + def _request_test_cabinet_create_view(self): # Typecast to list to force queryset evaluation values = list(Cabinet.objects.values_list('pk', flat=True)) @@ -77,6 +88,7 @@ class CabinetViewTestMixin(object): ) self.test_cabinet = Cabinet.objects.exclude(pk__in=values).first() + self.test_cabinets.append(self.test_cabinet) return response @@ -97,12 +109,20 @@ class CabinetViewTestMixin(object): ) def _request_test_cabinet_child_create_view(self): - return self.post( + # Typecast to list to force queryset evaluation + values = list(Cabinet.objects.values_list('pk', flat=True)) + + response = self.post( viewname='cabinets:cabinet_child_add', kwargs={ 'pk': self.test_cabinet.pk }, data={'label': TEST_CABINET_CHILD_LABEL} ) + self.test_cabinet = Cabinet.objects.exclude(pk__in=values).first() + self.test_cabinets.append(self.test_cabinet) + + return response + def _request_test_cabinet_child_delete_view(self): return self.post( viewname='cabinets:cabinet_delete', kwargs={ diff --git a/mayan/apps/cabinets/tests/test_views.py b/mayan/apps/cabinets/tests/test_views.py index 7f17e53058..894a01d3eb 100644 --- a/mayan/apps/cabinets/tests/test_views.py +++ b/mayan/apps/cabinets/tests/test_views.py @@ -127,7 +127,11 @@ class CabinetChildViewTestCase(CabinetTestMixin, CabinetViewTestMixin, GenericVi response = self._request_test_cabinet_child_create_view() self.assertEqual(response.status_code, 302) + self.test_cabinets[0].refresh_from_db() self.assertEqual(Cabinet.objects.count(), cabinet_count + 1) + self.assertTrue( + self.test_cabinets[1] in self.test_cabinets[0].get_descendants() + ) def test_cabinet_child_delete_view_no_permission(self): self._create_test_cabinet_child() diff --git a/mayan/apps/cabinets/views.py b/mayan/apps/cabinets/views.py index 364e65f740..8f589a8098 100644 --- a/mayan/apps/cabinets/views.py +++ b/mayan/apps/cabinets/views.py @@ -62,12 +62,16 @@ class CabinetChildAddView(ExternalObjectMixin, SingleObjectCreateView): 'object': self.external_object } + def get_instance_extra_data(self): + return { + 'parent': self.external_object, + } + def get_queryset(self): return self.external_object.get_descendants() def get_save_extra_data(self): return { - 'parent': self.external_object, '_user': self.request.user }