def _remote_request_query_datums(self): datums = [ QueryData(key='case_type', ref=f"'{case_type}'") for case_type in get_ordered_case_types_for_module(self.module) ] datums.extend( QueryData(key=c.property, ref=c.defaultValue) for c in self.module.search_config.default_properties) if self.module.search_config.blacklisted_owner_ids_expression: datums.append( QueryData( key=CASE_SEARCH_BLACKLISTED_OWNER_ID_KEY, ref=self.module.search_config. blacklisted_owner_ids_expression, )) if module_offers_registry_search(self.module): datums.append( QueryData( key=CASE_SEARCH_REGISTRY_ID_KEY, ref=f"'{self.module.search_config.data_registry}'", )) if self.module.search_config.custom_related_case_property: datums.append( QueryData( key=CASE_SEARCH_CUSTOM_RELATED_CASE_PROPERTY_KEY, ref= f"'{self.module.search_config.custom_related_case_property}'", )) return datums
def _get_remote_request_query_datums(self): default_query_datums = [ QueryData(key='case_type', ref=u"'{}'".format(self.module.case_type)), QueryData(key='include_closed', ref="'{}'".format( self.module.search_config.include_closed)) ] extra_query_datums = [ QueryData(key=u"{}".format(c.property), ref=u"{}".format(c.defaultValue)) for c in self.module.search_config.default_properties ] return default_query_datums + extra_query_datums
def to_stack_datum(self): wanted = (CASE_SEARCH_REGISTRY_ID_KEY, "case_type", "case_id") keys = {el.key for el in self.query.data} data = [ QueryData(key=el.key, ref=el.ref) for el in self.query.data if el.key in wanted ] if "case_id" not in keys and self.next_datum: data.append( QueryData(key="case_id", ref=session_var(self.source_id))) url = self.query.url if self.is_case_search: # we don't need the full search results, just the case that's been selected url = url.replace('/phone/search/', '/phone/registry_case/') return StackQuery(id=self.query.storage_instance, value=url, data=data)
def _get_remote_request_query_datums(self): default_query_datums = [ QueryData(key='case_type', ref="'{}'".format(self.module.case_type)), ] extra_query_datums = [ QueryData(key="{}".format(c.property), ref="{}".format(c.defaultValue)) for c in self.module.search_config.default_properties ] if self.module.search_config.blacklisted_owner_ids_expression: extra_query_datums.append( QueryData(key=CASE_SEARCH_BLACKLISTED_OWNER_ID_KEY, ref="{}".format(self.module.search_config. blacklisted_owner_ids_expression))) return default_query_datums + extra_query_datums
def _build_remote_request_post(self): return RemoteRequestPost( url=absolute_reverse('claim_case', args=[self.domain]), relevant=self.module.search_config.relevant, data=[ QueryData( key='case_id', ref=QuerySessionXPath('case_id').instance(), ), ])
def _build_remote_request_post(self): kwargs = { "url": absolute_reverse('claim_case', args=[self.domain]), "data": [ QueryData( key='case_id', ref=QuerySessionXPath('case_id').instance(), ), ], } if self.module.search_config.relevant: kwargs["relevant"] = self.module.search_config.relevant return RemoteRequestPost(**kwargs)
def build_case_id_query_data(self): data = QueryData(key='case_id') if self.module.is_multi_select(): data.ref = "." data.nodeset = self._get_multi_select_nodeset() data.exclude = self._get_multi_select_exclude() else: data.ref = QuerySessionXPath(self.case_session_var).instance() return data
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 []