From 618a5f0f597fb8ad408726e9f2d3e972faf2216e Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 18 Sep 2018 21:34:58 -0400 Subject: [PATCH] Fix 90, 180 and 270 degrees rotation transformations. Signed-off-by: Roberto Rosario --- .../converter/tests/test_transformations.py | 39 ++++++++++++++++++- mayan/apps/converter/transformations.py | 5 ++- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/mayan/apps/converter/tests/test_transformations.py b/mayan/apps/converter/tests/test_transformations.py index cba100fc8c..2773ea4108 100644 --- a/mayan/apps/converter/tests/test_transformations.py +++ b/mayan/apps/converter/tests/test_transformations.py @@ -6,8 +6,9 @@ from documents.tests import GenericDocumentTestCase from ..models import Transformation from ..transformations import ( - BaseTransformation, TransformationCrop, TransformationResize, - TransformationRotate, TransformationZoom + BaseTransformation, TransformationCrop, TransformationLineArt, + TransformationResize, TransformationRotate, TransformationRotate90, + TransformationRotate180, TransformationRotate270, TransformationZoom ) from .literals import ( @@ -154,3 +155,37 @@ class TransformationTestCase(GenericDocumentTestCase): ) self.assertTrue(document_page.generate_image().startswith('page')) + + def test_lineart_transformations(self): + document_page = self.document.pages.first() + + Transformation.objects.add_for_model( + obj=document_page, transformation=TransformationLineArt, + arguments={} + ) + + self.assertTrue(document_page.generate_image().startswith('page')) + + def test_rotate_transformations(self): + document_page = self.document.pages.first() + + Transformation.objects.add_for_model( + obj=document_page, transformation=TransformationRotate90, + arguments={} + ) + + self.assertTrue(document_page.generate_image().startswith('page')) + + Transformation.objects.add_for_model( + obj=document_page, transformation=TransformationRotate180, + arguments={} + ) + + self.assertTrue(document_page.generate_image().startswith('page')) + + Transformation.objects.add_for_model( + obj=document_page, transformation=TransformationRotate270, + arguments={} + ) + + self.assertTrue(document_page.generate_image().startswith('page')) diff --git a/mayan/apps/converter/transformations.py b/mayan/apps/converter/transformations.py index 42ce6963ef..deca867239 100644 --- a/mayan/apps/converter/transformations.py +++ b/mayan/apps/converter/transformations.py @@ -210,8 +210,9 @@ class TransformationRotate(BaseTransformation): if self.degrees == 0: return self.image - if self.fillcolor: - fillcolor = ImageColor.getrgb(self.fillcolor) + fillcolor_value = getattr(self, 'fillcolor', None) + if fillcolor_value: + fillcolor = ImageColor.getrgb(fillcolor_value) else: fillcolor = None