.env.prod | .env.prod | ||||
.env.dev | .env.dev | ||||
.DS_Store | .DS_Store | ||||
instance | |||||
database_functions_live.sh | database_functions_live.sh | ||||
old_database_schema | old_database_schema | ||||
db_exports | db_exports | ||||
db_imports |
container_name: python | container_name: python | ||||
expose: | expose: | ||||
- 5000 | - 5000 | ||||
volumes: | |||||
- ./web:/code | |||||
env_file: | env_file: | ||||
- ./.env.prod | - ./.env.prod | ||||
depends_on: | depends_on: |
- ./web:/code | - ./web:/code | ||||
env_file: | env_file: | ||||
- ./.env.dev | - ./.env.dev | ||||
db: | |||||
image: mariadb:latest | |||||
container_name: mariadb | |||||
restart: unless-stopped | |||||
env_file: | |||||
- ./.env.dev | |||||
volumes: | |||||
- dbdata:/var/lib/mysql | |||||
command: '--default-authentication-plugin=mysql_native_password' | |||||
volumes: | |||||
dbdata: |
type = 'tool' | type = 'tool' | ||||
name = request.form.get('tool_name') | name = request.form.get('tool_name') | ||||
description = request.form.get('description') | description = request.form.get('description') | ||||
developer = request.form.get('developer') | |||||
developerUrl = request.form.get('developerUrl') | |||||
projectUrl = request.form.get('projectUrl') | projectUrl = request.form.get('projectUrl') | ||||
repositoryUrl = request.form.get('repositoryUrl') | repositoryUrl = request.form.get('repositoryUrl') | ||||
license = request.form.get('license') | |||||
scriptingLanguage = request.form.get('scriptingLanguage') | |||||
expertiseToUse = request.form.get('expertiseToUse') | expertiseToUse = request.form.get('expertiseToUse') | ||||
expertiseToHost = request.form.get('expertiseToHost') | expertiseToHost = request.form.get('expertiseToHost') | ||||
dependencies = request.form.get('dependencies') | dependencies = request.form.get('dependencies') | ||||
return redirect(url_for('create.create_resource',_external=True,_scheme=os.environ.get('SSL_SCHEME'))) | return redirect(url_for('create.create_resource',_external=True,_scheme=os.environ.get('SSL_SCHEME'))) | ||||
# create a new tool with the form data | # create a new tool with the form data | ||||
new_tool = Resource(type=type, name=name, description=description, projectUrl=projectUrl, repositoryUrl=repositoryUrl, expertiseToUse=expertiseToUse, expertiseToHost=expertiseToHost, dependencies=dependencies, ingestFormats=ingestFormats, outputFormats=outputFormats, status=status) | |||||
new_tool = Resource(type=type, name=name, description=description, developer=developer, developerUrl=developerUrl, projectUrl=projectUrl, repositoryUrl=repositoryUrl, license=license, scriptingLanguage=scriptingLanguage, expertiseToUse=expertiseToUse, expertiseToHost=expertiseToHost, dependencies=dependencies, ingestFormats=ingestFormats, outputFormats=outputFormats, status=status) | |||||
# add the new tool to the database | # add the new tool to the database | ||||
db.session.add(new_tool) | db.session.add(new_tool) |
# @acknowledgements: | # @acknowledgements: | ||||
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 .models import Resource | from .models import Resource | ||||
from werkzeug.exceptions import abort | from werkzeug.exceptions import abort | ||||
from . import db | from . import db |
--bs-success-rgb: 25,135,84; | --bs-success-rgb: 25,135,84; | ||||
--bs-tool-rgb: 13,202,240; | --bs-tool-rgb: 13,202,240; | ||||
--bs-practice-rgb: 255,193,7; | --bs-practice-rgb: 255,193,7; | ||||
--bs-publisher-rgb: 150, 224, 167; | |||||
--bs-danger-rgb: 220,53,69; | --bs-danger-rgb: 220,53,69; | ||||
--bs-light-rgb: 248,249,250; | --bs-light-rgb: 248,249,250; | ||||
--bs-dark-rgb: 33,37,41; | --bs-dark-rgb: 33,37,41; | ||||
background-color: rgba(var(--bs-practice-rgb),var(--bs-bg-opacity))!important; | background-color: rgba(var(--bs-practice-rgb),var(--bs-bg-opacity))!important; | ||||
} | } | ||||
.bg-publisher { | |||||
--bs-bg-opacity: 1; | |||||
background-color: rgba(var(--bs-publisher-rgb),var(--bs-bg-opacity))!important; | |||||
} | |||||
.drop { | .drop { | ||||
position: relative; | position: relative; | ||||
-webkit-user-select: none; | -webkit-user-select: none; |
<label for="description">Short description</label> | <label for="description">Short description</label> | ||||
<textarea class="form-control" rows="4" type="text" name="description" placeholder="Tool description" autofocus=""></textarea> | <textarea class="form-control" rows="4" type="text" name="description" placeholder="Tool description" autofocus=""></textarea> | ||||
</div> | </div> | ||||
<div class="mb-3 mt-3"> | |||||
<label for="developer">Developer</label> | |||||
<input class="form-control" type="text" name="developer" placeholder="Developer" autofocus=""> | |||||
</div> | |||||
<div class="mb-3 mt-3"> | |||||
<label for="developerUrl">Developer URL</label> | |||||
<input class="form-control" type="text" name="developerUrl" placeholder="Developer URL" autofocus=""> | |||||
</div> | |||||
<div class="mb-3 mt-3"> | <div class="mb-3 mt-3"> | ||||
<label for="projectUrl">Project URL</label> | <label for="projectUrl">Project URL</label> | ||||
<label for="repositoryUrl">Repository URL</label> | <label for="repositoryUrl">Repository URL</label> | ||||
<input class="form-control" type="text" name="repositoryUrl" placeholder="Repository URL" autofocus=""> | <input class="form-control" type="text" name="repositoryUrl" placeholder="Repository URL" autofocus=""> | ||||
</div> | </div> | ||||
<div class="mb-3 mt-3"> | |||||
<label for="license">Software license</label> | |||||
<input class="form-control" type="text" name="license" placeholder="Software license" autofocus=""> | |||||
</div> | |||||
<div class="mb-3 mt-3"> | |||||
<label for="scriptingLanguage">Software language</label> | |||||
<input class="form-control" type="text" name="scriptingLanguage" placeholder="Software language" autofocus=""> | |||||
</div> | |||||
<div class="mb-3 mt-3"> | <div class="mb-3 mt-3"> | ||||
<label for="expertiseToUse">Expertise required to use</label> | <label for="expertiseToUse">Expertise required to use</label> |
{% block content %} | {% block content %} | ||||
{{linked_resources}} | |||||
<h1>{% block title %} Edit "{{ resource['name'] }}" {% endblock %}</h1> | <h1>{% block title %} Edit "{{ resource['name'] }}" {% endblock %}</h1> | ||||
<form method="post"> | <form method="post"> | ||||
</div> | </div> | ||||
{% if resource['type'] == 'tool' %} | {% if resource['type'] == 'tool' %} | ||||
<div class="mb-3 mt-3"> | |||||
<label for="developer">Developer</label> | |||||
<input type="text" name="developer" placeholder="Developer" | |||||
class="form-control" | |||||
value="{{ request.form['developer'] or resource['developer'] }}"> | |||||
</input> | |||||
</div> | |||||
<div class="mb-3 mt-3"> | |||||
<label for="developerUrl">Developer URL</label> | |||||
<input type="text" name="developerUrl" placeholder="Developer URL" | |||||
class="form-control" | |||||
value="{{ request.form['developerUrl'] or resource['developerUrl'] }}"> | |||||
</input> | |||||
</div> | |||||
<div class="mb-3 mt-3"> | <div class="mb-3 mt-3"> | ||||
<label for="projectUrl">Project URL</label> | <label for="projectUrl">Project URL</label> | ||||
<input type="text" name="projectUrl" placeholder="Project URL" | <input type="text" name="projectUrl" placeholder="Project URL" | ||||
value="{{ request.form['repositoryUrl'] or resource['repositoryUrl'] }}"> | value="{{ request.form['repositoryUrl'] or resource['repositoryUrl'] }}"> | ||||
</input> | </input> | ||||
</div> | </div> | ||||
<div class="mb-3 mt-3"> | |||||
<label for="license">Software license</label> | |||||
<input type="text" name="license" placeholder="Software license" | |||||
class="form-control" | |||||
value="{{ request.form['license'] or resource['license'] }}"> | |||||
</input> | |||||
</div> | |||||
<div class="mb-3 mt-3"> | |||||
<label for="scriptingLanguage">Software language(s)</label> | |||||
<input type="text" name="scriptingLanguage" placeholder="Software language(s)" | |||||
class="form-control" | |||||
value="{{ request.form['scriptingLanguage'] or resource['scriptingLanguage'] }}"> | |||||
</input> | |||||
</div> | |||||
<div class="mb-3 mt-3"> | <div class="mb-3 mt-3"> | ||||
<label for="expertiseToUse">Expertise required to use</label> | <label for="expertiseToUse">Expertise required to use</label> | ||||
<input type="text" name="expertiseToUse" placeholder="Expertise required to use" | <input type="text" name="expertiseToUse" placeholder="Expertise required to use" | ||||
onclick="return confirm('Are you sure you want to delete this practice?')"> | onclick="return confirm('Are you sure you want to delete this practice?')"> | ||||
</form> | </form> | ||||
{% endif %} | {% endif %} | ||||
{% if resource['type'] == 'publisher' %} | |||||
<form action="{{ url_for('publisher.delete_publisher', publisher_id=resource['id']) }}" method="POST"> | |||||
<input type="submit" value="Delete" | |||||
class="btn btn-danger btn-sm" | |||||
onclick="return confirm('Are you sure you want to delete this publisher?')"> | |||||
</form> | |||||
{% endif %} | |||||
{% endblock %} | {% endblock %} |
{{ resource['created'].strftime("%Y-%m-%d %H:%M") }} UTC | {{ resource['created'].strftime("%Y-%m-%d %H:%M") }} UTC | ||||
</td> | </td> | ||||
</tr> | </tr> | ||||
{% if resource['description'] %} | |||||
<tr> | <tr> | ||||
<th> | <th> | ||||
Description: | Description: | ||||
{{ resource['description'] }} | {{ resource['description'] }} | ||||
</td> | </td> | ||||
</tr> | </tr> | ||||
{% endif %} | |||||
{% if resource['developer'] %} | |||||
<tr> | |||||
<th> | |||||
Developer | |||||
</th> | |||||
<td> | |||||
{% if resource['developerUrl'] %} | |||||
<a href="{{ resource['developerUrl'] }}">{{ resource['developer'] }}</a> | |||||
{% else %} | |||||
{{ resource['developer'] }} | |||||
{% endif %} | |||||
</td> | |||||
</tr> | |||||
{% endif %} | |||||
{% if resource['license'] %} | |||||
<tr> | |||||
<th> | |||||
Software license: | |||||
</th> | |||||
<td> | |||||
{{ resource['license'] }} | |||||
</td> | |||||
</tr> | |||||
{% endif %} | |||||
{% if resource['scriptingLanguage'] %} | |||||
<tr> | |||||
<th> | |||||
Software language(s): | |||||
</th> | |||||
<td> | |||||
{{ resource['scriptingLanguage'] }} | |||||
</td> | |||||
</tr> | |||||
{% endif %} | |||||
{% if resource['projectUrl'] %} | {% if resource['projectUrl'] %} | ||||
<tr> | <tr> | ||||
<th> | <th> |
<a href="{{ url_for('practice.show_practice', practice_id=resource['id']) }}"> | <a href="{{ url_for('practice.show_practice', practice_id=resource['id']) }}"> | ||||
<h3 class="card-title text-center text-dark">{{ resource['name'] }}</h3> | <h3 class="card-title text-center text-dark">{{ resource['name'] }}</h3> | ||||
</a> | </a> | ||||
{% elif resource['type'] == 'publisher' %} | |||||
<a href="{{ url_for('publisher.show_publisher', publisher_id=resource['id']) }}"> | |||||
<h3 class="card-title text-center text-dark">{{ resource['name'] }}</h3> | |||||
</a> | |||||
{% endif %} | {% endif %} | ||||
<p class="card-text"> | <p class="card-text"> | ||||
{{ resource['description']|truncate(100) }} | {{ resource['description']|truncate(100) }} | ||||
<a href="{{ url_for('tool.edit_tool', tool_id=resource['id']) }}"> | <a href="{{ url_for('tool.edit_tool', tool_id=resource['id']) }}"> | ||||
<span class="badge bg-dark">Edit</span> | <span class="badge bg-dark">Edit</span> | ||||
</a> | </a> | ||||
{% endif %} | |||||
{% if resource['type'] == 'practice' %} | |||||
{% elif resource['type'] == 'practice' %} | |||||
<a href="{{ url_for('practice.edit_practice', practice_id=resource['id']) }}"> | <a href="{{ url_for('practice.edit_practice', practice_id=resource['id']) }}"> | ||||
<span class="badge bg-dark">Edit</span> | <span class="badge bg-dark">Edit</span> | ||||
</a> | </a> | ||||
{% elif resource['type'] == 'publisher' %} | |||||
<a href="{{ url_for('publisher.edit_publisher', publisher_id=resource['id']) }}"> | |||||
<span class="badge bg-dark">Edit</span> | |||||
</a> | |||||
{% endif %} | {% endif %} | ||||
{% endif %} | {% endif %} | ||||
</div> | </div> |
if request.method == 'POST': | if request.method == 'POST': | ||||
name = request.form['name'] | name = request.form['name'] | ||||
description = request.form['description'] | description = request.form['description'] | ||||
developer = request.form['developer'] | |||||
developerUrl = request.form['developerUrl'] | |||||
projectUrl = request.form['projectUrl'] | projectUrl = request.form['projectUrl'] | ||||
repositoryUrl = request.form['repositoryUrl'] | repositoryUrl = request.form['repositoryUrl'] | ||||
license = request.form['license'] | |||||
scriptingLanguage = request.form['scriptingLanguage'] | |||||
expertiseToUse = request.form['expertiseToUse'] | expertiseToUse = request.form['expertiseToUse'] | ||||
expertiseToHost = request.form['expertiseToHost'] | expertiseToHost = request.form['expertiseToHost'] | ||||
dependencies = request.form['dependencies'] | dependencies = request.form['dependencies'] | ||||
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.developer = developer | |||||
tool.developerUrl = developerUrl | |||||
tool.projectUrl = projectUrl | tool.projectUrl = projectUrl | ||||
tool.repositoryUrl = repositoryUrl | tool.repositoryUrl = repositoryUrl | ||||
tool.license = license | |||||
tool.scriptingLanguage = scriptingLanguage | |||||
tool.dependencies = dependencies | tool.dependencies = dependencies | ||||
tool.expertiseToUse = expertiseToUse | tool.expertiseToUse = expertiseToUse | ||||
tool.expertiseToHost = expertiseToHost | tool.expertiseToHost = expertiseToHost |