@@ -33,7 +33,7 @@ def get_books(): | |||
intro_text = markdown.markdown(intro_text) | |||
# DATABASE QUERY | |||
books_query = Resource.query.filter_by(type=resource_type) | |||
books_query = Resource.query.filter_by(type=resource_type).filter_by(published=True) | |||
# FILTERING | |||
for key in request.args.keys(): | |||
@@ -52,7 +52,7 @@ def get_books(): | |||
# FILTERS MENU | |||
# get values for filter menu dropdowns | |||
# practices | |||
practices_filter = Resource.query.filter_by(type='practice').with_entities(Resource.id, Resource.name).all() | |||
practices_filter = Resource.query.filter_by(type='practice').filter_by(published=True).with_entities(Resource.id, Resource.name).all() | |||
# year | |||
year_filter = get_filter_values('year', resource_type) | |||
# typology |
@@ -26,6 +26,7 @@ class Resource(db.Model): | |||
# all resource types | |||
id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy | |||
created = db.Column(db.DateTime, default=datetime.utcnow) | |||
published = db.Column(db.Boolean) | |||
type = db.Column(db.Text) | |||
name = db.Column(db.Text) | |||
description = db.Column(db.Text) |
@@ -34,7 +34,7 @@ def get_practices(): | |||
intro_text = markdown.markdown(intro_text) | |||
# DATABASE QUERY | |||
practices_query = Resource.query.filter_by(type=resource_type) | |||
practices_query = Resource.query.filter_by(type=resource_type).filter_by(published=True) | |||
# temporarily removing incomplete practices from main list | |||
practices_query = practices_query.filter( |
@@ -18,12 +18,12 @@ def get_relationships(primary_id): | |||
links = [] | |||
for relationship in primary_relationships: | |||
secondary_id = relationship.second_resource_id | |||
links.extend(Resource.query.filter_by(id=secondary_id).all()) | |||
links.extend(Resource.query.filter_by(id=secondary_id).filter_by(published=True).all()) | |||
secondary_relationships = Relationship.query.filter_by(second_resource_id=primary_id).all() | |||
if secondary_relationships: | |||
for relationship in secondary_relationships: | |||
primary_id = relationship.first_resource_id | |||
links.extend(Resource.query.filter_by(id=primary_id).all()) | |||
links.extend(Resource.query.filter_by(id=primary_id).filter_by(published=True).all()) | |||
return links | |||
else: | |||
secondary_relationships = Relationship.query.filter_by(second_resource_id=primary_id).all() | |||
@@ -31,7 +31,7 @@ def get_relationships(primary_id): | |||
links = [] | |||
for relationship in secondary_relationships: | |||
primary_id = relationship.first_resource_id | |||
links.extend(Resource.query.filter_by(id=primary_id).all()) | |||
links.extend(Resource.query.filter_by(id=primary_id).filter_by(published=True).all()) | |||
return links | |||
# function to append relationships to a resource object |
@@ -40,7 +40,7 @@ def get_full_resource(resource_id): | |||
# function to retrieve data about a curated list of resources | |||
def get_curated_resources(resource_ids): | |||
resources = Resource.query.filter(Resource.id.in_(resource_ids)).order_by(func.random()).all() | |||
resources = Resource.query.filter(Resource.id.in_(resource_ids)).filter_by(published=True).order_by(func.random()).all() | |||
# append relationships to each resource | |||
append_relationships_multiple(resources) | |||
return resources |
@@ -33,7 +33,7 @@ def get_tools(): | |||
intro_text = markdown.markdown(intro_text) | |||
# DATABASE QUERY | |||
tools_query = Resource.query.filter_by(type=resource_type) | |||
tools_query = Resource.query.filter_by(type=resource_type).filter_by(published=True) | |||
# FILTERING | |||
for key in request.args.keys(): | |||
@@ -55,7 +55,7 @@ def get_tools(): | |||
# FILTERS MENU | |||
# get values for filter menu dropdowns | |||
# practices | |||
practices_filter = Resource.query.filter_by(type='practice').with_entities(Resource.id, Resource.name).all() | |||
practices_filter = Resource.query.filter_by(type='practice').filter_by(published=True).with_entities(Resource.id, Resource.name).all() | |||
# license | |||
licenses_filter = get_filter_values('license', resource_type) | |||
# language |
@@ -10,4 +10,5 @@ isbntools | |||
requests | |||
marshmallow | |||
flask-marshmallow | |||
marshmallow-sqlalchemy | |||
pandas |