Skip to content
Snippets Groups Projects
Commit 34843baa authored by Benjamin Bertrand's avatar Benjamin Bertrand
Browse files

Add view item page

parent 99536bdd
No related branches found
No related tags found
No related merge requests found
...@@ -63,6 +63,13 @@ def index(): ...@@ -63,6 +63,13 @@ def index():
return render_template('index.html') return render_template('index.html')
@bp.route('/view/<ics_id>')
@login_required
def view_item(ics_id):
item = Item.query.filter_by(ics_id=ics_id).first_or_404()
return render_template('view_item.html', item=item)
@bp.route('/qrcodes') @bp.route('/qrcodes')
@login_required @login_required
def qrcodes(): def qrcodes():
......
...@@ -17,6 +17,17 @@ $(document).ready(function() { ...@@ -17,6 +17,17 @@ $(document).ready(function() {
"targets": [0], "targets": [0],
"visible": false, "visible": false,
"searchable": false "searchable": false
},
{
"targets": [1],
"render": function(data, type, row) {
// render funtion to create link to Item view page
if ( data === null ) {
return data;
}
var url = $SCRIPT_ROOT + "/view/" + data;
return '<a href="'+ url + '">' + data + '</a>';
}
} }
] ]
}); });
......
{% macro is_active(active) -%} {% macro is_active(active) -%}
{% if active %}active{% endif %} {% if active %}active{% endif %}
{%- endmacro %} {%- endmacro %}
{% macro link_to_item(item) -%}
{% if item %}
<a href="{{ url_for('main.view_item', ics_id=item.ics_id) }}">{{ item.ics_id }}</a>
{% else %}
{{ item }}
{% endif %}
{%- endmacro %}
{% macro link_to_children(item) -%}
{% for child in item.children %}
{{ link_to_item(child) }}
{% endfor %}
{%- endmacro %}
{%- extends "base.html" %}
{% from "_helpers.html" import link_to_item, link_to_children %}
{% block title %}View Item{% endblock %}
{% block main %}
<h2>Item {{ item.ics_id }}</h2>
<dl class="row">
<dt class="col-sm-3">ICS id</dt>
<dd class="col-sm-9">{{ item.ics_id }}</dt>
<dt class="col-sm-3">Created</dt>
<dd class="col-sm-9">{{ item._created.strftime("%Y-%m-%d %H:%M") }}</dt>
<dt class="col-sm-3">Updated</dt>
<dd class="col-sm-9">{{ item._updated.strftime("%Y-%m-%d %H:%M") }}</dt>
<dt class="col-sm-3">Serial number</dt>
<dd class="col-sm-9">{{ item.serial_number }}</dt>
<dt class="col-sm-3">Manufacturer</dt>
<dd class="col-sm-9">{{ item.manufacturer }}</dt>
<dt class="col-sm-3">Model</dt>
<dd class="col-sm-9">{{ item.model }}</dt>
<dt class="col-sm-3">Location</dt>
<dd class="col-sm-9">{{ item.location }}</dt>
<dt class="col-sm-3">Status</dt>
<dd class="col-sm-9">{{ item.status }}</dt>
<dt class="col-sm-3">Parent</dt>
<dd class="col-sm-9">{{ link_to_item(item.parent) }}</dt>
<dt class="col-sm-3">Children</dt>
<dd class="col-sm-9">{{ link_to_children(item) }}</dt>
</dl>
{%- endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment