Browse Source

adding functional count for each resource

joel
Simon Bowie 1 year ago
parent
commit
b1a7c96622
7 changed files with 19 additions and 9 deletions
  1. +3
    -1
      web/app/book.py
  2. +3
    -1
      web/app/practice.py
  3. +1
    -0
      web/app/resources.py
  4. +4
    -4
      web/app/templates/base.html
  5. +1
    -0
      web/app/templates/resource.html
  6. +4
    -2
      web/app/templates/resources.html
  7. +3
    -1
      web/app/tool.py

+ 3
- 1
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()
# get number of books
count = len(books)
# append relationships to each book # append relationships to each book
append_relationships_multiple(books) append_relationships_multiple(books)
# get filters # get filters
year_filter = get_filter_values('year', type) year_filter = get_filter_values('year', type)
# typology # typology
typology_filter = get_filter_values('typology', type) typology_filter = get_filter_values('typology', type)
return render_template('resources.html', resources=books, type=type, practices_filter=practices_filter, year_filter=year_filter, typology_filter=typology_filter)
return render_template('resources.html', resources=books, type=type, practices_filter=practices_filter, year_filter=year_filter, typology_filter=typology_filter, count=count)


# route for displaying a single book based on the ID in the database # route for displaying a single book based on the ID in the database
@book.route('/books/<int:book_id>') @book.route('/books/<int:book_id>')

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

@practice.route('/practices') @practice.route('/practices')
def get_practices(): def get_practices():
practices = Resource.query.filter_by(type='practice').all() practices = Resource.query.filter_by(type='practice').all()
# get number of practices
count = len(practices)
# append relationships to each practice # append relationships to each practice
append_relationships_multiple(practices) append_relationships_multiple(practices)
return render_template('resources.html', resources=practices, type='practice')
return render_template('resources.html', resources=practices, type='practice', count=count)


# 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
@practice.route('/practices/<int:practice_id>') @practice.route('/practices/<int:practice_id>')

+ 1
- 0
web/app/resources.py View File

pass pass


# function to get full metadata for a book and combine into one object # function to get full metadata for a book and combine into one object
# TO BE DELETED
def get_book(resource_id): def get_book(resource_id):
book = get_resource(resource_id) book = get_resource(resource_id)
book_data = get_book_data(book.isbn) book_data = get_book_data(book.isbn)

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

{% endif %} {% endif %}
{% endmacro %} {% endmacro %}


{% macro book_with_related(resource, relationships, pre_title='', post_title='Related') %}
{% macro book_with_related(resource, loop, relationships, pre_title='', post_title='Related') %}
<div class="w-full overflow-x-scroll my-8 pb-12 border-b-2 border-black"> <div class="w-full overflow-x-scroll my-8 pb-12 border-b-2 border-black">
<div class="grid lg:grid-rows-[auto,auto,auto] grid-flow-col" > <div class="grid lg:grid-rows-[auto,auto,auto] grid-flow-col" >
<div class=" w-40 pl-16 pt-4 row-start-1 "> <div class=" w-40 pl-16 pt-4 row-start-1 ">
{% if pre_title == '' %} {% if pre_title == '' %}
<p>1 / 34</p>
<p>{{loop.index}} / {{count}}</p>
{% else %} {% else %}
<p>{{ pre_title }}</p> <p>{{ pre_title }}</p>
{% endif %} {% endif %}
</div> </div>
{% endmacro %} {% endmacro %}


{% macro resource_with_related(resource, pre_title='', post_title='Related') %}
{% macro resource_with_related(resource, loop, pre_title='', post_title='Related') %}
<div class="w-full overflow-x-scroll my-8 pb-12 border-b-2 border-black"> <div class="w-full overflow-x-scroll my-8 pb-12 border-b-2 border-black">
<div class="grid lg:grid-rows-[auto,auto,auto] grid-flow-col" > <div class="grid lg:grid-rows-[auto,auto,auto] grid-flow-col" >
<div class=" w-40 pl-16 pt-4 row-start-1 "> <div class=" w-40 pl-16 pt-4 row-start-1 ">
{% if pre_title == '' %} {% if pre_title == '' %}
<p>1 / 34</p>
<p>{{loop.index}} / {{count}}</p>
{% else %} {% else %}
<p>{{ pre_title }}</p> <p>{{ pre_title }}</p>
{% endif %} {% endif %}

+ 1
- 0
web/app/templates/resource.html View File

<div class="right lg:mt-16 max-w-[30rem] mx-auto p-4"> <div class="right lg:mt-16 max-w-[30rem] mx-auto p-4">
{{ relationships_links(relationships) }} {{ relationships_links(relationships) }}
{% if resource.tools %} {% if resource.tools %}
TOOLS: TOOLS:
{% for tool in resource.tools %} {% for tool in resource.tools %}

+ 4
- 2
web/app/templates/resources.html View File



<div> <div>
{% for resource in resources %} {% for resource in resources %}
{% if resource.tools %}

{% if resource.tools %}
TOOLS: TOOLS:
{% for tool in resource.tools %} {% for tool in resource.tools %}
{{ tool.name }}; {{ tool.name }};
{{ book.name }}; {{ book.name }};
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{{ resource_with_related(resource) }}

{{ resource_with_related(resource, loop) }}
{% endfor %} {% endfor %}
</div> </div>
</div> </div>

+ 3
- 1
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()
# get number of tools
count = len(tools)
# append relationships to each tool # append relationships to each tool
append_relationships_multiple(tools) append_relationships_multiple(tools)
# get filters # get filters
licenses_filter = get_filter_values('license', type) licenses_filter = get_filter_values('license', type)
# language # language
languages_filter = get_filter_values('scriptingLanguage', type) languages_filter = get_filter_values('scriptingLanguage', type)
return render_template('resources.html', resources=tools, type=type, practices_filter=practices_filter, licenses_filter=licenses_filter, languages_filter=languages_filter)
return render_template('resources.html', resources=tools, type=type, practices_filter=practices_filter, licenses_filter=licenses_filter, languages_filter=languages_filter, count=count)


# route for displaying a single tool based on the ID in the database # route for displaying a single tool based on the ID in the database
@tool.route('/tools/<int:tool_id>') @tool.route('/tools/<int:tool_id>')

Loading…
Cancel
Save