(self)
return errors
This is the real validation logic, to be overridden/augmented by subclasses.
This is the real validation logic, to be overridden/augmented by subclasses.
This is the real validation logic to be overridden / augmented by subclasses .
def validate_with_raise(self):
        '''
        This is the real validation logic, to be overridden/augmented by subclasses.
        '''
        errors = []
        app = self.module.get_app()
        needs_case_detail = self.module.requires_case_details()
        needs_case_type = needs_case_detail or any(f.is_registration_form() for f in self.module.get_forms())
        if needs_case_detail or needs_case_type:
            errors.extend(self.module.validator.get_case_errors(
                needs_case_type=needs_case_type,
                needs_case_detail=needs_case_detail
            ))
        if self.module.case_list_form.form_id:
            try:
                form = app.get_form(self.module.case_list_form.form_id)
            except FormNotFoundException:
                errors.append({
                    'type': 'case list form missing',
                    'module': self.get_module_info()
                })
            else:
                if toggles.FOLLOWUP_FORMS_AS_CASE_LIST_FORM.enabled(app.domain):
                    from corehq.apps.app_manager.views.modules import get_parent_select_followup_forms
                    valid_forms = [f.unique_id for f in get_parent_select_followup_forms(app, self.module)]
                    if form.unique_id not in valid_forms and not form.is_registration_form(self.module.case_type):
                        errors.append({
                            'type': 'invalid case list followup form',
                            'module': self.get_module_info(),
                            'form': form,
                        })
                elif not form.is_registration_form(self.module.case_type):
                    errors.append({
                        'type': 'case list form not registration',
                        'module': self.get_module_info(),
                        'form': form,
                    })
        if self.module.module_filter:
            is_valid, message = validate_xpath(self.module.module_filter)
            if not is_valid:
                errors.append({
                    'type': 'module filter has xpath error',
                    'xpath_error': message,
                    'module': self.get_module_info(),
                })

        if self.module.put_in_root and self.module.session_endpoint_id:
            errors.append({
                'type': 'endpoint to display only forms',
                'module': self.get_module_info(),
            })

        if module_uses_smart_links(self.module):
            if not self.module.session_endpoint_id:
                errors.append({
                    'type': 'smart links missing endpoint',
                    'module': self.get_module_info(),
                })
            if self.module.parent_select.active:
                errors.append({
                    'type': 'smart links select parent first',
                    'module': self.get_module_info(),
                })

        return errors
def validate_with_raise ( self ) : errors = [ ] app = self . module . get_app ( ) needs_case_detail = self . module . requires_case_details ( ) needs_case_type = needs_case_detail or any ( f . is_registration_form ( ) for f in self . module . get_forms ( ) ) if needs_case_detail or needs_case_type : errors . extend ( self . module . validator . get_case_errors ( needs_case_type = needs_case_type , needs_case_detail = needs_case_detail ) ) if self . module . case_list_form . form_id : try : form = app . get_form ( self . module . case_list_form . form_id ) except FormNotFoundException : errors . append ( { 'type' : 'case list form missing' , 'module' : self . get_module_info ( ) } ) else : if toggles . FOLLOWUP_FORMS_AS_CASE_LIST_FORM . enabled ( app . domain ) : from corehq . apps . app_manager . views . modules import get_parent_select_followup_forms valid_forms = [ f . unique_id for f in get_parent_select_followup_forms ( app , self . module ) ] if form . unique_id not in valid_forms and not form . is_registration_form ( self . module . case_type ) : errors . append ( { 'type' : 'invalid case list followup form' , 'module' : self . get_module_info ( ) , 'form' : form , } ) elif not form . is_registration_form ( self . module . case_type ) : errors . append ( { 'type' : 'case list form not registration' , 'module' : self . get_module_info ( ) , 'form' : form , } ) if self . module . module_filter : is_valid , message = validate_xpath ( self . module . module_filter ) if not is_valid : errors . append ( { 'type' : 'module filter has xpath error' , 'xpath_error' : message , 'module' : self . get_module_info ( ) , } ) if self . module . put_in_root and self . module . session_endpoint_id : errors . append ( { 'type' : 'endpoint to display only forms' , 'module' : self . get_module_info ( ) , } ) if module_uses_smart_links ( self . module ) : if not self . module . session_endpoint_id : errors . append ( { 'type' : 'smart links missing endpoint' , 'module' : self . get_module_info ( ) , } ) if self . module . parent_select . active : errors . append ( { 'type' : 'smart links select parent first' , 'module' : self . get_module_info ( ) , } ) return errors