| @@ -12,6 +12,7 @@ from .models import Resource | |||
| from .resources import * | |||
| from .relationships import * | |||
| from . import db | |||
| from sqlalchemy import text | |||
| import os | |||
| book = Blueprint('book', __name__) | |||
| @@ -24,7 +25,8 @@ def get_books(): | |||
| for key in request.args.keys(): | |||
| if key == 'practice': | |||
| query = 'SELECT Resource.* FROM Resource LEFT JOIN Relationship ON Resource.id=Relationship.first_resource_id WHERE Relationship.second_resource_id=' + request.args.get(key) + ' AND Resource.type="' + type + '";' | |||
| books = db.engine.execute(query) | |||
| with db.engine.connect() as conn: | |||
| books = conn.execute(text(query)) | |||
| else: | |||
| kwargs = {'type': type, key: request.args.get(key)} | |||
| books = Resource.query.filter_by(**kwargs) | |||
| @@ -62,6 +64,7 @@ def edit_book(book_id): | |||
| book.year = request.form['year'] | |||
| book.bookUrl = request.form['bookUrl'] | |||
| book.isbn = request.form['isbn'] | |||
| book.typology = request.form['typology'] | |||
| db.session.commit() | |||
| linked_resources = request.form.getlist('linked_resources') | |||
| remove_linked_resources = request.form.getlist('remove_linked_resources') | |||
| @@ -43,14 +43,16 @@ class Resource(db.Model): | |||
| outputFormats = db.Column(db.Text) | |||
| status = db.Column(db.Text) | |||
| # practices | |||
| longDescription = db.Column(db.Text) | |||
| experimental = db.Column(db.Text) | |||
| lessonsLearned = db.Column(db.Text) | |||
| considerations = db.Column(db.Text) | |||
| references = db.Column(db.Text) | |||
| # books | |||
| author = db.Column(db.Text) | |||
| year = db.Column(db.Text) | |||
| bookUrl = db.Column(db.Text) | |||
| isbn = db.Column(db.Text) | |||
| typology = db.Column(db.Text) | |||
| # table for relationships | |||
| class Relationship(db.Model): | |||
| @@ -45,8 +45,9 @@ def edit_practice(practice_id): | |||
| practice = Resource.query.get(practice_id) | |||
| practice.name = request.form['name'] | |||
| practice.description = request.form['description'] | |||
| practice.longDescription = request.form['longDescription'] | |||
| practice.experimental = request.form['experimental'] | |||
| practice.lessonsLearned = request.form['lessonsLearned'] | |||
| practice.considerations = request.form['considerations'] | |||
| practice.references = request.form['references'] | |||
| db.session.commit() | |||
| linked_resources = request.form.getlist('linked_resources') | |||
| @@ -123,14 +123,19 @@ | |||
| {% elif resource['type'] == 'practice' %} | |||
| <div class="mb-3 mt-3"> | |||
| <label for="experimental">How is this / Can this be an experimental practice?</label> | |||
| <textarea name="experimental" placeholder="How is this / Can this be an experimental practice?" | |||
| <label for="longDescription">Full description</label> | |||
| <textarea name="longDescription" placeholder="Full description" | |||
| class="form-control">{{ request.form['longDescription'] or resource['longDescription'] }}</textarea> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="experimental">Experimental use</label> | |||
| <textarea name="experimental" placeholder="Experimental use" | |||
| class="form-control">{{ request.form['experimental'] or resource['experimental'] }}</textarea> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="lessonsLearned">How has it been applied experimentally (lessons learned for authors and publishers)?</label> | |||
| <textarea name="lessonsLearned" placeholder="How has it been applied experimentally (lessons learned for authors and publishers)?" | |||
| class="form-control">{{ request.form['lessonsLearned'] or resource['lessonsLearned'] }}</textarea> | |||
| <label for="considerations">Considerations</label> | |||
| <textarea name="considerations" placeholder="Considerations" | |||
| class="form-control">{{ request.form['considerations'] or resource['considerations'] }}</textarea> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="references">References</label> | |||
| @@ -169,6 +174,13 @@ | |||
| value="{{ request.form['year'] or resource['year'] }}"> | |||
| </input> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="typology">Typology category</label> | |||
| <input type="text" name="typology" placeholder="Typology category" | |||
| class="form-control" | |||
| value="{{ request.form['typology'] or resource['typology'] }}"> | |||
| </input> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="bookUrl">URL</label> | |||
| <input type="text" name="bookUrl" placeholder="URL" | |||
| @@ -160,23 +160,33 @@ | |||
| </tr> | |||
| {% endif %} | |||
| <!-- fields for practices --> | |||
| {% if resource['longDescription'] %} | |||
| <tr> | |||
| <th> | |||
| Full description | |||
| </th> | |||
| <td> | |||
| {{ resource['longDescription']|safe }} | |||
| </td> | |||
| </tr> | |||
| {% endif %} | |||
| {% if resource['experimental'] %} | |||
| <tr> | |||
| <th> | |||
| How is this / Can this be an experimental practice? | |||
| Experimental uses | |||
| </th> | |||
| <td> | |||
| {{ resource['experimental']|safe }} | |||
| </td> | |||
| </tr> | |||
| {% endif %} | |||
| {% if resource['lessonsLearned'] %} | |||
| {% if resource['considerations'] %} | |||
| <tr> | |||
| <th> | |||
| How has it been applied experimentally (lessons learned for authors and publishers)? | |||
| Considerations | |||
| </th> | |||
| <td> | |||
| <p style="white-space: pre-line">{{ resource['lessonsLearned']|safe }}</p> | |||
| <p style="white-space: pre-line">{{ resource['considerations']|safe }}</p> | |||
| </td> | |||
| </tr> | |||
| {% endif %} | |||
| @@ -1,6 +1,7 @@ | |||
| {% extends 'base.html' %} | |||
| {% block content %} | |||
| <div class="row"> | |||
| <div class="col-12 text-center"> | |||
| <h1>{% block title %} | |||
| @@ -12,6 +12,7 @@ from .models import Resource | |||
| from .resources import * | |||
| from .relationships import * | |||
| from . import db | |||
| from sqlalchemy import text | |||
| import os | |||
| tool = Blueprint('tool', __name__) | |||
| @@ -24,7 +25,8 @@ def get_tools(): | |||
| for key in request.args.keys(): | |||
| if key == 'practice': | |||
| query = 'SELECT Resource.* FROM Resource LEFT JOIN Relationship ON Resource.id=Relationship.first_resource_id WHERE Relationship.second_resource_id=' + request.args.get(key) + ' AND Resource.type="' + type + '";' | |||
| tools = db.engine.execute(query) | |||
| with db.engine.connect() as conn: | |||
| tools = conn.execute(text(query)) | |||
| elif key == 'scriptingLanguage': | |||
| regex = request.args.get(key) + "$|" + request.args.get(key) + "\s\/" | |||
| tools = Resource.query.filter_by(type=type).filter(Resource.scriptingLanguage.regexp_match(regex)) | |||