Browse Source

changes for new database structure and adding MariaDB to dev environ

joel
Simon Bowie 2 years ago
parent
commit
5a20230b72
12 changed files with 135 additions and 7 deletions
  1. +1
    -1
      .gitignore
  2. +0
    -0
      database_functions.sh
  3. +2
    -0
      docker-compose.prod.yml
  4. +13
    -0
      docker-compose.yml
  5. +5
    -1
      web/app/create.py
  6. +0
    -1
      web/app/resources.py
  7. +6
    -0
      web/app/static/styles/custom.css
  8. +20
    -0
      web/app/templates/create.html
  9. +35
    -2
      web/app/templates/edit.html
  10. +36
    -0
      web/app/templates/resource.html
  11. +9
    -2
      web/app/templates/resources.html
  12. +8
    -0
      web/app/tool.py

+ 1
- 1
.gitignore View File

@@ -2,7 +2,7 @@ web/app/__pycache__/
.env.prod
.env.dev
.DS_Store
instance
database_functions_live.sh
old_database_schema
db_exports
db_imports

+ 0
- 0
database_functions.sh View File


+ 2
- 0
docker-compose.prod.yml View File

@@ -5,6 +5,8 @@ services:
container_name: python
expose:
- 5000
volumes:
- ./web:/code
env_file:
- ./.env.prod
depends_on:

+ 13
- 0
docker-compose.yml View File

@@ -9,3 +9,16 @@ services:
- ./web:/code
env_file:
- ./.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:

+ 5
- 1
web/app/create.py View File

@@ -27,8 +27,12 @@ def create_resource():
type = 'tool'
name = request.form.get('tool_name')
description = request.form.get('description')
developer = request.form.get('developer')
developerUrl = request.form.get('developerUrl')
projectUrl = request.form.get('projectUrl')
repositoryUrl = request.form.get('repositoryUrl')
license = request.form.get('license')
scriptingLanguage = request.form.get('scriptingLanguage')
expertiseToUse = request.form.get('expertiseToUse')
expertiseToHost = request.form.get('expertiseToHost')
dependencies = request.form.get('dependencies')
@@ -46,7 +50,7 @@ def create_resource():
return redirect(url_for('create.create_resource',_external=True,_scheme=os.environ.get('SSL_SCHEME')))

# 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
db.session.add(new_tool)

+ 0
- 1
web/app/resources.py View File

@@ -6,7 +6,6 @@
# @acknowledgements:

from flask import Blueprint, render_template, request, flash, redirect, url_for
from flask_login import login_required, current_user
from .models import Resource
from werkzeug.exceptions import abort
from . import db

+ 6
- 0
web/app/static/styles/custom.css View File

@@ -19,6 +19,7 @@
--bs-success-rgb: 25,135,84;
--bs-tool-rgb: 13,202,240;
--bs-practice-rgb: 255,193,7;
--bs-publisher-rgb: 150, 224, 167;
--bs-danger-rgb: 220,53,69;
--bs-light-rgb: 248,249,250;
--bs-dark-rgb: 33,37,41;
@@ -1058,6 +1059,11 @@ main > .container {
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 {
position: relative;
-webkit-user-select: none;

+ 20
- 0
web/app/templates/create.html View File

@@ -23,6 +23,16 @@
<label for="description">Short description</label>
<textarea class="form-control" rows="4" type="text" name="description" placeholder="Tool description" autofocus=""></textarea>
</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">
<label for="projectUrl">Project URL</label>
@@ -33,6 +43,16 @@
<label for="repositoryUrl">Repository URL</label>
<input class="form-control" type="text" name="repositoryUrl" placeholder="Repository URL" autofocus="">
</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">
<label for="expertiseToUse">Expertise required to use</label>

+ 35
- 2
web/app/templates/edit.html View File

@@ -2,8 +2,6 @@

{% block content %}

{{linked_resources}}

<h1>{% block title %} Edit "{{ resource['name'] }}" {% endblock %}</h1>

<form method="post">
@@ -22,6 +20,20 @@
</div>

{% 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">
<label for="projectUrl">Project URL</label>
<input type="text" name="projectUrl" placeholder="Project URL"
@@ -36,6 +48,20 @@
value="{{ request.form['repositoryUrl'] or resource['repositoryUrl'] }}">
</input>
</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">
<label for="expertiseToUse">Expertise required to use</label>
<input type="text" name="expertiseToUse" placeholder="Expertise required to use"
@@ -147,4 +173,11 @@
onclick="return confirm('Are you sure you want to delete this practice?')">
</form>
{% 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 %}

+ 36
- 0
web/app/templates/resource.html View File

@@ -37,6 +37,7 @@
{{ resource['created'].strftime("%Y-%m-%d %H:%M") }} UTC
</td>
</tr>
{% if resource['description'] %}
<tr>
<th>
Description:
@@ -45,6 +46,41 @@
{{ resource['description'] }}
</td>
</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'] %}
<tr>
<th>

+ 9
- 2
web/app/templates/resources.html View File

@@ -29,6 +29,10 @@
<a href="{{ url_for('practice.show_practice', practice_id=resource['id']) }}">
<h3 class="card-title text-center text-dark">{{ resource['name'] }}</h3>
</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 %}
<p class="card-text">
{{ resource['description']|truncate(100) }}
@@ -38,11 +42,14 @@
<a href="{{ url_for('tool.edit_tool', tool_id=resource['id']) }}">
<span class="badge bg-dark">Edit</span>
</a>
{% endif %}
{% if resource['type'] == 'practice' %}
{% elif resource['type'] == 'practice' %}
<a href="{{ url_for('practice.edit_practice', practice_id=resource['id']) }}">
<span class="badge bg-dark">Edit</span>
</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 %}
</div>

+ 8
- 0
web/app/tool.py View File

@@ -41,8 +41,12 @@ def edit_tool(tool_id):
if request.method == 'POST':
name = request.form['name']
description = request.form['description']
developer = request.form['developer']
developerUrl = request.form['developerUrl']
projectUrl = request.form['projectUrl']
repositoryUrl = request.form['repositoryUrl']
license = request.form['license']
scriptingLanguage = request.form['scriptingLanguage']
expertiseToUse = request.form['expertiseToUse']
expertiseToHost = request.form['expertiseToHost']
dependencies = request.form['dependencies']
@@ -58,8 +62,12 @@ def edit_tool(tool_id):
tool = Resource.query.get(tool_id)
tool.name = name
tool.description = description
tool.developer = developer
tool.developerUrl = developerUrl
tool.projectUrl = projectUrl
tool.repositoryUrl = repositoryUrl
tool.license = license
tool.scriptingLanguage = scriptingLanguage
tool.dependencies = dependencies
tool.expertiseToUse = expertiseToUse
tool.expertiseToHost = expertiseToHost

Loading…
Cancel
Save