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

.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

+ 0
- 0
database_functions.sh View File


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

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:

+ 13
- 0
docker-compose.yml View File

- ./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:

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

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)

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

# @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

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

--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;

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

<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>

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



{% 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 %}

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

{{ 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>

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

<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>

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

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

Loading…
Cancel
Save