@@ -23,11 +23,13 @@ class User(UserMixin, db.Model): | |||
class Resource(db.Model): | |||
__tablename__ = 'Resource' | |||
# 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) | |||
type = db.Column(db.Text) | |||
name = db.Column(db.Text) | |||
description = db.Column(db.Text) | |||
# tools | |||
developer = db.Column(db.Text) | |||
developerUrl = db.Column(db.Text) | |||
projectUrl = db.Column(db.Text) | |||
@@ -40,8 +42,12 @@ class Resource(db.Model): | |||
ingestFormats = db.Column(db.Text) | |||
outputFormats = db.Column(db.Text) | |||
status = db.Column(db.Text) | |||
publisherUrl = db.Column(db.Text) | |||
zoteroUrl = db.Column(db.Text) | |||
# practices | |||
experimental = db.Column(db.Text) | |||
lessonsLearned = db.Column(db.Text) | |||
references = db.Column(db.Text) | |||
# books | |||
isbn = db.Column(db.Text) | |||
# table for relationships | |||
class Relationship(db.Model): |
@@ -45,6 +45,9 @@ def edit_practice(practice_id): | |||
practice = Resource.query.get(practice_id) | |||
practice.name = request.form['name'] | |||
practice.description = request.form['description'] | |||
practice.experimental = request.form['experimental'] | |||
practice.lessonsLearned = request.form['lessonsLearned'] | |||
practice.references = request.form['references'] | |||
db.session.commit() | |||
linked_resources = request.form.getlist('linked_resources') | |||
remove_linked_resources = request.form.getlist('remove_linked_resources') |
@@ -122,6 +122,21 @@ | |||
</div> | |||
{% 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?" | |||
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> | |||
</div> | |||
<div class="mb-3 mt-3"> | |||
<label for="references">References</label> | |||
<textarea name="references" placeholder="References" | |||
class="form-control">{{ request.form['references'] or resource['references'] }}</textarea> | |||
</div> | |||
<div class="mb-3 mt-3"> | |||
<label for="linked_practice_id">Linked resources</label> | |||
</div> |
@@ -50,6 +50,7 @@ | |||
</td> | |||
</tr> | |||
{% endif %} | |||
<!-- fields for tools --> | |||
{% if resource['developer'] %} | |||
<tr> | |||
<th> | |||
@@ -164,6 +165,37 @@ | |||
</td> | |||
</tr> | |||
{% endif %} | |||
<!-- fields for practices --> | |||
{% if resource['experimental'] %} | |||
<tr> | |||
<th> | |||
How is this / Can this be an experimental practice? | |||
</th> | |||
<td> | |||
{{ resource['experimental'] }} | |||
</td> | |||
</tr> | |||
{% endif %} | |||
{% if resource['lessonsLearned'] %} | |||
<tr> | |||
<th> | |||
How has it been applied experimentally (lessons learned for authors and publishers)? | |||
</th> | |||
<td> | |||
<p style="white-space: pre-line">{{ resource['lessonsLearned'] }}</p> | |||
</td> | |||
</tr> | |||
{% endif %} | |||
{% if resource['references'] %} | |||
<tr> | |||
<th> | |||
References: | |||
</th> | |||
<td> | |||
<p style="white-space: pre-line">{{ resource['references'] }}</p> | |||
</td> | |||
</tr> | |||
{% endif %} | |||
</tbody> | |||
</table> | |||
</div> |
@@ -27,7 +27,7 @@ def get_tools(): | |||
tools = db.engine.execute(query) | |||
elif key == 'scriptingLanguage': | |||
regex = request.args.get(key) + "$|" + request.args.get(key) + "\s\/" | |||
tools = Resource.query.filter(Resource.scriptingLanguage.regexp_match(regex)) | |||
tools = Resource.query.filter_by(type='tool').filter(Resource.scriptingLanguage.regexp_match(regex)) | |||
else: | |||
kwargs = {'type': 'tool', key: request.args.get(key)} | |||
tools = Resource.query.filter_by(**kwargs) |