def prepare_simulator_form_for_search(self, dict_to_render): sim_adapter_form = SimulatorAdapterForm(project_id=1) sim_adapter_form.fill_from_trait(Simulator()) dict_to_render[SimulatorController.FORM_KEY] = sim_adapter_form html = self.dummy_renderer(dict_to_render) soup = BeautifulSoup(html) return soup
def prepare_simulator_form_for_search(self, rendering_rules, form=None): # type: (SimulatorFragmentRenderingRules, ABCAdapterForm) -> BeautifulSoup if form is None: form = SimulatorAdapterForm(project_id=1) form.fill_from_trait(Simulator()) rendering_rules.form = form html = self.dummy_renderer(rendering_rules.to_dict()) soup = BeautifulSoup(html) return soup
def prepare_simulator_form_for_search(self, mocker, rendering_rules, form=None): # type: (MockerFixture, SimulatorFragmentRenderingRules, ABCAdapterForm) -> BeautifulSoup if form is None: form = SimulatorAdapterForm() form.fill_from_trait(Simulator()) rendering_rules.form = form def _is_online_help_active(self): return True def _get_logged_user(): return User('test', 'test', 'test') mocker.patch('tvb.interfaces.web.controllers.common.get_logged_user', _get_logged_user) mocker.patch.object(User, 'is_online_help_active', _is_online_help_active) html = self.dummy_renderer(rendering_rules.to_dict()) soup = BeautifulSoup(html, features="html.parser") return soup
def prepare_first_fragment(self): self.context.set_simulator() simulator, _, _, is_branch = self.context.get_common_params() branch_conditions = self.simulator_service.compute_conn_branch_conditions(is_branch, simulator) form = self.algorithm_service.prepare_adapter_form(form_instance=SimulatorAdapterForm(), project_id=self.context.project.id, extra_conditions=branch_conditions) self.simulator_service.validate_first_fragment(form, self.context.project.id, ConnectivityIndex) form.fill_from_trait(self.context.simulator) return form
def set_connectivity(self, **data): session_stored_simulator, is_simulation_copy, is_simulation_load, _ = self.context.get_common_params( ) if cherrypy.request.method == POST_REQUEST: self.context.add_last_loaded_form_url_to_session( SimulatorWizzardURLs.SET_COUPLING_PARAMS_URL) form = SimulatorAdapterForm() form.fill_from_post(data) self.simulator_service.reset_at_connectivity_change( is_simulation_copy, form, session_stored_simulator) form.fill_trait(session_stored_simulator) next_form = self.algorithm_service.prepare_adapter_form( form_instance=get_form_for_coupling( type(session_stored_simulator.coupling))()) self.range_parameters.coupling_parameters = next_form.get_range_parameters( ) next_form.fill_from_trait(session_stored_simulator.coupling) rendering_rules = SimulatorFragmentRenderingRules( next_form, SimulatorWizzardURLs.SET_COUPLING_PARAMS_URL, SimulatorWizzardURLs.SET_CONNECTIVITY_URL, is_simulation_copy, is_simulation_load, self.context.last_loaded_fragment_url, cherrypy.request.method) return rendering_rules.to_dict()
def set_connectivity(self, **data): session_stored_simulator = common.get_from_session( common.KEY_SIMULATOR_CONFIG) is_simulator_copy = common.get_from_session( common.KEY_IS_SIMULATOR_COPY) is_simulator_load = common.get_from_session( common.KEY_IS_SIMULATOR_LOAD) form = SimulatorAdapterForm() if cherrypy.request.method == 'POST': is_simulator_copy = False form.fill_from_post(data) connectivity_index_gid = form.connectivity.value conduction_speed = form.conduction_speed.value coupling = form.coupling.value connectivity_index = ABCAdapter.load_entity_by_gid( connectivity_index_gid) connectivity = h5.load_from_index(connectivity_index) # TODO: handle this cases in a better manner session_stored_simulator.connectivity = connectivity session_stored_simulator.conduction_speed = conduction_speed session_stored_simulator.coupling = coupling() next_form = get_form_for_coupling( type(session_stored_simulator.coupling))() self.range_parameters.coupling_parameters = next_form.get_range_parameters( ) next_form.fill_from_trait(session_stored_simulator.coupling) dict_to_render = copy.deepcopy(self.dict_to_render) dict_to_render[self.FORM_KEY] = next_form dict_to_render[self.ACTION_KEY] = '/burst/set_coupling_params' dict_to_render[self.PREVIOUS_ACTION_KEY] = '/burst/set_connectivity' dict_to_render[self.IS_COPY] = is_simulator_copy dict_to_render[self.IS_LOAD] = is_simulator_load return dict_to_render