from models import DataSource data_source_id = request.arguments.get('data_source_id', '') command = request.arguments.get('command', 'update') data_source = DataSource.get(guid=data_source_id) if data_source: disabled = '2' if command == 'delete' else '0' form = self.dialog_update.form_update form.connector.value = data_source.connector form.connector.mode = disabled form.workspace_id.value = data_source.workspace_id form.data_source_id.value = data_source.guid form.command.value = command self.dialog_update.form_update.btn_update.label = command.title() form.btn_update.action("setLabel", [command.title()]) form.btn_update.action( "setClass", ['btn btn-danger' if command == 'delete' else 'btn btn-success']) self.dialog_update.title = 'Data Source {}'.format(command.title()) self.dialog_update.show = '1'
raise Exception('Workspace ID is not provided') workspace_id = request.arguments.get('workspace_id') command = request.arguments.get('command', u'') workspace = Workspace.get(guid=workspace_id) if not workspace: self.action('goTo', ['/main']) elif command in ['delete', 'update']: if 'data_source_id' not in request.arguments: raise Exception(u'DataSource ID is not provided') data_source_id = request.arguments['data_source_id'] data_source = DataSource.get(guid=data_source_id, workspace_id=workspace.guid) if data_source: if command == 'delete': data_source.delete() else: connector = request.arguments['connector'] if connector: data_source.connector = connector data_source.save() self.dialog_update.action('hide', ['0']) elif command == 'create': connector = request.arguments['connector'] if connector: