Add transformation metaclass in a way compatible

Use Django's with_metaclass to Work with Python 2 and Python 3.

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-12-11 16:28:42 -04:00
parent 8cfb457cf1
commit 16e95ffc42
2 changed files with 4 additions and 3 deletions
+2
View File
@@ -18,6 +18,8 @@
- Use TemplateField for the web link template. - Use TemplateField for the web link template.
- Use TemplateField for smart links. - Use TemplateField for smart links.
- Add the ID and the URL to the checkout serializer. - Add the ID and the URL to the checkout serializer.
- Add BaseTransformationType metaclass in a way compatible with
Python 2 and Python 3.
3.3.4 (2019-12-09) 3.3.4 (2019-12-09)
================== ==================
+2 -3
View File
@@ -6,6 +6,7 @@ import logging
from PIL import Image, ImageColor, ImageDraw, ImageFilter from PIL import Image, ImageColor, ImageDraw, ImageFilter
from django.utils.encoding import force_bytes, force_text from django.utils.encoding import force_bytes, force_text
from django.utils.six import with_metaclass
from django.utils.translation import string_concat, ugettext_lazy as _ from django.utils.translation import string_concat, ugettext_lazy as _
from .layers import layer_saved_transformations from .layers import layer_saved_transformations
@@ -18,7 +19,7 @@ class BaseTransformationType(type):
return force_text(self.label) return force_text(self.label)
class BaseTransformation(object, metaclass=BaseTransformationType): class BaseTransformation(with_metaclass(meta=BaseTransformationType)):
""" """
Transformation can modify the appearance of the document's page preview. Transformation can modify the appearance of the document's page preview.
Some transformation available are: Rotate, zoom, resize and crop. Some transformation available are: Rotate, zoom, resize and crop.
@@ -27,8 +28,6 @@ class BaseTransformation(object, metaclass=BaseTransformationType):
name = 'base_transformation' name = 'base_transformation'
_layer_transformations = {} _layer_transformations = {}
_registry = {} _registry = {}
# PY 2
__metaclass__ = BaseTransformationType
@staticmethod @staticmethod
def combine(transformations): def combine(transformations):