def _get_sub_attribute_checker(self, filter_name, attribute_path, filters, noop_checker, text_search=False): if filters.get(filter_name): if text_search: return lambda c: filters[filter_name].lower() in getattr_path( c, attribute_path, '').lower() return lambda c: getattr_path(c, attribute_path) == filters[ filter_name] return noop_checker
def triggered(self, record) -> Triggered: value = getattr_path(record, self.record_attr_path, None) if not value: contains_symbols = False else: contains_symbols = self.contains_symbols(value) return Triggered(contains_symbols)
def test_blank_sender_roll_number(self): self.assertAllResponsesHaveBlankField( { 'sender_roll_number__isblank': 'True' }, ['sender_roll_number'], lambda credit: getattr_path(credit, 'transaction.sender_roll_number', None) == '' )
def _get_prison_type_checker(self, filter_name, list_attribute_path, filters, noop_checker): if filters.get(filter_name): filter_list = filters[filter_name] if isinstance(filters[filter_name], list) else [filters[filter_name]] return lambda c: any( value in [t.name for t in getattr_path(c, list_attribute_path).all()] for value in filter_list ) return noop_checker
def _get_prison_type_checker(self, filter_name, list_attribute_path, filters, noop_checker): if filters.get(filter_name): filter_list = filters[filter_name] if isinstance( filters[filter_name], list) else [filters[filter_name]] return lambda c: any(value in [ t.name for t in getattr_path(c, list_attribute_path).all() ] for value in filter_list) return noop_checker
def has_permission(self, request): has_permission = super().has_permission(request) required_permissions = getattr_path(request, 'resolver_match.func.view_class.required_permissions', []) return has_permission and request.user.has_perms(required_permissions)
def _get_sub_attribute_checker(self, filter_name, attribute_path, filters, noop_checker, text_search=False): if filters.get(filter_name): if text_search: return lambda c: filters[filter_name].lower() in getattr_path(c, attribute_path, '').lower() return lambda c: getattr_path(c, attribute_path) == filters[filter_name] return noop_checker