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

intro_text = markdown.markdown(intro_text) intro_text = markdown.markdown(intro_text)


# DATABASE QUERY # 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 # FILTERING
for key in request.args.keys(): for key in request.args.keys():
# FILTERS MENU # FILTERS MENU
# get values for filter menu dropdowns # get values for filter menu dropdowns
# practices # 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
year_filter = get_filter_values('year', resource_type) year_filter = get_filter_values('year', resource_type)
# typology # typology

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

# all resource types # all resource types
id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy
created = db.Column(db.DateTime, default=datetime.utcnow) created = db.Column(db.DateTime, default=datetime.utcnow)
published = db.Column(db.Boolean)
type = db.Column(db.Text) type = db.Column(db.Text)
name = db.Column(db.Text) name = db.Column(db.Text)
description = db.Column(db.Text) description = db.Column(db.Text)

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

intro_text = markdown.markdown(intro_text) intro_text = markdown.markdown(intro_text)


# DATABASE QUERY # 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 # temporarily removing incomplete practices from main list
practices_query = practices_query.filter( practices_query = practices_query.filter(

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

links = [] links = []
for relationship in primary_relationships: for relationship in primary_relationships:
secondary_id = relationship.second_resource_id 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() secondary_relationships = Relationship.query.filter_by(second_resource_id=primary_id).all()
if secondary_relationships: if secondary_relationships:
for relationship in secondary_relationships: for relationship in secondary_relationships:
primary_id = relationship.first_resource_id 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 return links
else: else:
secondary_relationships = Relationship.query.filter_by(second_resource_id=primary_id).all() secondary_relationships = Relationship.query.filter_by(second_resource_id=primary_id).all()
links = [] links = []
for relationship in secondary_relationships: for relationship in secondary_relationships:
primary_id = relationship.first_resource_id 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 return links


# function to append relationships to a resource object # function to append relationships to a resource object

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



# function to retrieve data about a curated list of resources # function to retrieve data about a curated list of resources
def get_curated_resources(resource_ids): 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 to each resource
append_relationships_multiple(resources) append_relationships_multiple(resources)
return resources return resources

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

intro_text = markdown.markdown(intro_text) intro_text = markdown.markdown(intro_text)


# DATABASE QUERY # 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 # FILTERING
for key in request.args.keys(): for key in request.args.keys():
# FILTERS MENU # FILTERS MENU
# get values for filter menu dropdowns # get values for filter menu dropdowns
# practices # 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 # license
licenses_filter = get_filter_values('license', resource_type) licenses_filter = get_filter_values('license', resource_type)
# language # language

+ 1
- 0
web/requirements.txt View File

requests requests
marshmallow marshmallow
flask-marshmallow flask-marshmallow
marshmallow-sqlalchemy
pandas pandas

Loading…
Cancel
Save