23 lines
761 B
Python
23 lines
761 B
Python
from flask import Blueprint, render_template
|
|
from definitions.models import Asset
|
|
from config import item_attributes
|
|
|
|
viewall_bp = Blueprint('viewall', __name__)
|
|
|
|
@viewall_bp.route('/viewall/', methods=['GET'])
|
|
def view_list():
|
|
# Fetch all items from the database
|
|
items = Asset.query.all()
|
|
|
|
# Identify the primary attribute
|
|
primary_attrib = next((attrib for attrib in item_attributes if attrib.primary), None)
|
|
if not primary_attrib:
|
|
return "Primary attribute not defined in configuration."
|
|
|
|
# Render the template with items, attributes, and primary attribute
|
|
return render_template(
|
|
'viewList.html',
|
|
items=items,
|
|
item_attributes=item_attributes,
|
|
primary_attrib=primary_attrib.attrib_name
|
|
) |