def _build_remote_request_datums(self): details_helper = DetailsHelper(self.app) if self.module.case_details.short.custom_xml: short_detail_id = 'case_short' long_detail_id = 'case_long' else: short_detail_id = 'search_short' long_detail_id = 'search_long' nodeset = CaseTypeXpath( self.module.case_type).case(instance_name=RESULTS_INSTANCE) if self.module.search_config.search_filter and toggles.USH_CASE_CLAIM_UPDATES.enabled( self.app.domain): nodeset = f"{nodeset}[{interpolate_xpath(self.module.search_config.search_filter)}]" return [ SessionDatum( id=self.module.search_config.case_session_var, nodeset=nodeset, value='./@case_id', detail_select=details_helper.get_detail_id_safe( self.module, short_detail_id), detail_confirm=details_helper.get_detail_id_safe( self.module, long_detail_id), ) ]
def _build_remote_request_datums(self): details_helper = DetailsHelper(self.app) return [SessionDatum( id='case_id', nodeset=(CaseTypeXpath(self.module.case_type) .case(instance_name=RESULTS_INSTANCE)), value='./@case_id', detail_select=details_helper.get_detail_id_safe(self.module, 'case_short'), detail_confirm=details_helper.get_detail_id_safe(self.module, 'case_long'), )]
def _build_remote_request_datums(self): details_helper = DetailsHelper(self.app) if self.module.case_details.short.custom_xml: short_detail_id = 'case_short' else: short_detail_id = 'search_short' nodeset = CaseTypeXpath(self.module.case_type).case(instance_name=RESULTS_INSTANCE) if self.module.search_config.search_filter: nodeset = f"{nodeset}[{interpolate_xpath(self.module.search_config.search_filter)}]" return [SessionDatum( id='case_id', nodeset=nodeset, value='./@case_id', detail_select=details_helper.get_detail_id_safe(self.module, short_detail_id), detail_confirm=details_helper.get_detail_id_safe(self.module, 'case_long'), )]
def __init__(self, app, modules=None): from corehq.apps.app_manager.suite_xml.sections.details import DetailsHelper self.app = app self.modules = modules or list(app.get_modules()) self.details_helper = DetailsHelper(self.app, self.modules)
def get_module_contributions(self, module): if module_offers_search(module): domain = self.app.domain details_helper = DetailsHelper(self.app) remote_request = RemoteRequest( post=RemoteRequestPost( url=absolute_reverse('claim_case', args=[domain]), relevant=module.search_config.relevant, data=[ QueryData( key='case_id', ref=QuerySessionXPath('case_id').instance(), # e.g. instance('querysession')/session/data/case_id ), ]), command=Command( id=id_strings.search_command(module), display=Display(text=Text( locale_id=id_strings.case_search_locale(module)), ), ), instances=[ Instance(id=SESSION_INSTANCE, src='jr://instance/session'), Instance(id='casedb', src='jr://instance/casedb'), ], session=RemoteRequestSession( queries=[ RemoteRequestQuery( url=absolute_reverse('remote_search', args=[domain]), storage_instance=RESULTS_INSTANCE, data=[ QueryData(key='case_type', ref="'{}'".format(module.case_type)), ], prompts=[ QueryPrompt( key=p.name, display=Display( text=Text(locale_id=id_strings. search_property_locale( module, p.name)), ), ) for p in module.search_config.properties ]) ], data=[ SessionDatum( id='case_id', nodeset=(CaseTypeXpath(module.case_type).case( instance_name=RESULTS_INSTANCE).select( u'@status', u'open', quote=True)), value='./@case_id', detail_select=details_helper.get_detail_id_safe( module, 'case_short'), detail_confirm=details_helper.get_detail_id_safe( module, 'case_long'), ) ], ), stack=Stack(), ) frame = CreateFrame() # Open first form in module frame.add_command(XPath.string(id_strings.menu_id(module))) frame.add_datum( StackDatum(id='case_id', value=QuerySessionXPath('case_id').instance())) remote_request.stack.add_frame(frame) return [remote_request] return []
def _details_helper(self): return DetailsHelper(self.app)