Avoid triggering migration creation using functions for choices and validators choices.
This commit is contained in:
27
mayan/apps/converter/migrations/0005_auto_20150708_0118.py
Normal file
27
mayan/apps/converter/migrations/0005_auto_20150708_0118.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
import converter.validators
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('converter', '0004_auto_20150704_0753'),
|
||||
]
|
||||
|
||||
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,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='transformation',
|
||||
name='name',
|
||||
field=models.CharField(max_length=128, verbose_name='Name', choices=[('rotate', 'Rotate: degrees'), ('zoom', 'Zoom: percent'), ('resize', 'Resize: width, height')]),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
||||
21
mayan/apps/converter/migrations/0006_auto_20150708_0120.py
Normal file
21
mayan/apps/converter/migrations/0006_auto_20150708_0120.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
import converter.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('converter', '0005_auto_20150708_0118'),
|
||||
]
|
||||
|
||||
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.models.validators),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
||||
@@ -16,6 +16,10 @@ from .validators import YAMLValidator
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def validators():
|
||||
return [YAMLValidator()]
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Transformation(models.Model):
|
||||
"""
|
||||
@@ -29,7 +33,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=[YAMLValidator()], verbose_name=_('Arguments'))
|
||||
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'))
|
||||
|
||||
objects = TransformationManager()
|
||||
|
||||
|
||||
20
mayan/apps/metadata/migrations/0002_auto_20150708_0118.py
Normal file
20
mayan/apps/metadata/migrations/0002_auto_20150708_0118.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('metadata', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='metadatatype',
|
||||
name='validation',
|
||||
field=models.CharField(blank=True, max_length=64, verbose_name='Validation function name', choices=[(b'metadata.validators.DateAndTimeValidator', b'metadata.validators.DateAndTimeValidator'), (b'metadata.validators.DateValidator', b'metadata.validators.DateValidator'), (b'metadata.validators.TimeValidator', b'metadata.validators.TimeValidator')]),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
||||
@@ -11,6 +11,10 @@ from .managers import MetadataTypeManager
|
||||
from .settings import setting_available_validators
|
||||
|
||||
|
||||
def validation_choices():
|
||||
return zip(setting_available_validators.value, setting_available_validators.value)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class MetadataType(models.Model):
|
||||
"""
|
||||
@@ -27,7 +31,7 @@ class MetadataType(models.Model):
|
||||
lookup = models.TextField(blank=True, null=True,
|
||||
verbose_name=_('Lookup'),
|
||||
help_text=_('Enter a string to be evaluated that returns an iterable.'))
|
||||
validation = models.CharField(blank=True, choices=zip(setting_available_validators.value, setting_available_validators.value), max_length=64, verbose_name=_('Validation function name'))
|
||||
validation = models.CharField(blank=True, choices=validation_choices(), max_length=64, verbose_name=_('Validation function name'))
|
||||
# TODO: Find a different way to let users know what models and functions are
|
||||
# available now that we removed these from the help_text
|
||||
objects = MetadataTypeManager()
|
||||
|
||||
Reference in New Issue
Block a user