From 5c9ff90d288e48d0cec78f6446fcc904df72da16 Mon Sep 17 00:00:00 2001 From: Manoel Brunnen Date: Sun, 3 Feb 2019 12:10:51 +0100 Subject: [PATCH 1/6] Fix libssl-dev dependency installation The apt package informations have already been removed at this point. Also, this dependency is not armhf specific. --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 9448ab895e..d86097fb09 100755 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -47,6 +47,7 @@ apt-get install -y --no-install-recommends \ supervisor \ tesseract-ocr \ zlib1g-dev \ + libssl-dev \ && \ apt-get clean autoclean && \ apt-get autoremove --purge -y && \ @@ -67,7 +68,6 @@ ln -s /usr/lib/aarch64-linux-gnu/libjpeg.so /usr/lib/ \ # Pillow can't find zlib or libjpeg on armv7l (ODROID HC1) RUN if [ "$(uname -m)" = "armv7l" ]; then \ -apt-get install libssl-dev -y && \ ln -s /usr/lib/arm-linux-gnueabihf/libz.so /usr/lib/ && \ ln -s /usr/lib/arm-linux-gnueabihf/libjpeg.so /usr/lib/ \ ; fi From bda4902bc753bacddba784661aab9ca40dbabbf9 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 2 Apr 2019 13:38:02 -0400 Subject: [PATCH 2/6] Checkout manager optimization Signed-off-by: Roberto Rosario --- mayan/apps/checkouts/managers.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mayan/apps/checkouts/managers.py b/mayan/apps/checkouts/managers.py index 1eca803a63..fd24c58459 100644 --- a/mayan/apps/checkouts/managers.py +++ b/mayan/apps/checkouts/managers.py @@ -96,10 +96,7 @@ class DocumentCheckoutManager(models.Manager): return expired_list def is_document_checked_out(self, document): - if self.filter(document=document).exists(): - return True - else: - return False + return self.filter(document=document).exists() class NewVersionBlockManager(models.Manager): From b6e0de01f3fd6dd37c5b609b91ada5307bb72c20 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 2 Apr 2019 13:38:21 -0400 Subject: [PATCH 3/6] Make random PK mixin work with pre_save signals Signed-off-by: Roberto Rosario --- mayan/apps/common/tests/mixins.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/mayan/apps/common/tests/mixins.py b/mayan/apps/common/tests/mixins.py index a729e7d280..26c76d0278 100644 --- a/mayan/apps/common/tests/mixins.py +++ b/mayan/apps/common/tests/mixins.py @@ -11,8 +11,8 @@ from django.conf import settings from django.conf.urls import url from django.contrib.contenttypes.models import ContentType from django.core import management -from django.db import connection -from django.db import models +from django.db import connection. models +from django.db.models.signals import post_save, pre_save from django.http import HttpResponse from django.template import Context, Template from django.test.utils import ContextList @@ -176,12 +176,35 @@ class RandomPrimaryKeyModelMonkeyPatchMixin(object): if instance.pk: return self.method_save_original(instance, *args, **kwargs) else: + # Set meta.auto_created to True to have the original save_base + # not send the pre_save signal which would normally send + # the instance without a primary key. Since we assign a random + # primary key any pre_save signal handler that relies on an + # empty primary key will fail. + # The meta.auto_created and manual pre_save sending emulates + # the original behavior. Since meta.auto_created also disables + # the post_save signal we must also send it ourselves. + # This hack work with Django 1.11 .save_base() but can break + # in future versions if that method is updated. + pre_save.send( + sender=instance.__class__, instance=instance, raw=False, + update_fields=None, + ) + instance._meta.auto_created = True instance.pk = RandomPrimaryKeyModelMonkeyPatchMixin.get_unique_primary_key( model=instance._meta.model ) instance.id = instance.pk - return instance.save_base(force_insert=True) + result = instance.save_base(force_insert=True) + instance._meta.auto_created = False + + post_save.send( + sender=instance.__class__, instance=instance, created=True, + update_fields=None, raw=False + ) + + return result setattr(models.Model, 'save', method_save_new) super(RandomPrimaryKeyModelMonkeyPatchMixin, self).setUp() From 83a4368eef7d99bce47f7ab402bfd3feb8e94c8b Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 2 Apr 2019 13:39:00 -0400 Subject: [PATCH 4/6] Simplify document indexing test Signed-off-by: Roberto Rosario --- mayan/apps/document_indexing/tests/test_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mayan/apps/document_indexing/tests/test_models.py b/mayan/apps/document_indexing/tests/test_models.py index acaff8e9a4..7a5bf488e3 100644 --- a/mayan/apps/document_indexing/tests/test_models.py +++ b/mayan/apps/document_indexing/tests/test_models.py @@ -79,7 +79,7 @@ class IndexTestCase(IndexTemplateTestMixin, DocumentTestMixin, BaseTestCase): self._create_document() self.assertEqual( - [instance.value for instance in IndexInstanceNode.objects.all()], + list(IndexInstanceNode.objects.values_list('value', flat=True)), [ '', force_text(self.test_document.date_added.year), force_text(self.test_document.date_added.month) From eb6f88dfd160b4a77c6614a98dd727eece76ae9f Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 2 Apr 2019 13:39:21 -0400 Subject: [PATCH 5/6] Fix user management tests Signed-off-by: Roberto Rosario --- .../apps/user_management/tests/test_views.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/mayan/apps/user_management/tests/test_views.py b/mayan/apps/user_management/tests/test_views.py index f1b6ff0a8e..2d806520e9 100644 --- a/mayan/apps/user_management/tests/test_views.py +++ b/mayan/apps/user_management/tests/test_views.py @@ -270,11 +270,12 @@ class UserViewsTestCase(GroupTestMixin, UserTestMixin, UserViewTestMixin, Generi self.logout() - with self.assertRaises(AssertionError): - self.login( - username=self.test_user.username, - password=TEST_USER_PASSWORD_EDITED - ) + result = self.login( + username=self.test_user.username, + password=TEST_USER_PASSWORD_EDITED + ) + + self.assertFalse(result) response = self.get(viewname='user_management:current_user_details') @@ -318,11 +319,12 @@ class UserViewsTestCase(GroupTestMixin, UserTestMixin, UserViewTestMixin, Generi self.logout() - with self.assertRaises(AssertionError): - self.login( - username=self.test_user.username, - password=TEST_USER_PASSWORD_EDITED - ) + result = self.login( + username=self.test_user.username, + password=TEST_USER_PASSWORD_EDITED + ) + + self.assertFalse(result) response = self.get(viewname='user_management:current_user_details') self.assertEqual(response.status_code, 302) From d4403daa617b6a33481c1dcbdea256a4e763fd65 Mon Sep 17 00:00:00 2001 From: Manoel Brunnen Date: Sun, 3 Feb 2019 23:14:07 +0100 Subject: [PATCH 6/6] Workaround for pip bug #6179 See https://github.com/pypa/pip/issues/6197 --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index c1860cabf6..2a9bbfbec6 100755 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -132,11 +132,11 @@ COPY --from=BUILDER_IMAGE /code/docker/version . RUN chown -R mayan:mayan $PROJECT_INSTALL_DIR # Install build Mayan EDMS -RUN sudo -u mayan $PYTHON_PIP install --no-cache-dir *.whl && \ +RUN sudo -u mayan $PYTHON_PIP install --no-cache-dir --no-use-pep517 *.whl && \ rm *.whl # Install Python clients for librabbitmq, MySQL, PostgreSQL, REDIS -RUN sudo -u mayan $PYTHON_PIP install --no-cache-dir librabbitmq==1.6.1 mysql-python==1.2.5 psycopg2==2.7.3.2 redis==2.10.6 +RUN sudo -u mayan $PYTHON_PIP install --no-cache-dir --no-use-pep517 librabbitmq==1.6.1 mysql-python==1.2.5 psycopg2==2.7.3.2 redis==2.10.6 # Setup supervisor COPY docker/etc/supervisor/mayan.conf /etc/supervisor/conf.d