Explorar el Código

adding functional count for each resource

joel
Simon Bowie hace 1 año
padre
commit
b1a7c96622
Se han modificado 7 ficheros con 19 adiciones y 9 borrados
  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 Ver fichero

@@ -30,6 +30,8 @@ def get_books():
else:
kwargs = {'type': type, key: request.args.get(key)}
books = Resource.query.filter_by(**kwargs).all()
# get number of books
count = len(books)
# append relationships to each book
append_relationships_multiple(books)
# get filters
@@ -39,7 +41,7 @@ def get_books():
year_filter = get_filter_values('year', type)
# typology
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
@book.route('/books/<int:book_id>')

+ 3
- 1
web/app/practice.py Ver fichero

@@ -20,9 +20,11 @@ practice = Blueprint('practice', __name__)
@practice.route('/practices')
def get_practices():
practices = Resource.query.filter_by(type='practice').all()
# get number of practices
count = len(practices)
# append relationships to each practice
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
@practice.route('/practices/<int:practice_id>')

+ 1
- 0
web/app/resources.py Ver fichero

@@ -75,6 +75,7 @@ def get_book_data(isbn):
pass

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

+ 4
- 4
web/app/templates/base.html Ver fichero

@@ -20,12 +20,12 @@
{% endif %}
{% 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="grid lg:grid-rows-[auto,auto,auto] grid-flow-col" >
<div class=" w-40 pl-16 pt-4 row-start-1 ">
{% if pre_title == '' %}
<p>1 / 34</p>
<p>{{loop.index}} / {{count}}</p>
{% else %}
<p>{{ pre_title }}</p>
{% endif %}
@@ -63,12 +63,12 @@
</div>
{% 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="grid lg:grid-rows-[auto,auto,auto] grid-flow-col" >
<div class=" w-40 pl-16 pt-4 row-start-1 ">
{% if pre_title == '' %}
<p>1 / 34</p>
<p>{{loop.index}} / {{count}}</p>
{% else %}
<p>{{ pre_title }}</p>
{% endif %}

+ 1
- 0
web/app/templates/resource.html Ver fichero

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

+ 4
- 2
web/app/templates/resources.html Ver fichero

@@ -95,7 +95,8 @@

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

{% if resource.tools %}
TOOLS:
{% for tool in resource.tools %}
{{ tool.name }};
@@ -113,7 +114,8 @@
{{ book.name }};
{% endfor %}
{% endif %}
{{ resource_with_related(resource) }}

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

+ 3
- 1
web/app/tool.py Ver fichero

@@ -33,6 +33,8 @@ def get_tools():
else:
kwargs = {'type': type, key: request.args.get(key)}
tools = Resource.query.filter_by(**kwargs).all()
# get number of tools
count = len(tools)
# append relationships to each tool
append_relationships_multiple(tools)
# get filters
@@ -43,7 +45,7 @@ def get_tools():
licenses_filter = get_filter_values('license', type)
# language
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
@tool.route('/tools/<int:tool_id>')

Cargando…
Cancelar
Guardar