Which will give you:\r
\r
Country Name\r
- Time Zone\r
+ Timezone\r
\r
Note that ``population`` is skipped (as it has ``visible=False``), that the\r
declared verbose name for the ``name`` column is used, and that ``time_zone``\r
import copy\r
from django.utils.datastructures import SortedDict\r
from django.utils.encoding import StrAndUnicode\r
+from django.utils.text import capfirst\r
from columns import Column\r
\r
__all__ = ('BaseTable', 'Table')\r
values = property(_get_values)\r
\r
def __unicode__(self):\r
- return self.column.verbose_name or self.name\r
+ return capfirst(self.column.verbose_name or self.name.replace('_', ' '))\r
\r
def as_html(self):\r
pass\r
# TODO: support function column sources both for modeltables (methods on model) and static tables (functions in dict)\r
# TODO: manual base columns change -> update() call (add as example in docstr here) -> rebuild snapshot: is row cache, column cache etc. reset?\r
# TODO: test that boundcolumn.name works with name overrides and without\r
-# TODO: more beautiful auto column names\r
# TODO: throw an exception on invalid order_by
\ No newline at end of file
# column name override, hidden columns\r
assert [c.name for c in countries.columns] == ['name', 'capital', 'population', 'cc']\r
# verbose_name, and fallback to field name\r
- assert [unicode(c) for c in countries.columns] == ['name', 'capital', 'Population Size', 'Phone Ext.']\r
+ assert [unicode(c) for c in countries.columns] == ['Name', 'Capital', 'Population Size', 'Phone Ext.']\r
\r
# data yielded by each row matches the defined columns\r
for row in countries.rows:\r
\r
assert Template("{% for column in countries.columns %}{{ column }}/{{ column.name }} {% endfor %}").\\r
render(Context({'countries': countries})) == \\r
- "name/name capital/capital Population Size/population Phone Ext./cc "\r
+ "Name/name Capital/capital Population Size/population Phone Ext./cc "\r
\r
assert Template("{% for row in countries %}{% for value in row %}{{ value }} {% endfor %}{% endfor %}").\\r
render(Context({'countries': countries})) == \\r