(self, module, detail_type, detail, detail_column_infos, tabs=None, id=None,
                     title=None, nodeset=None, print_template=None, start=0, end=None, relevant=None)
Recursively builds the Detail object.
        (Details can contain other details for each of their tabs)
Recursively builds the Detail object.
        (Details can contain other details for each of their tabs)
Recursively builds the Detail object . ( Details can contain other details for each of their tabs )
def build_detail(self, module, detail_type, detail, detail_column_infos, tabs=None, id=None,
                     title=None, nodeset=None, print_template=None, start=0, end=None, relevant=None):
        """
        Recursively builds the Detail object.
        (Details can contain other details for each of their tabs)
        """
        from corehq.apps.app_manager.detail_screen import get_column_generator
        d = Detail(id=id, title=title, nodeset=nodeset, print_template=print_template, relevant=relevant)
        self._add_custom_variables(detail, d)
        if tabs:
            tab_spans = detail.get_tab_spans()
            for tab in tabs:
                # relevant should be set to None even in case its ''
                tab_relevant = None
                if tab.relevant and toggles.DISPLAY_CONDITION_ON_TABS.enabled(module.get_app().domain):
                    tab_relevant = tab.relevant

                sub_detail = self.build_detail(
                    module,
                    detail_type,
                    detail,
                    detail_column_infos,
                    title=Text(locale_id=id_strings.detail_tab_title_locale(
                        module, detail_type, tab
                    )),
                    nodeset=self._get_detail_tab_nodeset(module, detail, tab),
                    start=tab_spans[tab.id][0],
                    end=tab_spans[tab.id][1],
                    relevant=tab_relevant,
                )
                if sub_detail:
                    d.details.append(sub_detail)
            if len(d.details):
                helper = EntriesHelper(self.app)
                datums = helper.get_datum_meta_module(module)
                d.variables.extend([DetailVariable(name=datum.datum.id, function=datum.datum.value) for datum in datums])
                return d
            else:
                return None

        # Base case (has no tabs)
        else:
            # Add lookup
            if detail.lookup_enabled and detail.lookup_action:
                d.lookup = self._get_lookup_element(detail, module)

            # Add variables
            variables = list(
                schedule_detail_variables(module, detail, detail_column_infos)
            )
            if variables:
                d.variables.extend(variables)

            # Add fields
            if end is None:
                end = len(detail_column_infos)
            for column_info in detail_column_infos[start:end]:
                # column_info is an instance of DetailColumnInfo named tuple. It has the following properties:
                #   column_info.column: an instance of app_manager.models.DetailColumn
                #   column_info.sort_element: an instance of app_manager.models.SortElement
                #   column_info.order: an integer
                fields = get_column_generator(
                    self.app, module, detail, parent_tab_nodeset=nodeset,
                    detail_type=detail_type, *column_info
                ).fields
                for field in fields:
                    d.fields.append(field)

            # Add actions
            if detail_type.endswith('short') and not module.put_in_root:
                if module.case_list_form.form_id:
                    from corehq.apps.app_manager.views.modules import get_parent_select_followup_forms
                    form = self.app.get_form(module.case_list_form.form_id)
                    if toggles.FOLLOWUP_FORMS_AS_CASE_LIST_FORM.enabled(self.app.domain):
                        valid_forms = [f.unique_id for f in get_parent_select_followup_forms(self.app, module)]
                    else:
                        valid_forms = []
                    if form.is_registration_form(module.case_type) or form.unique_id in valid_forms:
                        d.actions.append(self._get_case_list_form_action(module))

                if module_offers_search(module):
                    in_search = module_loads_registry_case(module) or "search" in id
                    d.actions.append(self._get_case_search_action(module, in_search=in_search))

            try:
                if not self.app.enable_multi_sort:
                    d.fields[0].sort = 'default'
            except IndexError:
                pass
            else:
                # only yield the Detail if it has Fields
                return d
def build_detail ( self , module , detail_type , detail , detail_column_infos , tabs = None , id = None , title = None , nodeset = None , print_template = None , start = 0 , end = None , relevant = None ) : from corehq . apps . app_manager . detail_screen import get_column_generator d = Detail ( id = id , title = title , nodeset = nodeset , print_template = print_template , relevant = relevant ) self . _add_custom_variables ( detail , d ) if tabs : tab_spans = detail . get_tab_spans ( ) for tab in tabs : # relevant should be set to None even in case its '' tab_relevant = None if tab . relevant and toggles . DISPLAY_CONDITION_ON_TABS . enabled ( module . get_app ( ) . domain ) : tab_relevant = tab . relevant sub_detail = self . build_detail ( module , detail_type , detail , detail_column_infos , title = Text ( locale_id = id_strings . detail_tab_title_locale ( module , detail_type , tab ) ) , nodeset = self . _get_detail_tab_nodeset ( module , detail , tab ) , start = tab_spans [ tab . id ] [ 0 ] , end = tab_spans [ tab . id ] [ 1 ] , relevant = tab_relevant , ) if sub_detail : d . details . append ( sub_detail ) if len ( d . details ) : helper = EntriesHelper ( self . app ) datums = helper . get_datum_meta_module ( module ) d . variables . extend ( [ DetailVariable ( name = datum . datum . id , function = datum . datum . value ) for datum in datums ] ) return d else : return None # Base case (has no tabs) else : # Add lookup if detail . lookup_enabled and detail . lookup_action : d . lookup = self . _get_lookup_element ( detail , module ) # Add variables variables = list ( schedule_detail_variables ( module , detail , detail_column_infos ) ) if variables : d . variables . extend ( variables ) # Add fields if end is None : end = len ( detail_column_infos ) for column_info in detail_column_infos [ start : end ] : # column_info is an instance of DetailColumnInfo named tuple. It has the following properties: #   column_info.column: an instance of app_manager.models.DetailColumn #   column_info.sort_element: an instance of app_manager.models.SortElement #   column_info.order: an integer fields = get_column_generator ( self . app , module , detail , parent_tab_nodeset = nodeset , detail_type = detail_type , * column_info ) . fields for field in fields : d . fields . append ( field ) # Add actions if detail_type . endswith ( 'short' ) and not module . put_in_root : if module . case_list_form . form_id : from corehq . apps . app_manager . views . modules import get_parent_select_followup_forms form = self . app . get_form ( module . case_list_form . form_id ) if toggles . FOLLOWUP_FORMS_AS_CASE_LIST_FORM . enabled ( self . app . domain ) : valid_forms = [ f . unique_id for f in get_parent_select_followup_forms ( self . app , module ) ] else : valid_forms = [ ] if form . is_registration_form ( module . case_type ) or form . unique_id in valid_forms : d . actions . append ( self . _get_case_list_form_action ( module ) ) if module_offers_search ( module ) : in_search = module_loads_registry_case ( module ) or "search" in id d . actions . append ( self . _get_case_search_action ( module , in_search = in_search ) ) try : if not self . app . enable_multi_sort : d . fields [ 0 ] . sort = 'default' except IndexError : pass else : # only yield the Detail if it has Fields return d