| @@ -1,5 +1,4 @@ | |||
| # @name: __init__.py | |||
| # @version: 0.1 | |||
| # @creation_date: 2021-10-20 | |||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | |||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | |||
| @@ -1,5 +1,4 @@ | |||
| # @name: auth.py | |||
| # @version: 0.1 | |||
| # @creation_date: 2021-10-20 | |||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | |||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | |||
| @@ -1,5 +1,4 @@ | |||
| # @name: book.py | |||
| # @version: 0.1 | |||
| # @creation_date: 2021-11-03 | |||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | |||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | |||
| @@ -1,5 +1,4 @@ | |||
| # @name: create.py | |||
| # @version: 0.1 | |||
| # @creation_date: 2021-10-25 | |||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | |||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | |||
| @@ -1,5 +1,4 @@ | |||
| # @name: main.py | |||
| # @version: 0.1 | |||
| # @creation_date: 2021-10-20 | |||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | |||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | |||
| @@ -1,5 +1,4 @@ | |||
| # @name: models.py | |||
| # @version: 0.1 | |||
| # @creation_date: 2021-10-20 | |||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | |||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | |||
| @@ -1,5 +1,4 @@ | |||
| # @name: practice.py | |||
| # @version: 0.1 | |||
| # @creation_date: 2021-11-03 | |||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | |||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | |||
| @@ -10,18 +9,12 @@ | |||
| from flask import Blueprint, render_template, request, flash, redirect, url_for | |||
| from flask_login import login_required, current_user | |||
| from .models import Resource | |||
| from .resources import * | |||
| from werkzeug.exceptions import abort | |||
| from . import db | |||
| 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 | |||
| @practice.route('/practices') | |||
| def get_practices(): | |||
| @@ -31,14 +24,15 @@ def get_practices(): | |||
| # route for displaying a single practice based on the ID in the database | |||
| @practice.route('/practices/<int: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 | |||
| @practice.route('/practices/<int:practice_id>/edit', methods=('GET', 'POST')) | |||
| @login_required | |||
| def edit_practice(practice_id): | |||
| practice = get_practice(practice_id) | |||
| practice = get_resource(practice_id) | |||
| if request.method == 'POST': | |||
| name = request.form['name'] | |||
| @@ -59,9 +53,5 @@ def edit_practice(practice_id): | |||
| @practice.route('/practices/<int:practice_id>/delete', methods=('POST',)) | |||
| @login_required | |||
| 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')) | |||
| @@ -1,5 +1,4 @@ | |||
| # @name: publisher.py | |||
| # @version: 0.1 | |||
| # @creation_date: 2022-02-08 | |||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | |||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | |||
| @@ -1,5 +1,4 @@ | |||
| # @name: reference.py | |||
| # @version: 0.1 | |||
| # @creation_date: 2022-02-08 | |||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | |||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | |||
| @@ -1,5 +1,4 @@ | |||
| # @name: resources.py | |||
| # @version: 0.1 | |||
| # @creation_date: 2022-02-23 | |||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | |||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | |||
| @@ -1,5 +1,4 @@ | |||
| # @name: sensitivity.py | |||
| # @version: 0.1 | |||
| # @creation_date: 2022-02-08 | |||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | |||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | |||
| @@ -17,6 +17,66 @@ | |||
| <textarea name="description" placeholder="Description" | |||
| class="form-control">{{ request.form['description'] or resource['description'] }}</textarea> | |||
| </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"> | |||
| <button type="submit" class="btn btn-primary">Submit</button> | |||
| </div> | |||
| @@ -0,0 +1,65 @@ | |||
| {% 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 %} | |||
| @@ -1,5 +1,4 @@ | |||
| # @name: tool.py | |||
| # @version: 0.1 | |||
| # @creation_date: 2021-10-20 | |||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | |||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | |||
| @@ -38,6 +37,14 @@ def edit_tool(tool_id): | |||
| if request.method == 'POST': | |||
| name = request.form['name'] | |||
| 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: | |||
| flash('Name is required!') | |||
| @@ -45,14 +52,14 @@ def edit_tool(tool_id): | |||
| tool = Resource.query.get(tool_id) | |||
| tool.name = name | |||
| 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() | |||
| return redirect(url_for('tool.get_tools')) | |||
| @@ -1,5 +1,4 @@ | |||
| # @name: typology.py | |||
| # @version: 0.1 | |||
| # @creation_date: 2022-02-08 | |||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | |||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | |||
| @@ -1,5 +1,4 @@ | |||
| # @name: workflow.py | |||
| # @version: 0.1 | |||
| # @creation_date: 2022-02-08 | |||
| # @license: The MIT License <https://opensource.org/licenses/MIT> | |||
| # @author: Simon Bowie <ad7588@coventry.ac.uk> | |||