예제 #1
0
 def _build_command(self):
     return Command(
         id=id_strings.search_command(self.module),
         display=Display(
             text=Text(locale_id=id_strings.case_search_locale(self.module)),
         ),
     )
예제 #2
0
 def _build_command(self):
     return Command(
         id=id_strings.search_command(self.module),
         display=Display(
             text=Text(locale_id=id_strings.case_search_locale(self.module)),
         ),
     )
예제 #3
0
 def _get_case_search_action(module):
     action = Action(display=Display(text=Text(
         locale_id=id_strings.case_search_locale(module))),
                     stack=Stack())
     frame = PushFrame()
     frame.add_mark()
     frame.add_command(XPath.string(id_strings.search_command(module)))
     action.stack.add_frame(frame)
     return action
예제 #4
0
 def _add_case_search_action_to_detail(detail, module):
     detail.action = Action(
         display=Display(
             text=Text(locale_id=id_strings.case_search_locale(module))
         ),
         stack=Stack()
     )
     frame = PushFrame()
     frame.add_command(XPath.string(id_strings.search_command(module)))
     detail.action.stack.add_frame(frame)
예제 #5
0
 def _get_case_search_action(module):
     action = Action(
         display=Display(
             text=Text(locale_id=id_strings.case_search_locale(module))
         ),
         stack=Stack()
     )
     frame = PushFrame()
     frame.add_mark()
     frame.add_command(XPath.string(id_strings.search_command(module)))
     action.stack.add_frame(frame)
     return action
예제 #6
0
 def _get_case_search_action(module):
     relevant_kwarg = {}
     if module.search_config.search_button_display_condition:
         relevant_kwarg = dict(relevant=XPath(
             module.search_config.search_button_display_condition), )
     action = Action(display=Display(text=Text(
         locale_id=id_strings.case_search_locale(module))),
                     stack=Stack(),
                     **relevant_kwarg)
     frame = PushFrame()
     frame.add_mark()
     frame.add_command(XPath.string(id_strings.search_command(module)))
     action.stack.add_frame(frame)
     return action
예제 #7
0
 def _get_case_search_action(module, in_search=False):
     action_kwargs = DetailContributor._get_action_kwargs(module, in_search)
     action = Action(
         display=Display(text=Text(locale_id=(
             id_strings.case_search_again_locale(module)
             if in_search else id_strings.case_search_locale(module)))),
         stack=Stack(),
         auto_launch=DetailContributor._get_auto_launch_expression(
             module, in_search),
         redo_last=in_search,
         **action_kwargs)
     frame = PushFrame()
     frame.add_mark()
     frame.add_command(XPath.string(id_strings.search_command(module)))
     action.stack.add_frame(frame)
     return action
예제 #8
0
 def _get_case_search_action(module):
     relevant_kwarg = {}
     if module.search_config.search_button_display_condition:
         relevant_kwarg = dict(
             relevant=XPath(module.search_config.search_button_display_condition),
         )
     action = Action(
         display=Display(
             text=Text(locale_id=id_strings.case_search_locale(module))
         ),
         stack=Stack(),
         **relevant_kwarg
     )
     frame = PushFrame()
     frame.add_mark()
     frame.add_command(XPath.string(id_strings.search_command(module)))
     action.stack.add_frame(frame)
     return action
예제 #9
0
 def _get_case_search_action(module):
     relevant_kwarg = {}
     if module.search_config.search_button_display_condition:
         relevant_kwarg = dict(relevant=XPath(
             module.search_config.search_button_display_condition), )
     allow_auto_launch = toggles.CASE_CLAIM_AUTOLAUNCH.enabled(
         module.get_app().domain)
     action = Action(display=Display(text=Text(
         locale_id=id_strings.case_search_locale(module))),
                     stack=Stack(),
                     auto_launch=allow_auto_launch
                     and module.search_config.auto_launch,
                     **relevant_kwarg)
     frame = PushFrame()
     frame.add_mark()
     frame.add_command(XPath.string(id_strings.search_command(module)))
     action.stack.add_frame(frame)
     return action
예제 #10
0
 def _get_case_search_action(module, in_search=False):
     relevant_kwarg = {}
     if not in_search and module.search_config.search_button_display_condition:
         relevant_kwarg = dict(relevant=XPath(
             module.search_config.search_button_display_condition), )
     allow_auto_launch = toggles.USH_CASE_CLAIM_UPDATES.enabled(
         module.get_app().domain) and not in_search
     action = Action(display=Display(text=Text(
         locale_id=(id_strings.case_search_again_locale(module) if in_search
                    else id_strings.case_search_locale(module)))),
                     stack=Stack(),
                     auto_launch=allow_auto_launch
                     and module.search_config.auto_launch,
                     redo_last=in_search,
                     **relevant_kwarg)
     frame = PushFrame()
     frame.add_mark()
     frame.add_command(XPath.string(id_strings.search_command(module)))
     action.stack.add_frame(frame)
     return action
예제 #11
0
    def _get_case_search_action(self, module, in_search=False):
        action_kwargs = DetailContributor._get_action_kwargs(module, in_search)
        if in_search:
            search_label = module.search_config.search_again_label
        else:
            search_label = module.search_config.search_label

        if self.app.enable_localized_menu_media:
            action = LocalizedAction(
                menu_locale_id=(id_strings.case_search_again_locale(module)
                                if in_search else
                                id_strings.case_search_locale(module)),
                media_image=search_label.uses_image(
                    build_profile_id=self.build_profile_id),
                media_audio=search_label.uses_audio(
                    build_profile_id=self.build_profile_id),
                image_locale_id=(
                    id_strings.case_search_again_icon_locale(module) if
                    in_search else id_strings.case_search_icon_locale(module)),
                audio_locale_id=(
                    id_strings.case_search_again_audio_locale(module)
                    if in_search else
                    id_strings.case_search_audio_locale(module)),
                stack=Stack(),
                for_action_menu=True,
                **action_kwargs,
            )
        else:
            action = Action(display=Display(
                text=Text(locale_id=(
                    id_strings.case_search_again_locale(module)
                    if in_search else id_strings.case_search_locale(module))),
                media_image=search_label.default_media_image,
                media_audio=search_label.default_media_audio),
                            stack=Stack(),
                            **action_kwargs)
        frame = PushFrame()
        frame.add_mark()
        frame.add_command(XPath.string(id_strings.search_command(module)))
        action.stack.add_frame(frame)
        return action
예제 #12
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)),
                            ],
                            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 []
예제 #13
0
    def get_module_contributions(self, module):
        if module_offers_search(module):
            domain = self.app.domain

            details_helper = DetailsHelper(self.app)

            sync_request = SyncRequest(
                post=SyncRequestPost(
                    url=absolute_reverse('claim_case', args=[domain]),
                    # Check whether the case to be claimed already exists in casedb:
                    # count(
                    #   instance('casedb')/casedb/case[@case_id=instance('querysession')/session/data/case_id]
                    # ) = 0
                    relevant=XPath.count(
                        CaseIDXPath(QuerySessionXPath('case_id').instance()).case()
                    ) + ' = 0',
                    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'
                )],

                session=SyncRequestSession(
                    queries=[
                        SyncRequestQuery(
                            url=absolute_reverse('sync_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 = PushFrame()
            # Open first form in module
            frame.add_command(XPath.string(id_strings.menu_id(module)))
            frame.add_datum(StackDatum(id=CALCULATED_DATA, value=XPath.string(MARK_AS_CLAIMED)))
            sync_request.stack.add_frame(frame)

            return [sync_request]
        return []