Browse Source

some changes to editing resources in app

practices
Simon Bowie 1 year ago
parent
commit
721f78315b
5 changed files with 66 additions and 18 deletions
  1. +2
    -2
      web/app/book.py
  2. +2
    -2
      web/app/practice.py
  3. +1
    -1
      web/app/static/styles/main.css
  4. +59
    -11
      web/app/templates/edit.html
  5. +2
    -2
      web/app/tool.py

+ 2
- 2
web/app/book.py View File

@login_required @login_required
def edit_book(book_id): def edit_book(book_id):
book = get_resource(book_id) book = get_resource(book_id)
resource_dropdown = Resource.query
resource_dropdown = Resource.query.order_by(Resource.name)
existing_relationships = get_relationships(book_id) existing_relationships = get_relationships(book_id)


if request.method == 'POST': if request.method == 'POST':
book.isbn = request.form['isbn'] book.isbn = request.form['isbn']
book.typology = request.form['typology'] book.typology = request.form['typology']
db.session.commit() db.session.commit()
linked_resources = request.form.getlist('linked_resources')
linked_resources = request.form.getlist('linked_tools') + request.form.getlist('linked_practices')
remove_linked_resources = request.form.getlist('remove_linked_resources') remove_linked_resources = request.form.getlist('remove_linked_resources')


edit_relationships(book_id, linked_resources, remove_linked_resources, existing_relationships) edit_relationships(book_id, linked_resources, remove_linked_resources, existing_relationships)

+ 2
- 2
web/app/practice.py View File

@login_required @login_required
def edit_practice(practice_id): def edit_practice(practice_id):
practice = get_resource(practice_id) practice = get_resource(practice_id)
resource_dropdown = Resource.query
resource_dropdown = Resource.query.order_by(Resource.name)
existing_relationships = get_relationships(practice_id) existing_relationships = get_relationships(practice_id)


if request.method == 'POST': if request.method == 'POST':
practice.considerations = request.form['considerations'] practice.considerations = request.form['considerations']
practice.references = request.form['references'] practice.references = request.form['references']
db.session.commit() db.session.commit()
linked_resources = request.form.getlist('linked_resources')
linked_resources = request.form.getlist('linked_tools') + request.form.getlist('linked_books')
remove_linked_resources = request.form.getlist('remove_linked_resources') remove_linked_resources = request.form.getlist('remove_linked_resources')


edit_relationships(practice_id, linked_resources, remove_linked_resources, existing_relationships) edit_relationships(practice_id, linked_resources, remove_linked_resources, existing_relationships)

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

hyphens: auto; hyphens: auto;
} }


h3 {
h1, h2, h3 {
font-family: 'ag-fett'; font-family: 'ag-fett';
} }



+ 59
- 11
web/app/templates/edit.html View File

</input> </input>
</div> </div>
<div class="mb-3 mt-3"> <div class="mb-3 mt-3">
<label for="linked_practice_id">Linked resources</label>
<label for="linked_practices">Add link to practices (press Ctrl to select multiple options)</label>
</div> </div>
<div class="mb-3 mt-3"> <div class="mb-3 mt-3">
<select name="linked_resources" id="linked_resources" aria-label="Linked resources" class="selectpicker" data-live-search="true" multiple>
<select name="linked_practices" id="linked_practices" aria-label="Add link to practices" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %} {% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] != 'tool' %}
{% 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 link to books (press Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_books" id="linked_books" aria-label="Add link to books" 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 %} {% if relationships and resource_dropdown in relationships %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option> <option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %} {% else %}
class="form-control">{{ request.form['references'] or resource['references'] }}</textarea> class="form-control">{{ request.form['references'] or resource['references'] }}</textarea>
</div> </div>
<div class="mb-3 mt-3"> <div class="mb-3 mt-3">
<label for="linked_practice_id">Linked resources</label>
<label for="linked_tools">Add link to tools (press Ctrl to select multiple options)</label>
</div> </div>
<div class="mb-3 mt-3"> <div class="mb-3 mt-3">
<select name="linked_resources" id="linked_resources" aria-label="Linked resources" class="selectpicker" data-live-search="true" multiple>
<select name="linked_tools" id="linked_tools" aria-label="Add link to tools" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %} {% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] != 'practice' %}
{% 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 link to books (press Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_books" id="linked_books" aria-label="Add link to books" 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 %} {% if relationships and resource_dropdown in relationships %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option> <option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %} {% else %}
</input> </input>
</div> </div>
<div class="mb-3 mt-3"> <div class="mb-3 mt-3">
<label for="linked_practice_id">Linked resources</label>
<label for="linked_tools">Add link to tools (press Ctrl to select multiple options)</label>
</div>
<div class="mb-3 mt-3">
<select name="linked_tools" id="linked_tools" aria-label="Add link to tools" 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 link to practices (press Ctrl to select multiple options)</label>
</div> </div>
<div class="mb-3 mt-3"> <div class="mb-3 mt-3">
<select name="linked_resources" id="linked_resources" aria-label="Linked resources" class="selectpicker" data-live-search="true" multiple>
<select name="linked_practices" id="linked_practices" aria-label="Add link to practices" class="selectpicker" data-live-search="true" multiple>
{% for resource_dropdown in resource_dropdown %} {% for resource_dropdown in resource_dropdown %}
{% if resource_dropdown['type'] != 'book' %}
{% if resource_dropdown['type'] == 'practice' %}
{% if relationships and resource_dropdown in relationships %} {% if relationships and resource_dropdown in relationships %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option> <option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %} {% else %}


{% if relationships %} {% if relationships %}
<div class="mb-3 mt-3"> <div class="mb-3 mt-3">
<label for="linked_practice_id">Remove linked resources</label>
<label for="linked_practice_id">Remove link</label>
</div> </div>
<div class="mb-3 mt-3"> <div class="mb-3 mt-3">
<select name="remove_linked_resources" id="remove_linked_resources" aria-label="Remove linked resources" class="selectpicker" data-live-search="true" multiple>
<select name="remove_linked_resources" id="remove_linked_resources" aria-label="Remove link" class="selectpicker" data-live-search="true" multiple>
{% for relationship in relationships %} {% for relationship in relationships %}
<option value="{{ relationship['id'] }}">{{ relationship['name'] }}</option> <option value="{{ relationship['id'] }}">{{ relationship['name'] }}</option>
{% endfor %} {% endfor %}

+ 2
- 2
web/app/tool.py View File

@login_required @login_required
def edit_tool(tool_id): def edit_tool(tool_id):
tool = get_resource(tool_id) tool = get_resource(tool_id)
resource_dropdown = Resource.query
resource_dropdown = Resource.query.order_by(Resource.name)
existing_relationships = get_relationships(tool_id) existing_relationships = get_relationships(tool_id)


if request.method == 'POST': if request.method == 'POST':
tool.outputFormats = request.form['outputFormats'] tool.outputFormats = request.form['outputFormats']
tool.status = request.form['status'] tool.status = request.form['status']
db.session.commit() db.session.commit()
linked_resources = request.form.getlist('linked_resources')
linked_resources = request.form.getlist('linked_practices') + request.form.getlist('linked_books')
remove_linked_resources = request.form.getlist('remove_linked_resources') remove_linked_resources = request.form.getlist('remove_linked_resources')


edit_relationships(tool_id, linked_resources, remove_linked_resources, existing_relationships) edit_relationships(tool_id, linked_resources, remove_linked_resources, existing_relationships)

Loading…
Cancel
Save