Browse Source

changes to backend forms for editing and creation

main
Simon Bowie 4 weeks ago
parent
commit
52653a1588
7 changed files with 498 additions and 469 deletions
  1. +1
    -0
      web/app/book.py
  2. +1
    -2
      web/app/static/js/main.js
  3. +5
    -1
      web/app/static/styles/main.css
  4. +181
    -178
      web/app/templates/create.html
  5. +291
    -272
      web/app/templates/edit.html
  6. +18
    -16
      web/app/templates/login.html
  7. +1
    -0
      web/app/tool.py

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

@@ -95,6 +95,7 @@ def edit_book(book_id):
book.bookUrl = request.form['bookUrl']
book.isbn = request.form['isbn']
book.typology = request.form['typology']
book.videoUrl = request.form['videoUrl']
db.session.commit()
linked_resources = request.form.getlist('linked_tools') + request.form.getlist('linked_practices')
remove_linked_resources = request.form.getlist('remove_linked_resources')

+ 1
- 2
web/app/static/js/main.js View File

@@ -11,8 +11,7 @@
// htmx.logAll();

// Dynamic HTML forms based on dropdown menu
$("#resource_type").change(function() {
var $ = jQuery.noConflict();
$(document).on("change", "#resource_type", function() {
var resource_type = $(this).val();
$(".resource_type_input").hide("fast", function() {
$("#resource_type_" + resource_type).show("slow");

+ 5
- 1
web/app/static/styles/main.css View File

@@ -1702,7 +1702,7 @@ input.form-control[type=text] {

textarea.form-control {
width: 100%;
padding: 35px 20px;
padding: 1rem 1rem;
margin: 8px 0;
box-sizing: border-box;
border: 2px solid black;
@@ -1765,4 +1765,8 @@ div#embedded-video iframe {
right: 0;
height: 480px;
width: 100%;
}

.input-form {
padding: 1.5rem 2.5rem;
}

+ 181
- 178
web/app/templates/create.html View File

@@ -1,192 +1,195 @@
{% extends 'base.html' %}

{% block content %}
<h1>{% block title %} Add a New Resource{% endblock %}</h1>
<form method="POST" action="/create" id="resource">
<div class="mb-3 mt-3">
<label for="type">Type</label>
<select class="form-select" id="resource_type" name="resource_type" form="resource">
<option selected="selected">Please choose</option>
<option value="tool">Tool</option>
<option value="practice">Practice</option>
<option value="book">Book</option>
</select>
</div>
<div id="resource_type_tool" class="resource_type_input" style="display: none;">
<div class="mb-3 mt-3">
<label for="tool_name">Tool name</label>
<input class="form-control" type="text" name="tool_name" placeholder="Tool name" autofocus="">
</div>
<div class="mb-3 mt-3">
<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>
<input class="form-control" type="text" name="projectUrl" placeholder="Project URL" autofocus="">
</div>
<div class="mb-3 mt-3">
<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>
<input class="form-control" type="text" name="expertiseToUse" placeholder="Expertise required to use" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="expertiseToHost">Expertise required to self-host</label>
<input class="form-control" type="text" name="expertiseToHost" placeholder="Expertise required to self-host" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="dependencies">Technical dependencies</label>
<input class="form-control" type="text" name="dependencies" placeholder="Technical dependencies" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="ingestFormats">Import / ingest formats</label>
<input class="form-control" type="text" name="ingestFormats" placeholder="Import / ingest formats" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="outputFormats">Output formats</label>
<input class="form-control" type="text" name="outputFormats" placeholder="Output formats" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="status">Platform status</label>
<input class="form-control" type="text" name="status" placeholder="Platform status" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="linked_practices">Add practices relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_practices" id="linked_practices" aria-label="Add practices relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'practice' %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endfor %}
</select>
</div>
<div class="mb-3 mt-3">
<label for="linked_books">Add books relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_books" id="linked_books" aria-label="Add books relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'book' %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endfor %}
</select>
</div>
</div>
<div id="resource_type_practice" class="resource_type_input" style="display: none;">
<div class="mb-3 mt-3">
<label for="practice_name">Practice name</label>
<input class="form-control" type="text" name="practice_name" placeholder="Practice name" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="practice_markdown">Markdown text</label>
<textarea class="form-control" rows="4" type="text" name="practice_markdown" placeholder="Markdown text" autofocus=""></textarea>
</div>
<div class="mb-3 mt-3">
<label for="linked_tools">Add tools relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_tools" id="linked_tools" aria-label="Add tools relationships" class="selectpicker" data-live-search="true" multiple>

<div class="input-form">
<h1>{% block title %} Add a New Resource{% endblock %}</h1>
<form method="POST" action="/create" id="resource">
<div class="mb-3 mt-3">
<label for="type">Type</label>
<select class="form-select" id="resource_type" name="resource_type" form="resource">
<option selected="selected">Please choose</option>
<option value="tool">Tool</option>
<option value="practice">Practice</option>
<option value="book">Book</option>
</select>
</div>
<div id="resource_type_tool" class="resource_type_input" style="display: none;">
<div class="mb-3 mt-3">
<label for="tool_name">Tool name</label>
<input class="form-control" type="text" name="tool_name" placeholder="Tool name" autofocus="">
</div>
<div class="mb-3 mt-3">
<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>
<input class="form-control" type="text" name="projectUrl" placeholder="Project URL" autofocus="">
</div>
<div class="mb-3 mt-3">
<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>
<input class="form-control" type="text" name="expertiseToUse" placeholder="Expertise required to use" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="expertiseToHost">Expertise required to self-host</label>
<input class="form-control" type="text" name="expertiseToHost" placeholder="Expertise required to self-host" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="dependencies">Technical dependencies</label>
<input class="form-control" type="text" name="dependencies" placeholder="Technical dependencies" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="ingestFormats">Import / ingest formats</label>
<input class="form-control" type="text" name="ingestFormats" placeholder="Import / ingest formats" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="outputFormats">Output formats</label>
<input class="form-control" type="text" name="outputFormats" placeholder="Output formats" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="status">Platform status</label>
<input class="form-control" type="text" name="status" placeholder="Platform status" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="linked_practices">Add practices relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_practices" id="linked_practices" aria-label="Add practices relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'tool' %}
{% if resource_dropdown['type'] == 'practice' %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endfor %}
</select>
</div>
<div class="mb-3 mt-3">
</select>
</div>
<div class="mb-3 mt-3">
<label for="linked_books">Add books relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_books" id="linked_books" aria-label="Add books relationships" class="selectpicker" data-live-search="true" multiple>
</div>
<div class="mb-3 mt-3">
<select name="linked_books" id="linked_books" aria-label="Add books relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'book' %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endfor %}
</select>
</div>
</div>
<div id="resource_type_book" class="resource_type_input" style="display: none;">
<div class="mb-3 mt-3">
<label for="book_name">Book name</label>
<input class="form-control" type="text" name="book_name" placeholder="Book name" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="description">Description</label>
<textarea class="form-control" rows="4" type="text" name="description" placeholder="Book description" autofocus=""></textarea>
</div>
<div class="mb-3 mt-3">
<label for="author">Author</label>
<input class="form-control" type="text" name="author" placeholder="Author" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="year">Publication year</label>
<input class="form-control" type="text" name="year" placeholder="Publication year" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="typology">Typology category</label>
<input class="form-control" type="text" name="typology" placeholder="Typology category" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="bookUrl">URL</label>
<input class="form-control" type="text" name="bookUrl" placeholder="URL" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="isbn">ISBN</label>
<input class="form-control" type="text" name="isbn" placeholder="ISBN" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="linked_tools">Add tools relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_tools" id="linked_tools" aria-label="Add tools relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'tool' %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endfor %}
</select>
</div>
<div class="mb-3 mt-3">
<label for="linked_practices">Add practices relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_practices" id="linked_practices" aria-label="Add practices relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'practice' %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endfor %}
</select>
</div>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<script
src="https://code.jquery.com/jquery-3.7.1.js"
integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4="
crossorigin="anonymous"></script>
</select>
</div>
</div>
<div id="resource_type_practice" class="resource_type_input" style="display: none;">
<div class="mb-3 mt-3">
<label for="practice_name">Practice name</label>
<input class="form-control" type="text" name="practice_name" placeholder="Practice name" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="practice_markdown">Markdown text</label>
<textarea class="form-control" rows="4" type="text" name="practice_markdown" placeholder="Markdown text" autofocus=""></textarea>
</div>
<div class="mb-3 mt-3">
<label for="linked_tools">Add tools relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_tools" id="linked_tools" aria-label="Add tools relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'tool' %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endfor %}
</select>
</div>
<div class="mb-3 mt-3">
<label for="linked_books">Add books relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_books" id="linked_books" aria-label="Add books relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'book' %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endfor %}
</select>
</div>
</div>
<div id="resource_type_book" class="resource_type_input" style="display: none;">
<div class="mb-3 mt-3">
<label for="book_name">Book name</label>
<input class="form-control" type="text" name="book_name" placeholder="Book name" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="description">Description</label>
<textarea class="form-control" rows="4" type="text" name="description" placeholder="Book description" autofocus=""></textarea>
</div>
<div class="mb-3 mt-3">
<label for="author">Author</label>
<input class="form-control" type="text" name="author" placeholder="Author" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="year">Publication year</label>
<input class="form-control" type="text" name="year" placeholder="Publication year" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="typology">Typology category</label>
<input class="form-control" type="text" name="typology" placeholder="Typology category" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="bookUrl">URL</label>
<input class="form-control" type="text" name="bookUrl" placeholder="URL" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="isbn">ISBN</label>
<input class="form-control" type="text" name="isbn" placeholder="ISBN" autofocus="">
</div>
<div class="mb-3 mt-3">
<label for="linked_tools">Add tools relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_tools" id="linked_tools" aria-label="Add tools relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'tool' %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endfor %}
</select>
</div>
<div class="mb-3 mt-3">
<label for="linked_practices">Add practices relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_practices" id="linked_practices" aria-label="Add practices relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'practice' %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endfor %}
</select>
</div>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<script
src="https://code.jquery.com/jquery-3.7.1.js"
integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4="
crossorigin="anonymous"></script>
</div>
{% endblock %}

+ 291
- 272
web/app/templates/edit.html View File

@@ -2,293 +2,312 @@

{% block content %}

<h1>{% block title %} Edit "{{ resource['name'] }}" {% endblock %}</h1>
<div class="input-form">

<form method="post">
<div class="mb-3 mt-3">
<label for="name">Name</label>
<input type="text" name="name" placeholder="Name"
class="form-control"
value="{{ request.form['name'] or resource['name'] }}">
</input>
</div>
<h1>{% block title %} Edit "{{ resource['name'] }}" {% endblock %}</h1>

{% if resource['type'] == 'tool' %}
<div class="mb-3 mt-3">
<label for="description">Description</label>
<textarea name="description" placeholder="Description"
class="form-control">{{ request.form['description'] or resource['description'] }}</textarea>
</div>
<form method="post">
<div class="mb-3 mt-3">
<label for="name">Name</label>
<input type="text" name="name" placeholder="Name"
class="form-control"
value="{{ request.form['name'] or resource['name'] }}">
</input>
</div>

<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"
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="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'] }}">
{% if resource['type'] == 'tool' %}
<div class="mb-3 mt-3">
<label for="description">Description</label>
<textarea name="description" placeholder="Description"
class="form-control">{{ request.form['description'] or resource['description'] }}</textarea>
</div>

<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"
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="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"
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="videoUrl">Accompanying video</label>
<input type="text" name="videoUrl" placeholder="URL for accompanying video"
class="form-control"
value="{{ request.form['videoUrl'] or resource['videoUrl'] }}">
</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'] }}">
</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>
<div class="mb-3 mt-3">
<label for="linked_practices">Add practices relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_practices" id="linked_practices" aria-label="Add practices relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'practice' %}
{% if relationships and resource_dropdown in relationships %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endif %}
{% endfor %}
</select>
</div>
<div class="mb-3 mt-3">
<label for="linked_books">Add books relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_books" id="linked_books" aria-label="Add books relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'book' %}
{% if relationships and resource_dropdown in relationships %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endif %}
{% endfor %}
</select>
</div>

{% elif resource['type'] == 'practice' %}
<div class="mb-3 mt-3">
<label for="practice_markdown">Markdown text</label>
<textarea name="practice_markdown" placeholder="Markdown text"
class="form-control">{{ request.form['practice_markdown'] or practice_markdown }}</textarea>
</div>
<div class="mb-3 mt-3">
<label for="linked_tools">Add tools relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_tools" id="linked_tools" aria-label="Add tools relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'tool' %}
{% if relationships and resource_dropdown in relationships %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endif %}
{% endfor %}
</select>
</div>
<div class="mb-3 mt-3">
<label for="linked_books">Add books relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_books" id="linked_books" aria-label="Add books relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'book' %}
{% if relationships and resource_dropdown in relationships %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endif %}
{% endfor %}
</select>
</div>

{% elif resource['type'] == 'book' %}
<div class="mb-3 mt-3">
<label for="description">Description</label>
<textarea name="description" placeholder="Description"
class="form-control">{{ request.form['description'] or resource['description'] }}</textarea>
</div>

<div class="mb-3 mt-3">
<label for="author">Author</label>
<input type="text" name="author" placeholder="Author"
class="form-control"
value="{{ request.form['author'] or resource['author'] }}">
</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'] }}">
</div>
<div class="mb-3 mt-3">
<label for="year">Publication year</label>
<input type="text" name="year" placeholder="Publication year"
class="form-control"
value="{{ request.form['year'] or resource['year'] }}">
</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'] }}">
</div>
<div class="mb-3 mt-3">
<label for="typology">Typology category</label>
<input type="text" name="typology" placeholder="Typology category"
class="form-control"
value="{{ request.form['typology'] or resource['typology'] }}">
</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'] }}">
</div>
<div class="mb-3 mt-3">
<label for="bookUrl">URL</label>
<input type="text" name="bookUrl" placeholder="URL"
class="form-control"
value="{{ request.form['bookUrl'] or resource['bookUrl'] }}">
</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'] }}">
</div>
<div class="mb-3 mt-3">
<label for="isbn">ISBN</label>
<input type="text" name="isbn" placeholder="ISBN"
class="form-control"
value="{{ request.form['isbn'] or resource['isbn'] }}">
</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'] }}">
</div>
<div class="mb-3 mt-3">
<label for="videoUrl">Accompanying video</label>
<input type="text" name="videoUrl" placeholder="URL for accompanying video"
class="form-control"
value="{{ request.form['videoUrl'] or resource['videoUrl'] }}">
</input>
</div>
<div class="mb-3 mt-3">
<label for="linked_practices">Add practices relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_practices" id="linked_practices" aria-label="Add practices relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'practice' %}
{% if relationships and resource_dropdown in relationships %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endif %}
{% endfor %}
</select>
</div>
<div class="mb-3 mt-3">
<label for="linked_books">Add books relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_books" id="linked_books" aria-label="Add books relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'book' %}
{% if relationships and resource_dropdown in relationships %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
</div>
<div class="mb-3 mt-3">
<label for="linked_tools">Add tools relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_tools" id="linked_tools" aria-label="Add tools relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'tool' %}
{% if relationships and resource_dropdown in relationships %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
</select>
</div>

{% elif resource['type'] == 'practice' %}
<div class="mb-3 mt-3">
<label for="practice_markdown">Markdown text</label>
<textarea name="practice_markdown" placeholder="Markdown text"
class="form-control">{{ request.form['practice_markdown'] or practice_markdown }}</textarea>
</div>
<div class="mb-3 mt-3">
<label for="linked_tools">Add tools relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_tools" id="linked_tools" aria-label="Add tools relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'tool' %}
{% if relationships and resource_dropdown in relationships %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endif %}
{% endfor %}
</select>
</div>
<div class="mb-3 mt-3">
<label for="linked_books">Add books relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_books" id="linked_books" aria-label="Add books relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'book' %}
{% if relationships and resource_dropdown in relationships %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endfor %}
</select>
</div>
<div class="mb-3 mt-3">
<label for="linked_practices">Add practices relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_practices" id="linked_practices" aria-label="Add practices relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'practice' %}
{% if relationships and resource_dropdown in relationships %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
</select>
</div>
{% endfor %}
</select>
</div>
{% endif %}

{% elif resource['type'] == 'book' %}
<div class="mb-3 mt-3">
<label for="description">Description</label>
<textarea name="description" placeholder="Description"
class="form-control">{{ request.form['description'] or resource['description'] }}</textarea>
</div>
{% if relationships %}
<div class="mb-3 mt-3">
<label for="linked_practice_id">Remove relationship(s)</label>
</div>
<div class="mb-3 mt-3">
<select name="remove_linked_resources" id="remove_linked_resources" aria-label="Remove link" class="selectpicker" data-live-search="true" multiple>
{% for relationship in relationships %}
<option value="{{ relationship['id'] }}">{{ relationship['name'] }}</option>
{% endfor %}
</select>
</div>
{% endif %}

<div class="mb-3 mt-3">
<label for="author">Author</label>
<input type="text" name="author" placeholder="Author"
class="form-control"
value="{{ request.form['author'] or resource['author'] }}">
</input>
</div>
<div class="mb-3 mt-3">
<label for="year">Publication year</label>
<input type="text" name="year" placeholder="Publication year"
class="form-control"
value="{{ request.form['year'] or resource['year'] }}">
</input>
</div>
<div class="mb-3 mt-3">
<label for="typology">Typology category</label>
<input type="text" name="typology" placeholder="Typology category"
class="form-control"
value="{{ request.form['typology'] or resource['typology'] }}">
</input>
</div>
<div class="mb-3 mt-3">
<label for="bookUrl">URL</label>
<input type="text" name="bookUrl" placeholder="URL"
class="form-control"
value="{{ request.form['bookUrl'] or resource['bookUrl'] }}">
</input>
</div>
<div class="mb-3 mt-3">
<label for="isbn">ISBN</label>
<input type="text" name="isbn" placeholder="ISBN"
class="form-control"
value="{{ request.form['isbn'] or resource['isbn'] }}">
</input>
</div>
<div class="mb-3 mt-3">
<label for="linked_tools">Add tools relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_tools" id="linked_tools" aria-label="Add tools relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'tool' %}
{% if relationships and resource_dropdown in relationships %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endif %}
{% endfor %}
</select>
</div>
<div class="mb-3 mt-3">
<label for="linked_practices">Add practices relationship(s) (hold Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_practices" id="linked_practices" aria-label="Add practices relationships" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] == 'practice' %}
{% if relationships and resource_dropdown in relationships %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %}
<option value="{{ resource_dropdown['id'] }}">{{ resource_dropdown['name'] }}</option>
{% endif %}
{% endif %}
{% endfor %}
</select>
</div>
{% endif %}
<div class="mb-3 mt-3">
<button type="submit" class="btn btn-default">Submit</button>
</div>
</form>

{% if relationships %}
<div class="mb-3 mt-3">
<label for="linked_practice_id">Remove relationship(s)</label>
</div>
<div class="mb-3 mt-3">
<select name="remove_linked_resources" id="remove_linked_resources" aria-label="Remove link" class="selectpicker" data-live-search="true" multiple>
{% for relationship in relationships %}
<option value="{{ relationship['id'] }}">{{ relationship['name'] }}</option>
{% endfor %}
</select>
</div>
{% endif %}
{% if resource['type'] == 'tool' %}
<form action="{{ url_for('tool.delete_tool', tool_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 tool?')">
</form>
{% endif %}
{% if resource['type'] == 'practice' %}
<form action="{{ url_for('practice.delete_practice', practice_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 practice?')">
</form>
{% endif %}
{% if resource['type'] == 'book' %}
<form action="{{ url_for('book.delete_book', book_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 book?')">
</form>
{% endif %}

<div class="mb-3 mt-3">
<button type="submit" class="btn btn-default">Submit</button>
</div>
</form>
</div>

{% if resource['type'] == 'tool' %}
<form action="{{ url_for('tool.delete_tool', tool_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 tool?')">
</form>
{% endif %}
{% if resource['type'] == 'practice' %}
<form action="{{ url_for('practice.delete_practice', practice_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 practice?')">
</form>
{% endif %}
{% if resource['type'] == 'book' %}
<form action="{{ url_for('book.delete_book', book_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 book?')">
</form>
{% endif %}
{% endblock %}

+ 18
- 16
web/app/templates/login.html View File

@@ -1,21 +1,23 @@
{% extends 'base.html' %}

{% block content %}
<h1>{% block title %} Login {% endblock %}</h1>
<form method="POST" action="/login">
<div class="mb-3 mt-3">
<input class="form-control" type="email" name="email" placeholder="Your Email" autofocus="">
</div>
<div class="input-form">
<h1>{% block title %} Login {% endblock %}</h1>
<form method="POST" action="/login">
<div class="mb-3 mt-3">
<input class="form-control" type="email" name="email" placeholder="Your Email" autofocus="">
</div>

<div class="mb-3 mt-3">
<input class="form-control" type="password" name="password" placeholder="Your Password">
</div>
<div class="mb-3 mt-3">
<label class="checkbox">
<input type="checkbox">
Remember me
</label>
</div>
<button class="btn btn-default">Login</button>
</form>
<div class="mb-3 mt-3">
<input class="form-control" type="password" name="password" placeholder="Your Password">
</div>
<div class="mb-3 mt-3">
<label class="checkbox">
<input type="checkbox">
Remember me
</label>
</div>
<button class="btn btn-default">Login</button>
</form>
</div>
{% endblock %}

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

@@ -104,6 +104,7 @@ def edit_tool(tool_id):
tool.ingestFormats = request.form['ingestFormats']
tool.outputFormats = request.form['outputFormats']
tool.status = request.form['status']
tool.videoUrl = request.form['videoUrl']
db.session.commit()
linked_resources = request.form.getlist('linked_practices') + request.form.getlist('linked_books')
remove_linked_resources = request.form.getlist('remove_linked_resources')

Loading…
Cancel
Save