Make validator not trigger migration creation.
This commit is contained in:
21
mayan/apps/converter/migrations/0007_auto_20150711_0656.py
Normal file
21
mayan/apps/converter/migrations/0007_auto_20150711_0656.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
import converter.validators
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('converter', '0006_auto_20150708_0120'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='transformation',
|
||||
name='arguments',
|
||||
field=models.TextField(help_text='Enter the arguments for the transformation as a YAML dictionary. ie: {"degrees": 180}', blank=True, verbose_name='Arguments', validators=[converter.validators.YAMLValidator()]),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
||||
@@ -15,10 +15,6 @@ from .validators import YAMLValidator
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def validators():
|
||||
return [YAMLValidator()]
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Transformation(models.Model):
|
||||
"""
|
||||
@@ -32,7 +28,7 @@ class Transformation(models.Model):
|
||||
|
||||
order = models.PositiveIntegerField(blank=True, db_index=True, default=0, help_text=_('Order in which the transformations will be executed.'), null=True, verbose_name=_('Order'))
|
||||
name = models.CharField(choices=BaseTransformation.get_transformation_choices(), max_length=128, verbose_name=_('Name'))
|
||||
arguments = models.TextField(blank=True, help_text=_('Enter the arguments for the transformation as a YAML dictionary. ie: {"degrees": 180}'), validators=validators, verbose_name=_('Arguments'))
|
||||
arguments = models.TextField(blank=True, help_text=_('Enter the arguments for the transformation as a YAML dictionary. ie: {"degrees": 180}'), validators=[YAMLValidator()], verbose_name=_('Arguments'))
|
||||
|
||||
objects = TransformationManager()
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ from __future__ import unicode_literals
|
||||
import yaml
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.deconstruct import deconstructible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
@deconstructible
|
||||
@@ -19,3 +19,11 @@ class YAMLValidator(object):
|
||||
yaml.safe_load(value)
|
||||
except yaml.error.YAMLError:
|
||||
raise ValidationError(_('Enter a valid YAML value.'), code='invalid')
|
||||
|
||||
def __eq__(self, other):
|
||||
return (
|
||||
isinstance(other, YAMLValidator)
|
||||
)
|
||||
|
||||
def __ne__(self, other):
|
||||
return not (self == other)
|
||||
|
||||
Reference in New Issue
Block a user