Asset-side printer save, status CRUD, real printer types, network fix
- Printers save through the asset blueprint (PUT /printers) instead of the legacy machines API; restrict supply-model picker to printer models. - Asset statuses get full CRUD (PUT/DELETE with in-use guard); canonical set. - Printer types reseeded to a real classification set + list filter. - Equipment accepts gauge/maintenance references. - Fix network list emitting network_device instead of networkdevice (View 404). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -42,7 +42,7 @@ def seed_cli():
|
||||
def seed_reference_data():
|
||||
"""Seed reference data (machine types, statuses, etc.)."""
|
||||
from shopdb.extensions import db
|
||||
from shopdb.core.models import MachineType, MachineStatus, OperatingSystem
|
||||
from shopdb.core.models import MachineType, MachineStatus, OperatingSystem, AssetStatus
|
||||
from shopdb.core.models.relationship import RelationshipType
|
||||
|
||||
# Machine types
|
||||
@@ -82,6 +82,24 @@ def seed_reference_data():
|
||||
s = MachineStatus(**s_data)
|
||||
db.session.add(s)
|
||||
|
||||
# Asset statuses (canonical set - the asset model is the contract)
|
||||
asset_statuses = [
|
||||
{'status': 'In Use', 'description': 'Currently in use', 'color': '#28a745'},
|
||||
{'status': 'Inventory', 'description': 'In inventory', 'color': '#17a2b8'},
|
||||
{'status': 'In Repair', 'description': 'Being repaired', 'color': '#ffc107'},
|
||||
{'status': 'Retired', 'description': 'No longer in use', 'color': '#6c757d'},
|
||||
{'status': 'Returned', 'description': 'Returned to vendor or owner', 'color': '#fd7e14'},
|
||||
{'status': 'Warrantied', 'description': 'Under warranty service', 'color': '#20c997'},
|
||||
{'status': 'Lost', 'description': 'Lost or missing', 'color': '#dc3545'},
|
||||
]
|
||||
|
||||
for s_data in asset_statuses:
|
||||
existing = AssetStatus.query.filter_by(status=s_data['status']).first()
|
||||
if not existing:
|
||||
db.session.add(AssetStatus(isactive=True, **s_data))
|
||||
elif existing.isactive is not True:
|
||||
existing.isactive = True
|
||||
|
||||
# Operating systems
|
||||
os_list = [
|
||||
{'osname': 'Windows 10', 'osversion': '10.0'},
|
||||
|
||||
Reference in New Issue
Block a user