From fa4cb686fb50f01b9fdf843922ddf79173cbe124 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sat, 4 Jul 2015 04:16:18 -0400 Subject: [PATCH] Auto add arguments to transformation labels. --- mayan/apps/converter/classes.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mayan/apps/converter/classes.py b/mayan/apps/converter/classes.py index c15c9e98a2..2201239a64 100644 --- a/mayan/apps/converter/classes.py +++ b/mayan/apps/converter/classes.py @@ -10,9 +10,9 @@ try: except ImportError: from StringIO import StringIO -from PIL import Image -from django.utils.translation import ugettext_lazy as _ +from PIL import Image +from django.utils.translation import string_concat, ugettext_lazy as _ from common.settings import setting_temporary_directory from common.utils import fs_cleanup @@ -201,12 +201,16 @@ class BaseTransformation(object): @classmethod def get_transformation_choices(cls): - return [(name, klass.label) for name, klass in cls._registry.items()] + return [(name, klass.get_label()) for name, klass in cls._registry.items()] @classmethod def get(cls, name): return cls._registry[name] + @classmethod + def get_label(cls): + return string_concat(cls.label, ': ', ', '.join(cls.arguments)) + def __init__(self, **kwargs): for argument_name in self.arguments: setattr(self, argument_name, kwargs.get(argument_name)) @@ -219,7 +223,7 @@ class BaseTransformation(object): class TransformationResize(BaseTransformation): name = 'resize' arguments = ('width', 'height') - label = _('Resize ') + label = _('Resize') def execute_on(self, *args, **kwargs): super(TransformationResize, self).execute_on(*args, **kwargs) @@ -257,7 +261,7 @@ class TransformationResize(BaseTransformation): class TransformationRotate(BaseTransformation): name = 'rotate' arguments = ('degrees',) - label = _('Rotate ') + label = _('Rotate') def execute_on(self, *args, **kwargs): super(TransformationRotate, self).execute_on(*args, **kwargs) @@ -268,7 +272,7 @@ class TransformationRotate(BaseTransformation): class TransformationZoom(BaseTransformation): name = 'zoom' arguments = ('percent',) - label = _('Zoom ') + label = _('Zoom') def execute_on(self, *args, **kwargs): super(TransformationZoom, self).execute_on(*args, **kwargs)