Browse Source

adding more books Markdown conversion

joel
Simon Bowie 1 year ago
parent
commit
7a97764dad
2 changed files with 4 additions and 0 deletions
  1. +3
    -0
      web/app/relationships.py
  2. +1
    -0
      web/app/resources.py

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

@@ -8,6 +8,7 @@
from .models import Resource
from .models import Relationship
from . import db
import markdown

# function to retrieve linked resources
def get_relationships(primary_id):
@@ -51,6 +52,8 @@ def append_relationships(resource):
else:
resource.__dict__['practices'].append(relationship)
elif relationship.type == 'book':
# render Markdown as HTML
relationship.description = markdown.markdown(relationship.description)
if 'books' not in resource.__dict__.keys():
resource.__dict__['books'] = []
resource.__dict__['books'].append(relationship)

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

@@ -32,6 +32,7 @@ def get_full_resource(resource_id):
if resource.type == 'book':
# render Markdown as HTML
resource.description = markdown.markdown(resource.description)
# get additional book metadata
book_data = get_book_data(resource.isbn)
if book_data:
resource.__dict__.update(book_data)

Loading…
Cancel
Save