Ability to easily customize _rows_and_columns.html per database table

Also added documentation for this.

Refs #158, Closes #159.
This commit is contained in:
Simon Willison 2017-12-06 22:11:22 -08:00
commit 7e1ba161ec
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
4 changed files with 78 additions and 4 deletions

View file

@ -682,6 +682,11 @@ class TableView(RowTableShared):
'display_columns': display_columns,
'filter_columns': filter_columns,
'display_rows': await self.make_display_rows(name, hash, table, rows, display_columns, pks, is_view, use_rowid, is_row_display=False),
'custom_rows_and_columns_templates': [
'_rows_and_columns-{}-{}.html'.format(to_css_class(name), to_css_class(table)),
'_rows_and_columns-table-{}-{}.html'.format(to_css_class(name), to_css_class(table)),
'_rows_and_columns.html',
]
}
return {
@ -741,6 +746,11 @@ class RowView(RowTableShared):
'foreign_key_tables': await self.foreign_key_tables(name, table, pk_values),
'display_columns': columns,
'display_rows': await self.make_display_rows(name, hash, table, rows, columns, pks, is_view=False, use_rowid=use_rowid, is_row_display=True),
'custom_rows_and_columns_templates': [
'_rows_and_columns-{}-{}.html'.format(to_css_class(name), to_css_class(table)),
'_rows_and_columns-row-{}-{}.html'.format(to_css_class(name), to_css_class(table)),
'_rows_and_columns.html',
]
}
data = {

View file

@ -22,7 +22,7 @@
<p>This data as <a href="{{ url_json }}">.json</a>, <a href="{{ url_jsono }}">.jsono</a></p>
{% include "_rows_and_columns.html" %}
{% include custom_rows_and_columns_templates %}
{% if foreign_key_tables %}
<h2>Links from other tables</h2>

View file

@ -74,7 +74,7 @@
<p>This data as <a href="{{ url_json }}">.json</a>, <a href="{{ url_jsono }}">.jsono</a></p>
{% include "_rows_and_columns.html" %}
{% include custom_rows_and_columns_templates %}
{% if next_url %}
<p><a href="{{ next_url }}">Next page</a></p>