Exemplo n.º 1
0
 def _build_stack(self):
     stack = Stack()
     frame = PushFrame()
     frame.add_rewind(
         QuerySessionXPath(
             self.module.search_config.case_session_var).instance())
     stack.add_frame(frame)
     return stack
Exemplo n.º 2
0
 def build_stack(self):
     stack = Stack()
     rewind_if = None
     if module_uses_smart_links(self.module):
         user_domain_xpath = session_var(COMMCARE_PROJECT, path="user/data")
         # For case in same domain, do a regular case claim rewind
         rewind_if = self._get_case_domain_xpath().eq(user_domain_xpath)
         # For case in another domain, jump to that other domain
         frame = PushFrame(if_clause=XPath.not_(rewind_if))
         frame.add_datum(
             StackJump(url=Text(xpath=TextXPath(
                 function=self.get_smart_link_function(),
                 variables=self.get_smart_link_variables(),
             ), ), ))
         stack.add_frame(frame)
     frame = PushFrame(if_clause=rewind_if)
     frame.add_rewind(QuerySessionXPath(self.case_session_var).instance())
     stack.add_frame(frame)
     return stack
Exemplo n.º 3
0
 def _build_stack(self):
     stack = Stack()
     frame = PushFrame()
     frame.add_rewind(QuerySessionXPath('case_id').instance())
     stack.add_frame(frame)
     return stack
Exemplo n.º 4
0
    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)),
                                QueryData(
                                    key='include_closed',
                                    ref="'{}'".format(
                                        module.search_config.include_closed))
                            ] + [
                                QueryData(key="'{}'".format(c.property),
                                          ref="'{}'".format(c.defaultValue))
                                for c in
                                module.search_config.default_properties
                            ]),
                            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)),
                            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 = PushFrame()
            frame.add_rewind(QuerySessionXPath('case_id').instance())
            remote_request.stack.add_frame(frame)

            return [remote_request]
        return []
Exemplo n.º 5
0
 def _build_stack(self):
     stack = Stack()
     frame = PushFrame()
     frame.add_rewind(QuerySessionXPath('case_id').instance())
     stack.add_frame(frame)
     return stack