| # @name: __init__.py | # @name: __init__.py | ||||
| # @version: 0.1 | |||||
| # @creation_date: 2021-10-20 | # @creation_date: 2021-10-20 | ||||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | # @license: The MIT License <https://opensource.org/licenses/MIT> | ||||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | # @author: Simon Bowie <ad7588@coventry.ac.uk> |
| # @name: auth.py | # @name: auth.py | ||||
| # @version: 0.1 | |||||
| # @creation_date: 2021-10-20 | # @creation_date: 2021-10-20 | ||||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | # @license: The MIT License <https://opensource.org/licenses/MIT> | ||||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | # @author: Simon Bowie <ad7588@coventry.ac.uk> |
| # @name: book.py | # @name: book.py | ||||
| # @version: 0.1 | |||||
| # @creation_date: 2021-11-03 | # @creation_date: 2021-11-03 | ||||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | # @license: The MIT License <https://opensource.org/licenses/MIT> | ||||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | # @author: Simon Bowie <ad7588@coventry.ac.uk> |
| # @name: create.py | # @name: create.py | ||||
| # @version: 0.1 | |||||
| # @creation_date: 2021-10-25 | # @creation_date: 2021-10-25 | ||||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | # @license: The MIT License <https://opensource.org/licenses/MIT> | ||||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | # @author: Simon Bowie <ad7588@coventry.ac.uk> |
| # @name: main.py | # @name: main.py | ||||
| # @version: 0.1 | |||||
| # @creation_date: 2021-10-20 | # @creation_date: 2021-10-20 | ||||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | # @license: The MIT License <https://opensource.org/licenses/MIT> | ||||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | # @author: Simon Bowie <ad7588@coventry.ac.uk> |
| # @name: models.py | # @name: models.py | ||||
| # @version: 0.1 | |||||
| # @creation_date: 2021-10-20 | # @creation_date: 2021-10-20 | ||||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | # @license: The MIT License <https://opensource.org/licenses/MIT> | ||||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | # @author: Simon Bowie <ad7588@coventry.ac.uk> |
| # @name: practice.py | # @name: practice.py | ||||
| # @version: 0.1 | |||||
| # @creation_date: 2021-11-03 | # @creation_date: 2021-11-03 | ||||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | # @license: The MIT License <https://opensource.org/licenses/MIT> | ||||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | # @author: Simon Bowie <ad7588@coventry.ac.uk> | ||||
| from flask import Blueprint, render_template, request, flash, redirect, url_for | from flask import Blueprint, render_template, request, flash, redirect, url_for | ||||
| from flask_login import login_required, current_user | from flask_login import login_required, current_user | ||||
| from .models import Resource | from .models import Resource | ||||
| from .resources import * | |||||
| from werkzeug.exceptions import abort | from werkzeug.exceptions import abort | ||||
| from . import db | from . import db | ||||
| practice = Blueprint('practice', __name__) | practice = Blueprint('practice', __name__) | ||||
| # function to retrieve data about a single practice from the database | |||||
| def get_practice(practice_id): | |||||
| practice = Resource.query.filter_by(id=practice_id).first() | |||||
| if practice is None: | |||||
| abort(404) | |||||
| return practice | |||||
| # route for displaying all practices in database | # route for displaying all practices in database | ||||
| @practice.route('/practices') | @practice.route('/practices') | ||||
| def get_practices(): | def get_practices(): | ||||
| # route for displaying a single practice based on the ID in the database | # route for displaying a single practice based on the ID in the database | ||||
| @practice.route('/practices/<int:practice_id>') | @practice.route('/practices/<int:practice_id>') | ||||
| def show_practice(practice_id): | def show_practice(practice_id): | ||||
| practice = get_practice(practice_id) | |||||
| return render_template('practice.html', practice=practice) | |||||
| practice = get_resource(practice_id) | |||||
| resources = get_linked_resources(practice_id) | |||||
| return render_template('practice.html', practice=practice, resources=resources) | |||||
| # route for editing a single practice based on the ID in the database | # route for editing a single practice based on the ID in the database | ||||
| @practice.route('/practices/<int:practice_id>/edit', methods=('GET', 'POST')) | @practice.route('/practices/<int:practice_id>/edit', methods=('GET', 'POST')) | ||||
| @login_required | @login_required | ||||
| def edit_practice(practice_id): | def edit_practice(practice_id): | ||||
| practice = get_practice(practice_id) | |||||
| practice = get_resource(practice_id) | |||||
| if request.method == 'POST': | if request.method == 'POST': | ||||
| name = request.form['name'] | name = request.form['name'] | ||||
| @practice.route('/practices/<int:practice_id>/delete', methods=('POST',)) | @practice.route('/practices/<int:practice_id>/delete', methods=('POST',)) | ||||
| @login_required | @login_required | ||||
| def delete_practice(practice_id): | def delete_practice(practice_id): | ||||
| practice = get_practice(practice_id) | |||||
| deletion = Resource.query.get(practice_id) | |||||
| db.session.delete(deletion) | |||||
| db.session.commit() | |||||
| flash('Successfully deleted!') | |||||
| delete_resource(practice_id) | |||||
| return redirect(url_for('practice.get_practices')) | return redirect(url_for('practice.get_practices')) |
| # @name: publisher.py | # @name: publisher.py | ||||
| # @version: 0.1 | |||||
| # @creation_date: 2022-02-08 | # @creation_date: 2022-02-08 | ||||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | # @license: The MIT License <https://opensource.org/licenses/MIT> | ||||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | # @author: Simon Bowie <ad7588@coventry.ac.uk> |
| # @name: reference.py | # @name: reference.py | ||||
| # @version: 0.1 | |||||
| # @creation_date: 2022-02-08 | # @creation_date: 2022-02-08 | ||||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | # @license: The MIT License <https://opensource.org/licenses/MIT> | ||||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | # @author: Simon Bowie <ad7588@coventry.ac.uk> |
| # @name: resources.py | # @name: resources.py | ||||
| # @version: 0.1 | |||||
| # @creation_date: 2022-02-23 | # @creation_date: 2022-02-23 | ||||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | # @license: The MIT License <https://opensource.org/licenses/MIT> | ||||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | # @author: Simon Bowie <ad7588@coventry.ac.uk> |
| # @name: sensitivity.py | # @name: sensitivity.py | ||||
| # @version: 0.1 | |||||
| # @creation_date: 2022-02-08 | # @creation_date: 2022-02-08 | ||||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | # @license: The MIT License <https://opensource.org/licenses/MIT> | ||||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | # @author: Simon Bowie <ad7588@coventry.ac.uk> |
| <textarea name="description" placeholder="Description" | <textarea name="description" placeholder="Description" | ||||
| class="form-control">{{ request.form['description'] or resource['description'] }}</textarea> | class="form-control">{{ request.form['description'] or resource['description'] }}</textarea> | ||||
| </div> | </div> | ||||
| {% if resource['type'] == 'tool' %} | |||||
| <div class="mb-3 mt-3"> | |||||
| <label for="projectUrl">Project URL</label> | |||||
| <input type="text" name="projectUrl" placeholder="Project URL" | |||||
| class="form-control" | |||||
| value="{{ request.form['projectUrl'] or resource['projectUrl'] }}"> | |||||
| </input> | |||||
| </div> | |||||
| <div class="mb-3 mt-3"> | |||||
| <label for="repositoryUrl">Repository URL</label> | |||||
| <input type="text" name="repositoryUrl" placeholder="Repository URL" | |||||
| class="form-control" | |||||
| value="{{ request.form['repositoryUrl'] or resource['repositoryUrl'] }}"> | |||||
| </input> | |||||
| </div> | |||||
| <div class="mb-3 mt-3"> | |||||
| <label for="expertiseToUse">Expertise required to use</label> | |||||
| <input type="text" name="expertiseToUse" placeholder="Expertise required to use" | |||||
| class="form-control" | |||||
| value="{{ request.form['expertiseToUse'] or resource['expertiseToUse'] }}"> | |||||
| </input> | |||||
| </div> | |||||
| <div class="mb-3 mt-3"> | |||||
| <label for="expertiseToHost">Expertise required to host</label> | |||||
| <input type="text" name="expertiseToHost" placeholder="Expertise required to host" | |||||
| class="form-control" | |||||
| value="{{ request.form['expertiseToHost'] or resource['expertiseToHost'] }}"> | |||||
| </input> | |||||
| </div> | |||||
| <div class="mb-3 mt-3"> | |||||
| <label for="dependencies">Technical dependencies</label> | |||||
| <input type="text" name="dependencies" placeholder="Technical dependencies" | |||||
| class="form-control" | |||||
| value="{{ request.form['dependencies'] or resource['dependencies'] }}"> | |||||
| </input> | |||||
| </div> | |||||
| <div class="mb-3 mt-3"> | |||||
| <label for="ingestFormats">Import / ingest formats</label> | |||||
| <input type="text" name="ingestFormats" placeholder="Import / ingest formats" | |||||
| class="form-control" | |||||
| value="{{ request.form['ingestFormats'] or resource['ingestFormats'] }}"> | |||||
| </input> | |||||
| </div> | |||||
| <div class="mb-3 mt-3"> | |||||
| <label for="outputFormats">Output formats</label> | |||||
| <input type="text" name="outputFormats" placeholder="Output formats" | |||||
| class="form-control" | |||||
| value="{{ request.form['outputFormats'] or resource['outputFormats'] }}"> | |||||
| </input> | |||||
| </div> | |||||
| <div class="mb-3 mt-3"> | |||||
| <label for="status">Platform status</label> | |||||
| <input type="text" name="status" placeholder="Platform status" | |||||
| class="form-control" | |||||
| value="{{ request.form['status'] or resource['status'] }}"> | |||||
| </input> | |||||
| </div> | |||||
| {% endif %} | |||||
| <div class="mb-3 mt-3"> | <div class="mb-3 mt-3"> | ||||
| <button type="submit" class="btn btn-primary">Submit</button> | <button type="submit" class="btn btn-primary">Submit</button> | ||||
| </div> | </div> |
| {% extends 'base.html' %} | |||||
| {% block content %} | |||||
| <div class="row"> | |||||
| <div class="col"> | |||||
| <h1 class="text-center">{% block title %} {{ practice['name'] }} {% endblock %}</h1> | |||||
| </div> | |||||
| </div> | |||||
| {% if current_user.is_authenticated %} | |||||
| <div class="row text-center py-3"> | |||||
| <a href="{{ url_for('practice.edit_practice', practice_id=practice['id']) }}"> | |||||
| <span class="badge bg-dark">Edit</span> | |||||
| </a> | |||||
| </div> | |||||
| {% endif %} | |||||
| <div class="row"> | |||||
| <div class="col"> | |||||
| <table class="table table-hover"> | |||||
| <tbody> | |||||
| <tr> | |||||
| <th> | |||||
| Created: | |||||
| </th> | |||||
| <td> | |||||
| {{ practice['created'].strftime("%Y-%m-%d %H:%M") }} UTC | |||||
| </td> | |||||
| </tr> | |||||
| <tr> | |||||
| <th> | |||||
| Description: | |||||
| </th> | |||||
| <td> | |||||
| {{ practice['description'] }} | |||||
| </td> | |||||
| </tr> | |||||
| </tbody> | |||||
| </table> | |||||
| </div> | |||||
| </div> | |||||
| {% if resources %} | |||||
| <div class="row"> | |||||
| <div class="col"> | |||||
| <h2 class="text-center">Linked resources:</h2> | |||||
| </div> | |||||
| </div> | |||||
| <div class="row"> | |||||
| {% for resource in resources %} | |||||
| <div class="col-md-4 col-sm-6 py-3"> | |||||
| {% if resource['type'] == 'tool' %} | |||||
| <div class="card text-dark bg-info mb-3"> | |||||
| <div class="card-body"> | |||||
| <a href="{{ url_for('tool.show_tool', tool_id=resource['id']) }}"> | |||||
| <h3 class="card-title text-center text-dark">{{ resource['name'] }}</h3> | |||||
| </a> | |||||
| <p class="card-text"> | |||||
| {{ resource['description']|truncate(100) }} | |||||
| </p> | |||||
| </div> | |||||
| </div> | |||||
| {% endif %} | |||||
| </div> | |||||
| {% endfor %} | |||||
| </div> | |||||
| {% endif %} | |||||
| {% endblock %} |
| # @name: tool.py | # @name: tool.py | ||||
| # @version: 0.1 | |||||
| # @creation_date: 2021-10-20 | # @creation_date: 2021-10-20 | ||||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | # @license: The MIT License <https://opensource.org/licenses/MIT> | ||||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | # @author: Simon Bowie <ad7588@coventry.ac.uk> | ||||
| if request.method == 'POST': | if request.method == 'POST': | ||||
| name = request.form['name'] | name = request.form['name'] | ||||
| description = request.form['description'] | description = request.form['description'] | ||||
| projectUrl = request.form.get('projectUrl') | |||||
| repositoryUrl = request.form.get('repositoryUrl') | |||||
| expertiseToUse = request.form.get('expertiseToUse') | |||||
| expertiseToHost = request.form.get('expertiseToHost') | |||||
| dependencies = request.form.get('dependencies') | |||||
| ingestFormats = request.form.get('ingestFormats') | |||||
| outputFormats = request.form.get('outputFormats') | |||||
| status = request.form.get('status') | |||||
| if not name: | if not name: | ||||
| flash('Name is required!') | flash('Name is required!') | ||||
| tool = Resource.query.get(tool_id) | tool = Resource.query.get(tool_id) | ||||
| tool.name = name | tool.name = name | ||||
| tool.description = description | tool.description = description | ||||
| # tool.projectUrl = project_url | |||||
| # tool.repositoryUrl = repository_url | |||||
| # tool.dependencies = dependencies | |||||
| # tool.expertiseToUse = expertise | |||||
| # tool.expertiseToHost = self_host_expertise | |||||
| # tool.ingestFormats = ingest | |||||
| # tool.outputFormats = output | |||||
| # tool.status = status | |||||
| tool.projectUrl = projectUrl | |||||
| tool.repositoryUrl = repositoryUrl | |||||
| tool.dependencies = dependencies | |||||
| tool.expertiseToUse = expertiseToUse | |||||
| tool.expertiseToHost = expertiseToHost | |||||
| tool.ingestFormats = ingestFormats | |||||
| tool.outputFormats = outputFormats | |||||
| tool.status = status | |||||
| db.session.commit() | db.session.commit() | ||||
| return redirect(url_for('tool.get_tools')) | return redirect(url_for('tool.get_tools')) | ||||
| # @name: typology.py | # @name: typology.py | ||||
| # @version: 0.1 | |||||
| # @creation_date: 2022-02-08 | # @creation_date: 2022-02-08 | ||||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | # @license: The MIT License <https://opensource.org/licenses/MIT> | ||||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | # @author: Simon Bowie <ad7588@coventry.ac.uk> |
| # @name: workflow.py | # @name: workflow.py | ||||
| # @version: 0.1 | |||||
| # @creation_date: 2022-02-08 | # @creation_date: 2022-02-08 | ||||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | # @license: The MIT License <https://opensource.org/licenses/MIT> | ||||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | # @author: Simon Bowie <ad7588@coventry.ac.uk> |