From ff6674cc4a9de4bdc1aa2957015a057e4d255d1f Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 26 Jul 2019 01:24:55 -0400 Subject: [PATCH] Fix workflow preview under Python 3 Signed-off-by: Roberto Rosario --- mayan/apps/document_states/models.py | 8 ++++++-- mayan/apps/document_states/tests/test_models.py | 11 +++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 mayan/apps/document_states/tests/test_models.py diff --git a/mayan/apps/document_states/models.py b/mayan/apps/document_states/models.py index d7fab264a7..a8538c4a1b 100644 --- a/mayan/apps/document_states/models.py +++ b/mayan/apps/document_states/models.py @@ -14,7 +14,9 @@ from django.core.files.base import ContentFile from django.db import IntegrityError, models, transaction from django.db.models import F, Max, Q from django.urls import reverse -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import ( + force_bytes, force_text, python_2_unicode_compatible +) from django.utils.module_loading import import_string from django.utils.translation import ugettext_lazy as _ @@ -110,7 +112,9 @@ class Workflow(models.Model): ) return hashlib.sha256( - serializers.serialize('json', objects_lists) + force_bytes( + serializers.serialize('json', objects_lists) + ) ).hexdigest() def get_initial_state(self): diff --git a/mayan/apps/document_states/tests/test_models.py b/mayan/apps/document_states/tests/test_models.py new file mode 100644 index 0000000000..ebe512f244 --- /dev/null +++ b/mayan/apps/document_states/tests/test_models.py @@ -0,0 +1,11 @@ +from __future__ import unicode_literals + +from mayan.apps.common.tests import BaseTestCase + +from .mixins import WorkflowTestMixin + + +class WorkflowModelTestCase(WorkflowTestMixin, BaseTestCase): + def test_workflow_template_preview(self): + self._create_test_workflow() + self.assertTrue(self.test_workflow.get_api_image_url())