Commit f8971ea5 authored by Jerome Mariette's avatar Jerome Mariette

handle from gui custom types

parent 29087665
......@@ -22,6 +22,7 @@ from functools import wraps
import time
import os
import argparse
from argparse import ArgumentTypeError
try:
import _preamble
......@@ -31,6 +32,7 @@ except ImportError:
from jflow.workflows_manager import WorkflowsManager
from jflow.config_reader import JFlowConfigReader
from jflow.workflow import Workflow
from workflows.types import *
import jflow.utils as utils
from cctools.util import time_format
......@@ -161,6 +163,20 @@ class JFlowServer (object):
status.append(self.jsonify_workflow_status(workflow))
return status
@cherrypy.expose
@jsonify
def validate_field(self, **kwargs):
try:
value_key = None
for key in kwargs.keys():
if key != "type" and key != "callback" and key != "_":
value_key = key
break
eval(kwargs["type"])(kwargs[value_key])
return True
except Exception, e:
return str(e)
if __name__ == '__main__':
......
......@@ -163,9 +163,21 @@
required: $this.workflow.parameters[i].required,
date: true
}
} else {
} else if ($this.workflow.parameters[i].type == "str") {
rules[$this.workflow.parameters[i].name] = {
required: $this.workflow.parameters[i].required
}
// if it is not a known type, check from the custom ones, using the validate_field address
} else {
rules[$this.workflow.parameters[i].name] = {
required: $this.workflow.parameters[i].required,
remote: {
url: $this.options.serverURL + '/validate_field?callback=?',
type: "post",
data: {
type: $this.workflow.parameters[i].type
}
}
}
}
}
......@@ -205,7 +217,7 @@
template: ['<form id="workflow_form" class="form-horizontal">',
'<fieldset>',
' {{each(index, param) workflow.parameters}}',
// it the parameter has ne already been settled
// it the parameter has not already been settled
' {{if Object.keys(parameters).indexOf(param.name) == -1 }}',
' <div class="control-group">',
' <label class="control-label">${param.display_name}</label>',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment