| @@ -31,13 +31,14 @@ def get_books(): | |||
| else: | |||
| kwargs = {'type': type, key: request.args.get(key)} | |||
| books = Resource.query.filter_by(**kwargs).all() | |||
| # reorder books by book name | |||
| books = sorted(books, key=lambda d: d.__dict__['name']) | |||
| # get number of books | |||
| count = len(books) | |||
| if view != 'list': | |||
| # 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']) | |||
| # get filters | |||
| # practices | |||
| practices_filter = Resource.query.filter_by(type='practice').with_entities(Resource.id, Resource.name) | |||
| @@ -22,13 +22,14 @@ practice = Blueprint('practice', __name__) | |||
| def get_practices(): | |||
| view = request.args.get('view') | |||
| practices = Resource.query.filter_by(type='practice').all() | |||
| # reorder practices by practice name | |||
| practices = sorted(practices, key=lambda d: d.__dict__['name']) | |||
| # get number of practices | |||
| count = len(practices) | |||
| if view != 'list': | |||
| # append relationships to each practice | |||
| append_relationships_multiple(practices) | |||
| else: | |||
| # reorder practices by practice name | |||
| practices = sorted(practices, key=lambda d: d.__dict__['name']) | |||
| 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 | |||
| @@ -143,8 +143,8 @@ | |||
| > | |||
| {% if (resource['type'] == 'book') %} | |||
| <img class="w-20 h-20 object-contain float-right m-4 grayscale rotate-[15deg]" src="https://dummyimage.com/4:5x70" alt="cover for {{ resource['name'] }}"> | |||
| {% if (resource.type == 'book') and (resource.references) %} | |||
| <img class="w-20 h-20 object-contain float-right m-4 grayscale rotate-[15deg]" src="{{resource.references}}" alt="cover for {{ resource.name }}"> | |||
| {% endif %} | |||
| <h2 class="{{ resource['type'] }} {% if size==1 %} big-title {% else %} small-title {% endif %} mb-2">{{ resource['name'] }}</h2> | |||
| @@ -181,7 +181,7 @@ | |||
| <!DOCTYPE html> | |||
| <html> | |||
| <html lang="en-gb"> | |||
| <head> | |||
| {{ moment.include_moment() }} | |||
| @@ -7,13 +7,13 @@ | |||
| <div class="left"> | |||
| <div class="mb-2">Book</div> | |||
| <div class="border-r-2 border-black pr-8"> | |||
| {% if resource['thumbnail'] %} | |||
| {% if resource.references %} | |||
| <div class="float-right"> | |||
| <img class="w-40 h-40 object-contain m-16 rotate-[15deg]" src={{ resource['thumbnail'] }} alt="cover for {{ resource['Title'] }}"> | |||
| <img class="w-40 h-40 object-contain m-16 rotate-[15deg]" src={{ resource.references }} alt="cover for {{ resource['Title'] }}"> | |||
| </div> | |||
| {% endif %} | |||
| <h2 class="book huge-title mb-2 max-w-[30rem]">{% block title %} {{ resource['Title'] or resource['name'] }} {% endblock %}</h2> | |||
| <h2 class="book huge-title mb-2 max-w-[30rem]">{% block title %} {{ resource.name }} {% endblock %}</h2> | |||
| {% if resource['Year'] %} | |||
| {{ resource['Year'] }} | |||
| @@ -34,13 +34,14 @@ def get_tools(): | |||
| else: | |||
| kwargs = {'type': type, key: request.args.get(key)} | |||
| tools = Resource.query.filter_by(**kwargs).all() | |||
| # reorder tools by tool name | |||
| tools = sorted(tools, key=lambda d: d.__dict__['name']) | |||
| # get number of tools | |||
| count = len(tools) | |||
| if view != 'list': | |||
| # append relationships to each tool | |||
| append_relationships_multiple(tools) | |||
| else: | |||
| # reorder tools by tools name | |||
| tools = sorted(tools, key=lambda d: d.__dict__['name']) | |||
| # get filters | |||
| # practices | |||
| practices_filter = Resource.query.filter_by(type='practice').with_entities(Resource.id, Resource.name) | |||