Browse Source

first steps for adding approval process: adding published status

main
Simon Bowie 6 months ago
parent
commit
c0c21bf519
7 changed files with 11 additions and 9 deletions
  1. +2
    -2
      web/app/book.py
  2. +1
    -0
      web/app/models.py
  3. +1
    -1
      web/app/practice.py
  4. +3
    -3
      web/app/relationships.py
  5. +1
    -1
      web/app/resources.py
  6. +2
    -2
      web/app/tool.py
  7. +1
    -0
      web/requirements.txt

+ 2
- 2
web/app/book.py View File

@@ -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

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

@@ -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)

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

@@ -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(

+ 3
- 3
web/app/relationships.py View File

@@ -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

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

@@ -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

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

@@ -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

+ 1
- 0
web/requirements.txt View File

@@ -10,4 +10,5 @@ isbntools
requests
marshmallow
flask-marshmallow
marshmallow-sqlalchemy
pandas

Loading…
Cancel
Save