from .resources import * | from .resources import * | ||||
from .relationships import * | from .relationships import * | ||||
from . import db | from . import db | ||||
from sqlalchemy import text | |||||
import os | import os | ||||
book = Blueprint('book', __name__) | book = Blueprint('book', __name__) | ||||
for key in request.args.keys(): | for key in request.args.keys(): | ||||
if key == 'practice': | 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 + '";' | 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: | else: | ||||
kwargs = {'type': type, key: request.args.get(key)} | kwargs = {'type': type, key: request.args.get(key)} | ||||
books = Resource.query.filter_by(**kwargs) | books = Resource.query.filter_by(**kwargs) | ||||
book.year = request.form['year'] | book.year = request.form['year'] | ||||
book.bookUrl = request.form['bookUrl'] | book.bookUrl = request.form['bookUrl'] | ||||
book.isbn = request.form['isbn'] | book.isbn = request.form['isbn'] | ||||
book.typology = request.form['typology'] | |||||
db.session.commit() | db.session.commit() | ||||
linked_resources = request.form.getlist('linked_resources') | linked_resources = request.form.getlist('linked_resources') | ||||
remove_linked_resources = request.form.getlist('remove_linked_resources') | remove_linked_resources = request.form.getlist('remove_linked_resources') |
outputFormats = db.Column(db.Text) | outputFormats = db.Column(db.Text) | ||||
status = db.Column(db.Text) | status = db.Column(db.Text) | ||||
# practices | # practices | ||||
longDescription = db.Column(db.Text) | |||||
experimental = db.Column(db.Text) | experimental = db.Column(db.Text) | ||||
lessonsLearned = db.Column(db.Text) | |||||
considerations = db.Column(db.Text) | |||||
references = db.Column(db.Text) | references = db.Column(db.Text) | ||||
# books | # books | ||||
author = db.Column(db.Text) | author = db.Column(db.Text) | ||||
year = db.Column(db.Text) | year = db.Column(db.Text) | ||||
bookUrl = db.Column(db.Text) | bookUrl = db.Column(db.Text) | ||||
isbn = db.Column(db.Text) | isbn = db.Column(db.Text) | ||||
typology = db.Column(db.Text) | |||||
# table for relationships | # table for relationships | ||||
class Relationship(db.Model): | class Relationship(db.Model): |
practice = Resource.query.get(practice_id) | practice = Resource.query.get(practice_id) | ||||
practice.name = request.form['name'] | practice.name = request.form['name'] | ||||
practice.description = request.form['description'] | practice.description = request.form['description'] | ||||
practice.longDescription = request.form['longDescription'] | |||||
practice.experimental = request.form['experimental'] | practice.experimental = request.form['experimental'] | ||||
practice.lessonsLearned = request.form['lessonsLearned'] | |||||
practice.considerations = request.form['considerations'] | |||||
practice.references = request.form['references'] | practice.references = request.form['references'] | ||||
db.session.commit() | db.session.commit() | ||||
linked_resources = request.form.getlist('linked_resources') | linked_resources = request.form.getlist('linked_resources') |
{% elif resource['type'] == 'practice' %} | {% elif resource['type'] == 'practice' %} | ||||
<div class="mb-3 mt-3"> | <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> | class="form-control">{{ request.form['experimental'] or resource['experimental'] }}</textarea> | ||||
</div> | </div> | ||||
<div class="mb-3 mt-3"> | <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> | ||||
<div class="mb-3 mt-3"> | <div class="mb-3 mt-3"> | ||||
<label for="references">References</label> | <label for="references">References</label> | ||||
value="{{ request.form['year'] or resource['year'] }}"> | value="{{ request.form['year'] or resource['year'] }}"> | ||||
</input> | </input> | ||||
</div> | </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"> | <div class="mb-3 mt-3"> | ||||
<label for="bookUrl">URL</label> | <label for="bookUrl">URL</label> | ||||
<input type="text" name="bookUrl" placeholder="URL" | <input type="text" name="bookUrl" placeholder="URL" |
</tr> | </tr> | ||||
{% endif %} | {% endif %} | ||||
<!-- fields for practices --> | <!-- fields for practices --> | ||||
{% if resource['longDescription'] %} | |||||
<tr> | |||||
<th> | |||||
Full description | |||||
</th> | |||||
<td> | |||||
{{ resource['longDescription']|safe }} | |||||
</td> | |||||
</tr> | |||||
{% endif %} | |||||
{% if resource['experimental'] %} | {% if resource['experimental'] %} | ||||
<tr> | <tr> | ||||
<th> | <th> | ||||
How is this / Can this be an experimental practice? | |||||
Experimental uses | |||||
</th> | </th> | ||||
<td> | <td> | ||||
{{ resource['experimental']|safe }} | {{ resource['experimental']|safe }} | ||||
</td> | </td> | ||||
</tr> | </tr> | ||||
{% endif %} | {% endif %} | ||||
{% if resource['lessonsLearned'] %} | |||||
{% if resource['considerations'] %} | |||||
<tr> | <tr> | ||||
<th> | <th> | ||||
How has it been applied experimentally (lessons learned for authors and publishers)? | |||||
Considerations | |||||
</th> | </th> | ||||
<td> | <td> | ||||
<p style="white-space: pre-line">{{ resource['lessonsLearned']|safe }}</p> | |||||
<p style="white-space: pre-line">{{ resource['considerations']|safe }}</p> | |||||
</td> | </td> | ||||
</tr> | </tr> | ||||
{% endif %} | {% endif %} |
{% extends 'base.html' %} | {% extends 'base.html' %} | ||||
{% block content %} | {% block content %} | ||||
<div class="row"> | <div class="row"> | ||||
<div class="col-12 text-center"> | <div class="col-12 text-center"> | ||||
<h1>{% block title %} | <h1>{% block title %} |
from .resources import * | from .resources import * | ||||
from .relationships import * | from .relationships import * | ||||
from . import db | from . import db | ||||
from sqlalchemy import text | |||||
import os | import os | ||||
tool = Blueprint('tool', __name__) | tool = Blueprint('tool', __name__) | ||||
for key in request.args.keys(): | for key in request.args.keys(): | ||||
if key == 'practice': | 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 + '";' | 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': | elif key == 'scriptingLanguage': | ||||
regex = request.args.get(key) + "$|" + request.args.get(key) + "\s\/" | regex = request.args.get(key) + "$|" + request.args.get(key) + "\s\/" | ||||
tools = Resource.query.filter_by(type=type).filter(Resource.scriptingLanguage.regexp_match(regex)) | tools = Resource.query.filter_by(type=type).filter(Resource.scriptingLanguage.regexp_match(regex)) |