(request, app, module, case_property_builder, lang=None)
return context
Get context items that are used by both basic and advanced modules.
Get context items that are used by both basic and advanced modules.
Get context items that are used by both basic and advanced modules .
def _get_shared_module_view_context(request, app, module, case_property_builder, lang=None):
    '''
    Get context items that are used by both basic and advanced modules.
    '''
    item_lists = item_lists_by_app(app) if app.enable_search_prompt_appearance else []
    case_types = set(module.search_config.additional_case_types) | {module.case_type}
    context = {
        'details': _get_module_details_context(request, app, module, case_property_builder),
        'case_list_form_options': _case_list_form_options(app, module, lang),
        'valid_parents_for_child_module': _get_valid_parents_for_child_module(app, module),
        'shadow_parent': _get_shadow_parent(app, module),
        'case_types': {m.case_type for m in app.modules if m.case_type},
        'session_endpoints_enabled': toggles.SESSION_ENDPOINTS.enabled(app.domain),
        'data_registry_enabled': app.supports_data_registry,
        'data_registries': get_data_registry_dropdown_options(app.domain, required_case_types=case_types),
        'data_registry_workflow_choices': (
            (REGISTRY_WORKFLOW_LOAD_CASE, _("Load external case into form")),
            (REGISTRY_WORKFLOW_SMART_LINK, _("Smart link to external domain")),
        ),
        'js_options': {
            'fixture_columns_by_type': _get_fixture_columns_by_type(app.domain),
            'is_search_enabled': case_search_enabled_for_domain(app.domain),
            'search_prompt_appearance_enabled': app.enable_search_prompt_appearance,
            'has_geocoder_privs': (
                domain_has_privilege(app.domain, privileges.GEOCODER)
                and toggles.USH_CASE_CLAIM_UPDATES.enabled(app.domain)
            ),
            'item_lists': item_lists,
            'has_lookup_tables': bool([i for i in item_lists if i['fixture_type'] == 'lookup_table_fixture']),
            'has_mobile_ucr': bool([i for i in item_lists if i['fixture_type'] == 'report_fixture']),
            'search_properties': module.search_config.properties if module_offers_search(module) else [],
            'auto_launch': module.search_config.auto_launch if module_offers_search(module) else False,
            'default_search': module.search_config.default_search if module_offers_search(module) else False,
            'default_properties': module.search_config.default_properties if module_offers_search(module) else [],
            'search_filter': module.search_config.search_filter if module_offers_search(module) else "",
            'search_button_display_condition':
                module.search_config.search_button_display_condition if module_offers_search(module) else "",
            'search_default_relevant':
                module.search_config.default_relevant if module_offers_search(module) else True,
            'search_additional_relevant':
                module.search_config.additional_relevant if module_offers_search(module) else "",
            'blacklisted_owner_ids_expression': (
                module.search_config.blacklisted_owner_ids_expression if module_offers_search(module) else ""),
            'default_value_expression_enabled': app.enable_default_value_expression,
            # populate these even if module_offers_search is false because search_config might just not exist yet
            'search_label':
                module.search_config.search_label.label if hasattr(module, 'search_config') else "",
            'search_again_label':
                module.search_config.search_again_label.label if hasattr(module, 'search_config') else "",
            'data_registry': module.search_config.data_registry,
            'data_registry_workflow': module.search_config.data_registry_workflow,
            'additional_registry_cases': module.search_config.additional_registry_cases,
            'custom_related_case_property': module.search_config.custom_related_case_property,
        },
    }
    if toggles.CASE_DETAIL_PRINT.enabled(app.domain):
        slug = 'module_%s_detail_print' % module.unique_id
        print_template = module.case_details.long.print_template
        print_uploader = MultimediaHTMLUploadController(
            slug,
            reverse(
                ProcessDetailPrintTemplateUploadView.urlname,
                args=[app.domain, app.id, module.unique_id],
            )
        )
        if not print_template:
            print_template = {
                'path': 'jr://file/commcare/text/%s.html' % slug,
            }
        context.update({
            'print_uploader': print_uploader,
            'print_uploader_js': print_uploader.js_options,
            'print_ref': ApplicationMediaReference(
                print_template.get('path'),
                media_class=CommCareMultimedia,
            ).as_dict(),
            'print_media_info': print_template,
        })
    return context
def _get_shared_module_view_context ( request , app , module , case_property_builder , lang = None ) : item_lists = item_lists_by_app ( app ) if app . enable_search_prompt_appearance else [ ] case_types = set ( module . search_config . additional_case_types ) | { module . case_type } context = { 'details' : _get_module_details_context ( request , app , module , case_property_builder ) , 'case_list_form_options' : _case_list_form_options ( app , module , lang ) , 'valid_parents_for_child_module' : _get_valid_parents_for_child_module ( app , module ) , 'shadow_parent' : _get_shadow_parent ( app , module ) , 'case_types' : { m . case_type for m in app . modules if m . case_type } , 'session_endpoints_enabled' : toggles . SESSION_ENDPOINTS . enabled ( app . domain ) , 'data_registry_enabled' : app . supports_data_registry , 'data_registries' : get_data_registry_dropdown_options ( app . domain , required_case_types = case_types ) , 'data_registry_workflow_choices' : ( ( REGISTRY_WORKFLOW_LOAD_CASE , _ ( "Load external case into form" ) ) , ( REGISTRY_WORKFLOW_SMART_LINK , _ ( "Smart link to external domain" ) ) , ) , 'js_options' : { 'fixture_columns_by_type' : _get_fixture_columns_by_type ( app . domain ) , 'is_search_enabled' : case_search_enabled_for_domain ( app . domain ) , 'search_prompt_appearance_enabled' : app . enable_search_prompt_appearance , 'has_geocoder_privs' : ( domain_has_privilege ( app . domain , privileges . GEOCODER ) and toggles . USH_CASE_CLAIM_UPDATES . enabled ( app . domain ) ) , 'item_lists' : item_lists , 'has_lookup_tables' : bool ( [ i for i in item_lists if i [ 'fixture_type' ] == 'lookup_table_fixture' ] ) , 'has_mobile_ucr' : bool ( [ i for i in item_lists if i [ 'fixture_type' ] == 'report_fixture' ] ) , 'search_properties' : module . search_config . properties if module_offers_search ( module ) else [ ] , 'auto_launch' : module . search_config . auto_launch if module_offers_search ( module ) else False , 'default_search' : module . search_config . default_search if module_offers_search ( module ) else False , 'default_properties' : module . search_config . default_properties if module_offers_search ( module ) else [ ] , 'search_filter' : module . search_config . search_filter if module_offers_search ( module ) else "" , 'search_button_display_condition' : module . search_config . search_button_display_condition if module_offers_search ( module ) else "" , 'search_default_relevant' : module . search_config . default_relevant if module_offers_search ( module ) else True , 'search_additional_relevant' : module . search_config . additional_relevant if module_offers_search ( module ) else "" , 'blacklisted_owner_ids_expression' : ( module . search_config . blacklisted_owner_ids_expression if module_offers_search ( module ) else "" ) , 'default_value_expression_enabled' : app . enable_default_value_expression , # populate these even if module_offers_search is false because search_config might just not exist yet 'search_label' : module . search_config . search_label . label if hasattr ( module , 'search_config' ) else "" , 'search_again_label' : module . search_config . search_again_label . label if hasattr ( module , 'search_config' ) else "" , 'data_registry' : module . search_config . data_registry , 'data_registry_workflow' : module . search_config . data_registry_workflow , 'additional_registry_cases' : module . search_config . additional_registry_cases , 'custom_related_case_property' : module . search_config . custom_related_case_property , } , } if toggles . CASE_DETAIL_PRINT . enabled ( app . domain ) : slug = 'module_%s_detail_print' % module . unique_id print_template = module . case_details . long . print_template print_uploader = MultimediaHTMLUploadController ( slug , reverse ( ProcessDetailPrintTemplateUploadView . urlname , args = [ app . domain , app . id , module . unique_id ] , ) ) if not print_template : print_template = { 'path' : 'jr://file/commcare/text/%s.html' % slug , } context . update ( { 'print_uploader' : print_uploader , 'print_uploader_js' : print_uploader . js_options , 'print_ref' : ApplicationMediaReference ( print_template . get ( 'path' ) , media_class = CommCareMultimedia , ) . as_dict ( ) , 'print_media_info' : print_template , } ) return context