def test_call_with_appropriate(): def foo(): return 'bar' assert call_with_appropriate(foo, {'a': 'd', 'c': 'e'}) == 'bar' def bar(baz): return baz assert call_with_appropriate(bar, dict(baz=23)) == 23
def test_basic(self): def foo(): return "bar" assert call_with_appropriate(foo, {"a": "d", "c": "e"}) == "bar" def bar(baz): return baz assert call_with_appropriate(bar, dict(baz=23)) == 23
def test_basic(self): def foo(): return 'bar' assert call_with_appropriate(foo, { 'a': 'd', 'c': 'e' }) == 'bar' def bar(baz): return baz assert call_with_appropriate(bar, dict(baz=23)) == 23
def compose_url(self, **kwargs): if self.url and callable(self.url): return call_with_appropriate(self.url, kwargs) bound_column = kwargs.get("bound_column", None) record = kwargs["record"] if self.reverse_args.get("viewname", None) is not None: return self.call_reverse(record=record) if bound_column is None and self.accessor is None: accessor = Accessor("") else: accessor = Accessor(self.accessor if self.accessor is not None else bound_column.name) context = accessor.resolve(record) if not hasattr(context, "get_absolute_url"): if hasattr(record, "get_absolute_url"): context = record else: raise TypeError( "for linkify=True, '{}' must have a method get_absolute_url".format( str(context) ) ) return context.get_absolute_url()
def footer(self, bound_column, table): """ Returns the content of the footer, if specified. """ footer_kwargs = {"column": self, "bound_column": bound_column, "table": table} if self._footer is not None: if callable(self._footer): return call_with_appropriate(self._footer, footer_kwargs) else: return self._footer if hasattr(self, "render_footer"): return call_with_appropriate(self.render_footer, footer_kwargs) return ""
def footer(self, bound_column, table): footer_kwargs = { 'column': self, 'bound_column': bound_column, 'table': table } if self._footer is not None: if callable(self._footer): return call_with_appropriate(self._footer, footer_kwargs) else: return self._footer if hasattr(self, 'render_footer'): return call_with_appropriate(self.render_footer, footer_kwargs) return ''
def footer(self, bound_column, table): footer_kwargs = { 'column': self, 'bound_column': bound_column, 'table': table } if self._footer is not None: if callable(self._footer): return call_with_appropriate(self._footer, footer_kwargs) else: return self._footer if hasattr(self, 'render_footer'): return call_with_appropriate(self.render_footer, footer_kwargs) return ''
def footer(self, bound_column, table): """ Returns the content of the footer, if specified. """ footer_kwargs = { "column": self, "bound_column": bound_column, "table": table } if self._footer is not None: if callable(self._footer): return call_with_appropriate(self._footer, footer_kwargs) else: return self._footer if hasattr(self, "render_footer"): return call_with_appropriate(self.render_footer, footer_kwargs) return ""
def footer(self, bound_column, table): ''' Returns the content of the footer, if specified. ''' footer_kwargs = { 'column': self, 'bound_column': bound_column, 'table': table } if self._footer is not None: if callable(self._footer): return call_with_appropriate(self._footer, footer_kwargs) else: return self._footer if hasattr(self, 'render_footer'): return call_with_appropriate(self.render_footer, footer_kwargs) return ''
def value(self, **kwargs): ''' Returns the content for a specific cell similarly to `.render` however without any html content. This can be used to get the data in the formatted as it is presented but in a form that could be added to a csv file. The default implementation just calls the `render` function but any subclasses where `render` returns html content should override this method. See `LinkColumn` for an example. ''' return call_with_appropriate(self.render, kwargs)
def value(self, **kwargs): ''' Returns the content for a specific cell similarly to `.render` however without any html content. This can be used to get the data in the formatted as it is presented but in a form that could be added to a csv file. The default implementation just calls the `render` function but any subclasses where `render` returns html content should override this method. See `LinkColumn` for an example. ''' return call_with_appropriate(self.render, kwargs)
def value(self, **kwargs): ''' Returns the content for a specific cell similarly to `.render` however without any html content. This can be used to get the data in the formatted as it is presented but in a form that could be added to a csv file. The default implementation just calls the `render` function but any subclasses where `render` returns html content should override this method. See `LinkColumn` for an example. ''' value = call_with_appropriate(self.render, kwargs) # convert model instances to string, otherwise exporting to xls fails. if isinstance(value, models.Model): value = str(value) return value
def compose_url(self, **kwargs): if self.url and callable(self.url): return call_with_appropriate(self.url, kwargs) bound_column = kwargs["bound_column"] record = kwargs["record"] if self.reverse_args.get("viewname", None) is not None: return self.call_reverse(record=record) accessor = Accessor( self.accessor if self.accessor is not None else bound_column.name) context = accessor.resolve(record) if not hasattr(context, "get_absolute_url"): if hasattr(record, "get_absolute_url"): context = record else: raise TypeError( "for linkify=True, '{}' must have a method get_absolute_url" .format(str(context))) return context.get_absolute_url()
def footer(self): return call_with_appropriate(self.column.footer, { 'bound_column': self, 'table': self.table })
def footer(self): return call_with_appropriate(self.column.footer, { 'bound_column': self, 'table': self.table })
def footer(self): return call_with_appropriate(self.column.footer, { "bound_column": self, "table": self._table })
def footer(self): return call_with_appropriate( self.column.footer, {"bound_column": self, "table": self._table} )