Last active
May 30, 2016 14:04
-
-
Save zindel/75475cc1beeca40c7fa851a7565366f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fields(table_name, prefix, skip=[]): | |
skip_dict = dict([(f.label, True) for f in skip]) | |
table = model().table(table_name) | |
ret = [] | |
print table | |
print table.schema | |
for f in table.fields(): | |
if f.label in skip_dict: | |
continue | |
ret.append(f.label) | |
return ret | |
def facets(table_name, skip_links_to=[]): | |
schema = model() | |
tables = [] | |
for table in schema.tables(): | |
identity = table.identity().fields | |
if len(identity) == 1 \ | |
and identity[0].is_link \ | |
and identity[0].target_table.label == table_name: | |
tables.append((table, identity[0])) | |
view_facet = lambda table, skip: action(table_name, | |
title='View %s' % table.title, | |
fields=fields(table_name, prefix=table_name, skip=[skip]) | |
) | |
return [view_facet(t, s) | |
for t, s in sorted(tables, key=lambda x: x[0].title)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment