def command_edit_post(id): command = Command.get(id=id) data = request.forms if ' ' in data['command']: danger(_("Spaces are not allowed in commands.")) # TODO Redirect to the edit page return { 'apis': get_apis(), 'data': data, } with db.atomic(): command.command = data['command'] command.save() command.clear_actions() for i in range(int(data['actions_number'])): # Each action has actionX prepended to its inputs namespace = 'action{0}'.format(i) module, method = data['{0}_action_type'.format(namespace)].split('|') parameters = { key[len(namespace):]: value for key, value in data.items() if key.startswith(namespace) and not key.endswith('_action_type') } action = Action.create(module=module, method=method, parameters=json.dumps(parameters)) CommandAction.create(command=command, action=action, order=i) success(_("Command edited.")) return redirect(app.get_url('commands:list'))
def commands_action_input(): module, method = request.query['action'].split('|') action = get_apis()[module]['api'][method] return { 'action_type': request.query['action'], 'action': action }
def command_edit(id): command = Command.get(id=id) return { 'apis': get_apis(), 'command': command }
def commands_add(): return { 'apis': get_apis(), }