def get_instances_for_module(app, module, additional_xpaths=None): """ This method is used by CloudCare when filtering cases. """ modules = list(app.get_modules()) helper = DetailsHelper(app, modules) details = DetailContributor(None, app, modules).get_section_elements() detail_mapping = {detail.id: detail for detail in details} details_by_id = detail_mapping detail_ids = [ helper.get_detail_id_safe(module, detail_type) for detail_type, detail, enabled in module.get_details() if enabled ] detail_ids = filter(None, detail_ids) xpaths = set() if additional_xpaths: xpaths.update(additional_xpaths) for detail_id in detail_ids: xpaths.update(details_by_id[detail_id].get_all_xpaths()) instances, _ = EntryInstances.get_required_instances(xpaths) return instances
def generate_suite(self): # Note: the order in which things happen in this function matters self._add_sections([ FormResourceContributor(self.suite, self.app, self.modules, self.build_profile_id), LocaleResourceContributor(self.suite, self.app, self.modules, self.build_profile_id), DetailContributor(self.suite, self.app, self.modules, self.build_profile_id), ]) if self.app.supports_practice_users and self.app.get_practice_user( self.build_profile_id): self._add_sections([ PracticeUserRestoreContributor(self.suite, self.app, self.modules, self.build_profile_id) ]) # by module entries = EntriesContributor(self.suite, self.app, self.modules, self.build_profile_id) menus = MenuContributor(self.suite, self.app, self.modules, self.build_profile_id) remote_requests = RemoteRequestContributor(self.suite, self.app, self.modules) if any(module.is_training_module for module in self.modules): training_menu = LocalizedMenu(id='training-root') training_menu.text = Text( locale_id=id_strings.training_module_locale()) else: training_menu = None for module in self.modules: self.suite.entries.extend(entries.get_module_contributions(module)) self.suite.menus.extend( menus.get_module_contributions(module, training_menu)) self.suite.remote_requests.extend( remote_requests.get_module_contributions(module)) if training_menu: self.suite.menus.append(training_menu) self._add_sections([ FixtureContributor(self.suite, self.app, self.modules), SchedulerFixtureContributor(self.suite, self.app, self.modules), ]) # post process if self.app.enable_post_form_workflow: WorkflowHelper(self.suite, self.app, self.modules).update_suite() if self.app.use_grid_menus: GridMenuHelper(self.suite, self.app, self.modules).update_suite() EntryInstances(self.suite, self.app, self.modules).update_suite() return self.suite.serializeDocument(pretty=True)
def generate_suite(self): # Note: the order in which things happen in this function matters self._add_sections([ FormResourceContributor(self.suite, self.app, self.modules, self.build_profile_id), LocaleResourceContributor(self.suite, self.app, self.modules, self.build_profile_id), DetailContributor(self.suite, self.app, self.modules, self.build_profile_id), ]) # by module entries = EntriesContributor(self.suite, self.app, self.modules) menus = MenuContributor(self.suite, self.app, self.modules) careplan_menus = CareplanMenuContributor(self.suite, self.app, self.modules) remote_requests = RemoteRequestContributor(self.suite, self.app, self.modules) for module in self.modules: self.suite.entries.extend(entries.get_module_contributions(module)) self.suite.menus.extend( careplan_menus.get_module_contributions(module)) self.suite.menus.extend(menus.get_module_contributions(module)) self.suite.remote_requests.extend( remote_requests.get_module_contributions(module)) self._add_sections([ FixtureContributor(self.suite, self.app, self.modules), SchedulerFixtureContributor(self.suite, self.app, self.modules), ]) # post process if self.app.enable_post_form_workflow: WorkflowHelper(self.suite, self.app, self.modules).update_suite() if self.app.grid_menu_toggle_enabled() and self.app.use_grid_menus: GridMenuHelper(self.suite, self.app, self.modules).update_suite() EntryInstances(self.suite, self.app, self.modules).update_suite() return self.suite.serializeDocument(pretty=True)
def get_instances_for_module(app, module, additional_xpaths=None): """ This method is used by CloudCare when filtering cases. """ modules = list(app.get_modules()) helper = DetailsHelper(app, modules) details = DetailContributor(None, app, modules).get_section_elements() detail_mapping = {detail.id: detail for detail in details} details_by_id = detail_mapping detail_ids = [helper.get_detail_id_safe(module, detail_type) for detail_type, detail, enabled in module.get_details() if enabled] detail_ids = filter(None, detail_ids) xpaths = set() if additional_xpaths: xpaths.update(additional_xpaths) for detail_id in detail_ids: xpaths.update(details_by_id[detail_id].get_all_xpaths()) instances, _ = EntryInstances.get_required_instances(xpaths) return instances