2025-02-11 07:47:57 +00:00
|
|
|
from flask import Blueprint, render_template
|
2025-02-11 18:45:53 +00:00
|
|
|
from definitions.models import Asset
|
2025-02-11 05:38:27 +00:00
|
|
|
from config import item_attributes
|
2025-01-30 07:37:21 +00:00
|
|
|
|
|
|
|
viewall_bp = Blueprint('viewall', __name__)
|
|
|
|
|
2025-02-11 07:47:57 +00:00
|
|
|
@viewall_bp.route('/viewall/', methods=['GET'])
|
2025-01-30 07:37:21 +00:00
|
|
|
def view_list():
|
2025-02-22 18:58:10 +00:00
|
|
|
# Fetch all items from the database
|
2025-01-30 07:37:21 +00:00
|
|
|
items = Asset.query.all()
|
2025-02-22 18:58:10 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
)
|