Add locationtypes + location tree (ADR-001)

- New locationtypes lookup (LocationType model) seeded with section, cell,
  subcell, operation, meetingroom, lab, office, storage, hallway,
  networkcloset, building.
- locations gains locationtypeid + parentlocationid (self-FK) for the site
  location tree. Migration 7c03; cli reference-data seeds the types.
- GET /api/locations/types; locations CRUD accepts type + parent; list/detail
  return locationtypename + parentlocationname.
- Locations settings page: Type column + Type/Parent selectors in the modal.

Realizes the operation-as-Location model (operations are locations with
locationtypeid='operation').

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-06-26 12:09:05 -04:00
parent a58feebe7a
commit 6fb8adc256
7 changed files with 192 additions and 10 deletions

View File

@@ -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, OperatingSystem, AssetStatus
from shopdb.core.models import MachineType, OperatingSystem, AssetStatus, LocationType
from shopdb.core.models.relationship import RelationshipType
# Machine types
@@ -85,6 +85,14 @@ def seed_reference_data():
elif existing.isactive is not True:
existing.isactive = True
# Location types (ADR-001)
location_types = ['section', 'cell', 'subcell', 'operation', 'meetingroom',
'lab', 'office', 'storage', 'hallway', 'networkcloset',
'building']
for lt in location_types:
if not LocationType.query.filter_by(locationtype=lt).first():
db.session.add(LocationType(locationtype=lt, isactive=True))
# Operating systems
os_list = [
{'osname': 'Windows 10', 'osversion': '10.0'},