Pārlūkot izejas kodu

some changes to editing resources in app

practices
Simon Bowie pirms 1 gada
vecāks
revīzija
721f78315b
5 mainītis faili ar 66 papildinājumiem un 18 dzēšanām
  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 Parādīt failu

@@ -80,7 +80,7 @@ def show_book(book_id):
@login_required
def edit_book(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)

if request.method == 'POST':
@@ -96,7 +96,7 @@ def edit_book(book_id):
book.isbn = request.form['isbn']
book.typology = request.form['typology']
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')

edit_relationships(book_id, linked_resources, remove_linked_resources, existing_relationships)

+ 2
- 2
web/app/practice.py Parādīt failu

@@ -76,7 +76,7 @@ def show_practice(practice_id):
@login_required
def edit_practice(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)

if request.method == 'POST':
@@ -91,7 +91,7 @@ def edit_practice(practice_id):
practice.considerations = request.form['considerations']
practice.references = request.form['references']
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')

edit_relationships(practice_id, linked_resources, remove_linked_resources, existing_relationships)

+ 1
- 1
web/app/static/styles/main.css Parādīt failu

@@ -1167,7 +1167,7 @@ h2,h3 {
hyphens: auto;
}

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


+ 59
- 11
web/app/templates/edit.html Parādīt failu

@@ -105,12 +105,28 @@
</input>
</div>
<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 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 %}
{% 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 %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %}
@@ -143,12 +159,28 @@
class="form-control">{{ request.form['references'] or resource['references'] }}</textarea>
</div>
<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_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 %}
{% 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 %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %}
@@ -196,12 +228,28 @@
</input>
</div>
<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 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 %}
{% if resource_dropdown['type'] != 'book' %}
{% if resource_dropdown['type'] == 'practice' %}
{% if relationships and resource_dropdown in relationships %}
<option value="{{ resource_dropdown['id'] }}" selected>{{ resource_dropdown['name'] }}</option>
{% else %}
@@ -215,10 +263,10 @@

{% if relationships %}
<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 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 %}
<option value="{{ relationship['id'] }}">{{ relationship['name'] }}</option>
{% endfor %}

+ 2
- 2
web/app/tool.py Parādīt failu

@@ -82,7 +82,7 @@ def show_tool(tool_id):
@login_required
def edit_tool(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)

if request.method == 'POST':
@@ -105,7 +105,7 @@ def edit_tool(tool_id):
tool.outputFormats = request.form['outputFormats']
tool.status = request.form['status']
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')

edit_relationships(tool_id, linked_resources, remove_linked_resources, existing_relationships)

Notiek ielāde…
Atcelt
Saglabāt