from flask import abort, flash, redirect, render_template, url_for
from flask_login import current_user, login_required

from . import inventory
from .. import db
from ..models import Thing


@app.before_request
def before_request():
    g.user = current_user


@inventory.route('/inventory', methods=['GET', 'POST'])
@login_required
def inventory_list():
    # show current inventory list
    # for the current user (vendor or customer)
    items = Thing.query.all()
    # render template
    # how do we get the image list?
    return render_template('inventory/items.html', items=items, title='Inventory')


@inventory.route('/inventory', methods=['GET', 'POST'])
@login_required
def item(itemid = None):
    # show a single item
    # select by item number
    # how do we get the image list?
    item = Thing.query(id=itemid)
    return render_template('inventory/item.html', item=item, title='element')
@@ -182,16 +182,23 @@
 rt Thing
+, Image
 %0A%0A%0A@app.
@@ -698,19 +698,17 @@
 m(itemid
- = 
+=
 None):%0A 
@@ -829,16 +829,58 @@
 itemid)%0A
+    image_list = Image.query(item=itemid)%0A
     retu
@@ -931,16 +931,39 @@
 em=item,
+ image_list=image_list,
  title='
@@ -971,8 +971,9 @@
 lement')
+%0A

add image list