Rename the equipment domain to machines; retype the models catalog (ADR-011)
The equipment plugin is now the machines plugin, ending the UI-vs-code vocabulary split while the contract is pre-1.0 and nothing external depends on the old names. - plugins/equipment -> plugins/machines: manifest, class, /api/machines, machines.* permissions, registry key (with an auto-migrating load shim for existing installs). - Tables: equipment -> machines (equipmentid -> machineid) and equipmenttypes -> machinetypes, renamed in the plugin's own migration chain (machines0002rename), idempotent for both upgrading and fresh installs. - The legacy core machinetypes lookup actually types the vendor MODELS catalog, so it is renamed losslessly to modeltypes (models.modeltypeid, /api/modeltypes, Model Types settings page) rather than collapsed, freeing the machinetypes name. Core migration 7d17_machines_rename also flips data in place: assettypes row equipment -> machine, auditlog entitytype, identifier_/search_ settings keys, permission rows, and renames alembic_version_equipment. - Frontend: machinesApi/modeltypesApi, item.machine response shape, assettype value compares 'equipment' -> 'machine' (map, search, custom fields, relationships), routes machines.js with plugin gating retagged, /print/machine-badge, Machine Types (subtypes) and Model Types (catalog) settings pages, machines-by-type report id. - Docs swept; ADRs left as history per the authoring rule. Upgrade: flask db upgrade then flask plugin upgrade-all. Verified: dev DB flipped live (262 machines, 35 modeltypes, 95 models retyped, zero equipment tables remain); fresh scratch-MySQL install produces the new names; 341 tests green; naming/style green; frontend builds; live E2E on machines list/detail, PC relationships, map, reports, and both settings pages. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -332,7 +332,7 @@ def list_assets():
|
||||
- per_page: Items per page (default: 20, max: 100)
|
||||
- active: Filter by active status (default: true)
|
||||
- search: Search by assetnumber or name
|
||||
- type: Filter by asset type name (e.g., 'equipment', 'computer')
|
||||
- type: Filter by asset type name (e.g., 'machine', 'computer')
|
||||
- type_id: Filter by asset type ID
|
||||
- status_id: Filter by status ID
|
||||
- location_id: Filter by location ID
|
||||
@@ -699,8 +699,8 @@ def get_assets_map():
|
||||
Returns assets with mapx/mapy coordinates, joined with type-specific data.
|
||||
|
||||
Query parameters:
|
||||
- assettype: Filter by asset type name (equipment, computer, network_device, printer)
|
||||
- subtype: Filter by subtype ID (machinetype for equipment/computer, networkdevicetype for network, printertype for printer)
|
||||
- assettype: Filter by asset type name (machine, computer, network_device, printer)
|
||||
- subtype: Filter by subtype ID (machinetype for machines, computertype for PCs, networkdevicetype for network, printertype for printer)
|
||||
- businessunitid: Filter by business unit ID
|
||||
- statusid: Filter by status ID
|
||||
- locationid: Filter by location ID
|
||||
@@ -720,26 +720,26 @@ def get_assets_map():
|
||||
|
||||
# Eager-load plugin extension tables AND their relationships
|
||||
try:
|
||||
from plugins.equipment.models import Equipment
|
||||
from plugins.machines.models import Machine
|
||||
eager_options.append(
|
||||
subqueryload(Asset.equipment)
|
||||
.joinedload(Equipment.equipmenttype)
|
||||
subqueryload(Asset.machine)
|
||||
.joinedload(Machine.machinetype)
|
||||
)
|
||||
eager_options.append(
|
||||
subqueryload(Asset.equipment)
|
||||
.joinedload(Equipment.vendor)
|
||||
subqueryload(Asset.machine)
|
||||
.joinedload(Machine.vendor)
|
||||
)
|
||||
eager_options.append(
|
||||
subqueryload(Asset.equipment)
|
||||
.joinedload(Equipment.model)
|
||||
subqueryload(Asset.machine)
|
||||
.joinedload(Machine.model)
|
||||
)
|
||||
eager_options.append(
|
||||
subqueryload(Asset.equipment)
|
||||
.joinedload(Equipment.controllervendor)
|
||||
subqueryload(Asset.machine)
|
||||
.joinedload(Machine.controllervendor)
|
||||
)
|
||||
eager_options.append(
|
||||
subqueryload(Asset.equipment)
|
||||
.joinedload(Equipment.controllermodel)
|
||||
subqueryload(Asset.machine)
|
||||
.joinedload(Machine.controllermodel)
|
||||
)
|
||||
except (ImportError, AttributeError):
|
||||
pass
|
||||
@@ -800,11 +800,11 @@ def get_assets_map():
|
||||
if subtype_id := request.args.get('subtype'):
|
||||
subtype_id = int(subtype_id)
|
||||
asset_type_lower = selected_assettype.lower() if selected_assettype else ''
|
||||
if asset_type_lower == 'equipment':
|
||||
if asset_type_lower == 'machine':
|
||||
try:
|
||||
from plugins.equipment.models import Equipment
|
||||
query = query.join(Equipment, Equipment.assetid == Asset.assetid).filter(
|
||||
Equipment.equipmenttypeid == subtype_id
|
||||
from plugins.machines.models import Machine
|
||||
query = query.join(Machine, Machine.assetid == Asset.assetid).filter(
|
||||
Machine.machinetypeid == subtype_id
|
||||
)
|
||||
except ImportError:
|
||||
pass
|
||||
@@ -926,11 +926,11 @@ def get_assets_map():
|
||||
subtypes = {}
|
||||
|
||||
try:
|
||||
from plugins.equipment.models import EquipmentType
|
||||
equipment_types = EquipmentType.query.filter(EquipmentType.isactive == True).order_by(EquipmentType.equipmenttype).all()
|
||||
subtypes['Equipment'] = [{'id': et.equipmenttypeid, 'name': et.equipmenttype, 'color': et.color} for et in equipment_types]
|
||||
from plugins.machines.models import MachineType
|
||||
machine_types = MachineType.query.filter(MachineType.isactive == True).order_by(MachineType.machinetype).all()
|
||||
subtypes['Machine'] = [{'id': mt.machinetypeid, 'name': mt.machinetype, 'color': mt.color} for mt in machine_types]
|
||||
except ImportError:
|
||||
subtypes['Equipment'] = []
|
||||
subtypes['Machine'] = []
|
||||
|
||||
try:
|
||||
from plugins.computers.models import ComputerType
|
||||
|
||||
Reference in New Issue
Block a user