Files
mayan-edms/mayan/apps/converter/forms.py
Roberto Rosario 924538fe48 Initial audit of the convert app
Add keyword arguments to call. Sort methods and arguments.

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
2019-01-02 14:45:48 -04:00

26 lines
667 B
Python

from __future__ import unicode_literals
import yaml
from django import forms
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from .models import Transformation
class TransformationForm(forms.ModelForm):
class Meta:
fields = ('name', 'arguments', 'order')
model = Transformation
def clean(self):
try:
yaml.safe_load(stream=self.cleaned_data['arguments'])
except yaml.YAMLError:
raise ValidationError(
message=_(
'"%s" not a valid entry.'
) % self.cleaned_data['arguments']
)