books = books_query.all() | books = books_query.all() | ||||
# get number of books | # get number of books | ||||
count = len(books) | count = len(books) | ||||
# reorder books by book name | |||||
books = sorted(books, key=lambda d: d.__dict__['name'].lower()) | |||||
if view != 'list': | if view != 'list': | ||||
# append relationships to each book | # append relationships to each book | ||||
append_relationships_multiple(books) | append_relationships_multiple(books) | ||||
else: | |||||
# reorder books by book name | |||||
books = sorted(books, key=lambda d: d.__dict__['name'].lower()) | |||||
# get values for filters | # get values for filters | ||||
# practices | # practices | ||||
practices_filter = Resource.query.filter_by(type='practice').with_entities(Resource.id, Resource.name).all() | practices_filter = Resource.query.filter_by(type='practice').with_entities(Resource.id, Resource.name).all() |
practices = Resource.query.filter_by(type='practice').order_by(func.random()).all() | practices = Resource.query.filter_by(type='practice').order_by(func.random()).all() | ||||
# get number of practices | # get number of practices | ||||
count = len(practices) | count = len(practices) | ||||
# reorder practices by practice name | |||||
practices = sorted(practices, key=lambda d: d.__dict__['name'].lower()) | |||||
if view != 'list': | if view != 'list': | ||||
# append relationships to each practice | # append relationships to each practice | ||||
append_relationships_multiple(practices) | append_relationships_multiple(practices) | ||||
else: | |||||
# reorder practices by practice name | |||||
practices = sorted(practices, key=lambda d: d.__dict__['name'].lower()) | |||||
return render_template('resources.html', resources=practices, type='practice', count=count, view=view) | return render_template('resources.html', resources=practices, type='practice', count=count, view=view) | ||||
# route for displaying a single practice based on the ID in the database | # route for displaying a single practice based on the ID in the database |
tools = tools_query.all() | tools = tools_query.all() | ||||
# get number of tools | # get number of tools | ||||
count = len(tools) | count = len(tools) | ||||
# reorder tools by tools name | |||||
tools = sorted(tools, key=lambda d: d.__dict__['name'].lower()) | |||||
if view != 'list': | if view != 'list': | ||||
# append relationships to each tool | # append relationships to each tool | ||||
append_relationships_multiple(tools) | append_relationships_multiple(tools) | ||||
else: | |||||
# reorder tools by tools name | |||||
tools = sorted(tools, key=lambda d: d.__dict__['name'].lower()) | |||||
# get values for filters | # get values for filters | ||||
# practices | # practices | ||||
practices_filter = Resource.query.filter_by(type='practice').with_entities(Resource.id, Resource.name).all() | practices_filter = Resource.query.filter_by(type='practice').with_entities(Resource.id, Resource.name).all() |