From 1a9be24ada1160c7f4d24c7a90580d0f50f590c1 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 12 Nov 2019 00:42:59 -0400 Subject: [PATCH 1/8] Revert "Improve workflow field help text" There are migrations in version 3.3 before this one. This reverts commit 1c39b3c84dc9ed3758c3be44d5a2bbb86b9d93c1. --- .../migrations/0016_auto_20191108_2332.py | 30 ------------------- mayan/apps/document_states/models.py | 8 ++--- 2 files changed, 4 insertions(+), 34 deletions(-) delete mode 100644 mayan/apps/document_states/migrations/0016_auto_20191108_2332.py diff --git a/mayan/apps/document_states/migrations/0016_auto_20191108_2332.py b/mayan/apps/document_states/migrations/0016_auto_20191108_2332.py deleted file mode 100644 index 6e175e00df..0000000000 --- a/mayan/apps/document_states/migrations/0016_auto_20191108_2332.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.25 on 2019-11-08 23:32 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('document_states', '0015_auto_20190701_1311'), - ] - - operations = [ - migrations.AlterField( - model_name='workflowstate', - name='completion', - field=models.IntegerField(blank=True, default=0, help_text='The percent of completion that this state represents in relation to the workflow. Use numbers without the percent sign.', verbose_name='Completion'), - ), - migrations.AlterField( - model_name='workflowstate', - name='initial', - field=models.BooleanField(default=False, help_text='The state at which the workflow will start in. Only one state can be the initial state.', verbose_name='Initial'), - ), - migrations.AlterField( - model_name='workflowstateaction', - name='when', - field=models.PositiveIntegerField(choices=[(1, 'On entry'), (2, 'On exit')], default=1, help_text='At which moment of the state this action will execute.', verbose_name='When'), - ), - ] diff --git a/mayan/apps/document_states/models.py b/mayan/apps/document_states/models.py index 24e966d3a6..a5da8ab106 100644 --- a/mayan/apps/document_states/models.py +++ b/mayan/apps/document_states/models.py @@ -200,13 +200,13 @@ class WorkflowState(models.Model): initial = models.BooleanField( default=False, help_text=_( - 'The state at which the workflow will start in. Only one state ' - 'can be the initial state.' + 'Select if this will be the state with which you want the ' + 'workflow to start in. Only one state can be the initial state.' ), verbose_name=_('Initial') ) completion = models.IntegerField( blank=True, default=0, help_text=_( - 'The percent of completion that this state represents in ' + 'Enter the percent of completion that this state represents in ' 'relation to the workflow. Use numbers without the percent sign.' ), verbose_name=_('Completion') ) @@ -283,7 +283,7 @@ class WorkflowStateAction(models.Model): when = models.PositiveIntegerField( choices=WORKFLOW_ACTION_WHEN_CHOICES, default=WORKFLOW_ACTION_ON_ENTRY, help_text=_( - 'At which moment of the state this action will execute.' + 'At which moment of the state this action will execute' ), verbose_name=_('When') ) action_path = models.CharField( From 3f505007fa15d39dd88e160870d7d14381174703 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 14 Nov 2019 22:48:37 -0400 Subject: [PATCH 2/8] Fix Docker makefile multiline indentation Signed-off-by: Roberto Rosario --- docker/Makefile | 58 ++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/docker/Makefile b/docker/Makefile index 9a8d9162a0..1f8160ccde 100755 --- a/docker/Makefile +++ b/docker/Makefile @@ -45,41 +45,41 @@ docker-staging-network-create: docker-staging-container-postgresql-start: docker run -d \ - --name mayan-staging-postgres \ - --network=mayan-staging \ - -e POSTGRES_USER=mayan \ - -e POSTGRES_DB=mayan \ - -e POSTGRES_PASSWORD=mayanuserpass \ - -v mayan-staging-postgres:/var/lib/postgresql/data \ - $(DOCKER_POSTGRES_IMAGE_VERSION) + --name mayan-staging-postgres \ + --network=mayan-staging \ + -e POSTGRES_USER=mayan \ + -e POSTGRES_DB=mayan \ + -e POSTGRES_PASSWORD=mayanuserpass \ + -v mayan-staging-postgres:/var/lib/postgresql/data \ + $(DOCKER_POSTGRES_IMAGE_VERSION) docker-staging-container-redis-start: docker run -d \ - --name mayan-staging-redis \ - --network=mayan-staging \ - $(DOCKER_REDIS_IMAGE_VERSION) \ - redis-server \ - --databases \ - "2" \ - --maxmemory-policy \ - allkeys-lru \ - --save \ - "" + --name mayan-staging-redis \ + --network=mayan-staging \ + $(DOCKER_REDIS_IMAGE_VERSION) \ + redis-server \ + --databases \ + "2" \ + --maxmemory-policy \ + allkeys-lru \ + --save \ + "" docker-staging-container-mayan-start: docker run -d \ - --name mayan-staging-app \ - --network=mayan-staging \ - -p 80:8000 \ - -e MAYAN_DATABASE_ENGINE=django.db.backends.postgresql \ - -e MAYAN_DATABASE_HOST=mayan-staging-postgres \ - -e MAYAN_DATABASE_NAME=mayan \ - -e MAYAN_DATABASE_PASSWORD=mayanuserpass \ - -e MAYAN_DATABASE_USER=mayan \ - -e MAYAN_BROKER_URL="redis://mayan-staging-redis:6379/0" \ - -e MAYAN_CELERY_RESULT_BACKEND="redis://mayan-staging-redis:6379/1" \ - -v mayan-staging-app:/var/lib/mayan \ - mayanedms/mayanedms:$(IMAGE_VERSION) + --name mayan-staging-app \ + --network=mayan-staging \ + -p 80:8000 \ + -e MAYAN_DATABASE_ENGINE=django.db.backends.postgresql \ + -e MAYAN_DATABASE_HOST=mayan-staging-postgres \ + -e MAYAN_DATABASE_NAME=mayan \ + -e MAYAN_DATABASE_PASSWORD=mayanuserpass \ + -e MAYAN_DATABASE_USER=mayan \ + -e MAYAN_BROKER_URL="redis://mayan-staging-redis:6379/0" \ + -e MAYAN_CELERY_RESULT_BACKEND="redis://mayan-staging-redis:6379/1" \ + -v mayan-staging-app:/var/lib/mayan \ + mayanedms/mayanedms:$(IMAGE_VERSION) docker-staging-start: docker-staging-network-create docker-staging-container-postgresql-start docker-staging-container-redis-start docker-staging-container-mayan-start docker logs -f mayan-staging-app From 3e954db2f7c4f23852695ab7466a35aac73ce02a Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 14 Nov 2019 23:52:36 -0400 Subject: [PATCH 3/8] Fix sources app logging Signed-off-by: Roberto Rosario --- mayan/apps/sources/models/base.py | 2 +- mayan/apps/sources/tasks.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mayan/apps/sources/models/base.py b/mayan/apps/sources/models/base.py index bcca608256..09d3690401 100644 --- a/mayan/apps/sources/models/base.py +++ b/mayan/apps/sources/models/base.py @@ -83,7 +83,7 @@ class Source(models.Model): ) ) except NoMIMETypeMatch: - logging.debug(msg='Exception: NoMIMETypeMatch') + logger.debug(msg='Exception: NoMIMETypeMatch') documents.append( self.upload_document(file_object=file_object, **kwargs) ) diff --git a/mayan/apps/sources/tasks.py b/mayan/apps/sources/tasks.py index 060fe61ee7..f9e05298c1 100644 --- a/mayan/apps/sources/tasks.py +++ b/mayan/apps/sources/tasks.py @@ -150,7 +150,7 @@ def task_source_handle_upload(self, document_type_id, shared_uploaded_file_id, s exception ) except NoMIMETypeMatch: - logging.debug('Exception: NoMIMETypeMatch') + logger.debug('Exception: NoMIMETypeMatch') task_upload_document.delay( shared_uploaded_file_id=shared_upload.pk, **kwargs ) From c14a98b78eafb2a8d4d12e050d88a3537bed6c6e Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 15 Nov 2019 02:44:53 -0400 Subject: [PATCH 4/8] Add supervisor configuration reread step changes Signed-off-by: Roberto Rosario --- docs/chapters/deploying.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/chapters/deploying.rst b/docs/chapters/deploying.rst index a14f694f16..4776923c66 100644 --- a/docs/chapters/deploying.rst +++ b/docs/chapters/deploying.rst @@ -239,6 +239,7 @@ of a restart or power failure. The Gunicorn workers are increased to 3. ------------------------ :: + sudo supervisorctl reread sudo supervisorctl restart all From 27d366101797ddaff5283941c7857b53c776fc79 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 15 Nov 2019 17:56:14 -0400 Subject: [PATCH 5/8] Use timezone aware date for document statistics Signed-off-by: Roberto Rosario --- HISTORY.rst | 1 + mayan/apps/documents/statistics.py | 57 ++++++++++++++++-------------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 2ecc02d918..6f3a8da471 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -18,6 +18,7 @@ to John Bentley (@johnbentleyii) for the report. - Add missing Event class cache invalidation when calling the refresh() method. +- Use timezone aware date for document statistics. 3.2.9 (2019-11-03) ================== diff --git a/mayan/apps/documents/statistics.py b/mayan/apps/documents/statistics.py index 2f1059e7d1..7bceb98f86 100644 --- a/mayan/apps/documents/statistics.py +++ b/mayan/apps/documents/statistics.py @@ -1,8 +1,7 @@ from __future__ import absolute_import, unicode_literals -import datetime - from django.apps import apps +from django.utils import timezone from django.utils.encoding import force_text from django.utils.translation import ugettext_lazy as _ @@ -26,14 +25,14 @@ def new_documents_per_month(): qss = qsstats.QuerySetStats(Document.passthrough.all(), 'date_added') - today = datetime.date.today() - this_year = datetime.date(year=today.year, month=1, day=1) + now = timezone.now().date() + start = timezone.datetime(year=now.year, month=1, day=1).date() return { 'series': { 'Documents': map( lambda x: {force_text(MONTH_NAMES[x[0].month]): x[1]}, - qss.time_series(start=this_year, end=today, interval='months') + qss.time_series(start=start, end=now, interval='months') ) } } @@ -48,14 +47,14 @@ def new_document_pages_per_month(): DocumentPage.objects.all(), 'document_version__document__date_added' ) - today = datetime.date.today() - this_year = datetime.date(year=today.year, month=1, day=1) + now = timezone.now().date() + start = timezone.datetime(year=now.year, month=1, day=1).date() return { 'series': { 'Pages': map( lambda x: {force_text(MONTH_NAMES[x[0].month]): x[1]}, - qss.time_series(start=this_year, end=today, interval='months') + qss.time_series(start=start, end=now, interval='months') ) } } @@ -88,14 +87,14 @@ def new_document_versions_per_month(): DocumentVersion.objects.all(), 'document__date_added' ) - today = datetime.date.today() - this_year = datetime.date(year=today.year, month=1, day=1) + now = timezone.now().date() + start = timezone.datetime(year=now.year, month=1, day=1).date() return { 'series': { 'Versions': map( lambda x: {force_text(MONTH_NAMES[x[0].month]): x[1]}, - qss.time_series(start=this_year, end=today, interval='months') + qss.time_series(start=start, end=now, interval='months') ) } } @@ -127,25 +126,27 @@ def total_document_per_month(): Document = apps.get_model(app_label='documents', model_name='Document') qss = qsstats.QuerySetStats(Document.objects.all(), 'date_added') - this_year = datetime.date.today().year + now = timezone.now() result = [] - for month in range(1, datetime.date.today().month + 1): + for month in range(1, now.month + 1): next_month = month + 1 if month == 12: next_month = 1 - year = this_year + 1 + year = now.year + 1 else: next_month = month + 1 - year = this_year + year = now.year result.append( { force_text( MONTH_NAMES[month] - ): qss.until(datetime.date(year, next_month, 1)) + ): qss.until( + timezone.datetime(year, next_month, 1, tzinfo=now.tzinfo) + ) } ) @@ -164,25 +165,27 @@ def total_document_version_per_month(): qss = qsstats.QuerySetStats( DocumentVersion.objects.all(), 'document__date_added' ) - this_year = datetime.date.today().year + now = timezone.now() result = [] - for month in range(1, datetime.date.today().month + 1): + for month in range(1, now.month + 1): next_month = month + 1 if month == 12: next_month = 1 - year = this_year + 1 + year = now.year + 1 else: next_month = month + 1 - year = this_year + year = now.year result.append( { force_text( MONTH_NAMES[month] - ): qss.until(datetime.date(year, next_month, 1)) + ): qss.until( + timezone.datetime(year, next_month, 1, tzinfo=now.tzinfo) + ) } ) @@ -201,25 +204,27 @@ def total_document_page_per_month(): qss = qsstats.QuerySetStats( DocumentPage.objects.all(), 'document_version__document__date_added' ) - this_year = datetime.date.today().year + now = timezone.now() result = [] - for month in range(1, datetime.date.today().month + 1): + for month in range(1, now.month + 1): next_month = month + 1 if month == 12: next_month = 1 - year = this_year + 1 + year = now.year + 1 else: next_month = month + 1 - year = this_year + year = now.year result.append( { force_text( MONTH_NAMES[month] - ): qss.until(datetime.date(year, next_month, 1)) + ): qss.until( + timezone.datetime(year, next_month, 1, tzinfo=now.tzinfo) + ) } ) From e2af72dab7a4f43af3919114679f4aa6a65a06c6 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 15 Nov 2019 18:49:02 -0400 Subject: [PATCH 6/8] Show placeholder label on invalid action classes Instead of throwing an error a sample label of "Unknown action type" will be used and allow users to delete the unknown state action. Signed-off-by: Roberto Rosario --- mayan/apps/document_states/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mayan/apps/document_states/models.py b/mayan/apps/document_states/models.py index a5da8ab106..4ef308470c 100644 --- a/mayan/apps/document_states/models.py +++ b/mayan/apps/document_states/models.py @@ -328,7 +328,10 @@ class WorkflowStateAction(models.Model): return self.get_class()(form_data=self.loads()) def get_class_label(self): - return self.get_class().label + try: + return self.get_class().label + except ImportError: + return _('Unknown action type') def loads(self): return json.loads(self.action_data) From 3ecbec36aac5a5199cf37b0d56b34a13fd1cf65b Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 15 Nov 2019 19:03:20 -0400 Subject: [PATCH 7/8] Update changelog Signed-off-by: Roberto Rosario --- HISTORY.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 6f3a8da471..cf46e1e96c 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -19,6 +19,10 @@ - Add missing Event class cache invalidation when calling the refresh() method. - Use timezone aware date for document statistics. +- Show placeholder label on invalid action classes + Instead of throwing an error a sample label of + "Unknown action type" will be used and allow users to + delete the unknown state action. 3.2.9 (2019-11-03) ================== From ec86d7679a45fe6ac14234ec4b31d81d61b7ac1e Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sat, 16 Nov 2019 21:40:39 -0400 Subject: [PATCH 8/8] Add exiftool to deployment installation Signed-off-by: Roberto Rosario --- docs/chapters/deploying.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/chapters/deploying.rst b/docs/chapters/deploying.rst index 4776923c66..9a98aea847 100644 --- a/docs/chapters/deploying.rst +++ b/docs/chapters/deploying.rst @@ -27,10 +27,10 @@ For another setup that offers more performance and scalability refer to the If using a Debian_ or Ubuntu_ based Linux distribution, get the executable requirements using:: - sudo apt-get install g++ gcc ghostscript gnupg1 graphviz libfuse2 \ - libjpeg-dev libmagic1 libpq-dev libpng-dev libreoffice libtiff-dev \ - poppler-utils postgresql python-dev python-virtualenv redis-server \ - sane-utils supervisor tesseract-ocr zlib1g-dev -y + sudo apt-get install exiftool g++ gcc ghostscript gnupg1 graphviz \ + libfuse2 libjpeg-dev libmagic1 libpq-dev libpng-dev libreoffice \ + libtiff-dev poppler-utils postgresql python-dev python-virtualenv \ + redis-server sane-utils supervisor tesseract-ocr zlib1g-dev -y .. note::