Browse Source

changes to book covers display

joel
Simon Bowie 1 year ago
parent
commit
d37f9731b6
5 changed files with 16 additions and 13 deletions
  1. +4
    -3
      web/app/book.py
  2. +3
    -2
      web/app/practice.py
  3. +3
    -3
      web/app/templates/base.html
  4. +3
    -3
      web/app/templates/book.html
  5. +3
    -2
      web/app/tool.py

+ 4
- 3
web/app/book.py View File

else: else:
kwargs = {'type': type, key: request.args.get(key)} kwargs = {'type': type, key: request.args.get(key)}
books = Resource.query.filter_by(**kwargs).all() 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 # get number of books
count = len(books) count = len(books)
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'])
# get filters # get filters
# practices # practices
practices_filter = Resource.query.filter_by(type='practice').with_entities(Resource.id, Resource.name) practices_filter = Resource.query.filter_by(type='practice').with_entities(Resource.id, Resource.name)

+ 3
- 2
web/app/practice.py View File

def get_practices(): def get_practices():
view = request.args.get('view') view = request.args.get('view')
practices = Resource.query.filter_by(type='practice').all() 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 # get number of practices
count = len(practices) count = len(practices)
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'])
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

+ 3
- 3
web/app/templates/base.html View File

> >


{% 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 %} {% endif %}
<h2 class="{{ resource['type'] }} {% if size==1 %} big-title {% else %} small-title {% endif %} mb-2">{{ resource['name'] }}</h2> <h2 class="{{ resource['type'] }} {% if size==1 %} big-title {% else %} small-title {% endif %} mb-2">{{ resource['name'] }}</h2>




<!DOCTYPE html> <!DOCTYPE html>
<html>
<html lang="en-gb">


<head> <head>
{{ moment.include_moment() }} {{ moment.include_moment() }}

+ 3
- 3
web/app/templates/book.html View File

<div class="left"> <div class="left">
<div class="mb-2">Book</div> <div class="mb-2">Book</div>
<div class="border-r-2 border-black pr-8"> <div class="border-r-2 border-black pr-8">
{% if resource['thumbnail'] %}
{% if resource.references %}
<div class="float-right"> <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> </div>
{% endif %} {% 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'] %} {% if resource['Year'] %}
{{ resource['Year'] }} {{ resource['Year'] }}

+ 3
- 2
web/app/tool.py View File

else: else:
kwargs = {'type': type, key: request.args.get(key)} kwargs = {'type': type, key: request.args.get(key)}
tools = Resource.query.filter_by(**kwargs).all() 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 # get number of tools
count = len(tools) count = len(tools)
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'])
# get filters # get filters
# practices # practices
practices_filter = Resource.query.filter_by(type='practice').with_entities(Resource.id, Resource.name) practices_filter = Resource.query.filter_by(type='practice').with_entities(Resource.id, Resource.name)

Loading…
Cancel
Save