Merge remote-tracking branch 'origin/versions/next' into versions/next

This commit is contained in:
Roberto Rosario
2019-04-06 20:06:05 -04:00
5 changed files with 43 additions and 21 deletions

View File

@@ -48,6 +48,7 @@ apt-get install -y --no-install-recommends \
supervisor \
tesseract-ocr \
zlib1g-dev \
libssl-dev \
&& \
apt-get clean autoclean && \
apt-get autoremove --purge -y && \
@@ -68,7 +69,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
@@ -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

View File

@@ -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):

View File

@@ -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()

View File

@@ -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)

View File

@@ -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)