main was 16 days and 259 commits behind the line the product is actually built on, at contract 0.30.0 against 0.35.0, with no per-PC credential code at all. It was neither current nor curated - just stale. This brings it forward and, at the same time, makes it mean something: main is what a receiving site installs, and nothing else. WHAT IT CARRIES. Twelve plugins - backups, computers, endpoints, guides, knowledgebase, machines, network, notifications, printers, slides, tools, warranty - plus applications, which is manifest-less core and always ships. The only manifest dependency inside that set is endpoints on computers, and both are in it, so the closure is self-contained. WHAT IT DOES NOT. employees, geenforce, measuringtools, printedparts and usb stay on the site line. So do the Windows installer tree, the VM rehearsal helpers, the agent tooling config, one site's data loader, the internal audit and findings records, and the planner spreadsheet. 1,135 tracked files against 1,438. A REMOVAL THAT BREAKS THE APP IS NOT A REMOVAL, and two nearly shipped: deploy/site-profile-universal.json still named all seventeen plugins. It is the file docs/DEPLOY.md tells a site to provision from, so a fresh install would have failed at `flask plugin apply-profile` with PluginError - the first thing a receiving site does, broken by the branch meant to serve them. It now names the twelve that exist, and its comment says the two must agree. agent/ was never refreshed. Whoever populated this branch copied shopdb/, plugins/, frontend/ and tests/ from the site line and left the agent tree at its September state: 22 C# and PowerShell sources missing, including AgentCredentials, EnrollmentService, AgentHttpFactory and the fleet-alert client, plus one file the site line had deleted still present. The old tree is internally consistent, so it compiles, and nothing in CI builds it - every gate was green over a server that speaks enrollment and per-PC credentials to a bundled agent source that cannot. Resynced whole. DECISIONS THIS ENCODES, rather than defers: - The plugin-authoring lab builds printedparts, whose manifest depends on employees, so it could not stay. The lab remains on the site line and main ships no build-along tutorial. That is a real loss for an adopting developer and is recorded here rather than discovered later. - Recognition, Training and Recertification notifications are no longer seeded. Each splits one notification into a card per employee and renders a photo, which needs a plugin this branch does not bundle. Seeding them would offer an author a type that cannot resolve anybody. A site that installs employees gets them from that plugin's own seed. - Windows/IIS is documented as the legacy path throughout, and the README leads with Docker, because that is what a receiving site gets. The API description is regenerated for THIS branch - 347 paths and 483 operations, down from 415 and 573 - so the published contract describes what is here rather than what the site line serves. docs/CONFIG.md lost the two measuring-tool label keys the code no longer declares, which two lanes had decided opposite ways. Suite: 3124 passed, 6 skipped. Naming and style gates pass. The docs gates run rather than skip, and every index line count is derived from the file it names.
150 lines
5.1 KiB
Python
150 lines
5.1 KiB
Python
"""Machines plugin models."""
|
|
|
|
from shopdb.api import db, BaseModel
|
|
|
|
|
|
class MachineType(BaseModel):
|
|
"""
|
|
Machine type classification.
|
|
|
|
Examples: CNC, CMM, Lathe, Grinder, EDM, Part Marker, etc.
|
|
"""
|
|
__tablename__ = 'machinetypes'
|
|
|
|
machinetypeid = db.Column(db.Integer, primary_key=True)
|
|
machinetype = db.Column(db.String(100), unique=True, nullable=False)
|
|
description = db.Column(db.Text)
|
|
icon = db.Column(db.String(50), comment='Icon name for UI')
|
|
color = db.Column(db.String(20), comment='CSS color for UI/map markers')
|
|
|
|
def __repr__(self):
|
|
return f"<MachineType {self.machinetype}>"
|
|
|
|
|
|
class Machine(BaseModel):
|
|
"""
|
|
Machine-specific extension data.
|
|
|
|
Links to core Asset table via assetid.
|
|
Stores machine-specific fields like type, model, vendor, etc.
|
|
"""
|
|
__tablename__ = 'machines'
|
|
|
|
machineid = db.Column(db.Integer, primary_key=True)
|
|
|
|
# Link to core asset
|
|
assetid = db.Column(
|
|
db.Integer,
|
|
db.ForeignKey('assets.assetid', ondelete='CASCADE'),
|
|
unique=True,
|
|
nullable=False,
|
|
index=True
|
|
)
|
|
|
|
# Machine classification
|
|
machinetypeid = db.Column(
|
|
db.Integer,
|
|
db.ForeignKey('machinetypes.machinetypeid'),
|
|
nullable=True
|
|
)
|
|
|
|
# Vendor and model
|
|
vendorid = db.Column(
|
|
db.Integer,
|
|
db.ForeignKey('vendors.vendorid'),
|
|
nullable=True
|
|
)
|
|
modelnumberid = db.Column(
|
|
db.Integer,
|
|
db.ForeignKey('models.modelnumberid'),
|
|
nullable=True
|
|
)
|
|
|
|
# Machine-specific fields
|
|
requiresmanualconfig = db.Column(
|
|
db.Boolean,
|
|
default=False,
|
|
comment='Multi-PC machine needs manual configuration'
|
|
)
|
|
islocationonly = db.Column(
|
|
db.Boolean,
|
|
default=False,
|
|
comment='Virtual location marker (not actual machine)'
|
|
)
|
|
|
|
# Maintenance tracking
|
|
# Dates, not datetimes: there is no time in a maintenance date, and a
|
|
# DATETIME went out of to_dict as "...T00:00:00Z", which a browser west of
|
|
# UTC rendered as the previous day. Warranties already
|
|
# model theirs as db.Date. See migration 7d40.
|
|
lastmaintenancedate = db.Column(db.Date, nullable=True)
|
|
nextmaintenancedate = db.Column(db.Date, nullable=True)
|
|
maintenanceintervaldays = db.Column(db.Integer, nullable=True)
|
|
|
|
# Controller info (for CNC machines)
|
|
controllervendorid = db.Column(
|
|
db.Integer,
|
|
db.ForeignKey('vendors.vendorid'),
|
|
nullable=True,
|
|
comment='Controller vendor (e.g., FANUC)'
|
|
)
|
|
controllermodelid = db.Column(
|
|
db.Integer,
|
|
db.ForeignKey('models.modelnumberid'),
|
|
nullable=True,
|
|
comment='Controller model (e.g., 31B)'
|
|
)
|
|
|
|
# Relationships
|
|
asset = db.relationship(
|
|
'Asset',
|
|
backref=db.backref('machine', uselist=False, lazy='joined')
|
|
)
|
|
machinetype = db.relationship('MachineType', backref='machines')
|
|
vendor = db.relationship('Vendor', foreign_keys=[vendorid], backref='machine_items')
|
|
model = db.relationship('Model', foreign_keys=[modelnumberid], backref='machine_items')
|
|
controllervendor = db.relationship('Vendor', foreign_keys=[controllervendorid], backref='machine_controllers')
|
|
controllermodel = db.relationship('Model', foreign_keys=[controllermodelid], backref='machine_controller_models')
|
|
|
|
__table_args__ = (
|
|
db.Index('idx_machine_type', 'machinetypeid'),
|
|
db.Index('idx_machine_vendor', 'vendorid'),
|
|
)
|
|
|
|
def __repr__(self):
|
|
return f"<Machine {self.assetid}>"
|
|
|
|
def to_dict(self):
|
|
"""Convert to dictionary with related names."""
|
|
result = super().to_dict()
|
|
|
|
# Add related object names
|
|
if self.machinetype:
|
|
result['machinetypename'] = self.machinetype.machinetype
|
|
if self.vendor:
|
|
result['vendorname'] = self.vendor.vendor
|
|
if self.model:
|
|
result['modelname'] = self.model.modelnumber
|
|
if self.model.imageurl:
|
|
result['imageurl'] = self.model.imageurl
|
|
# The catalog model already knows its maker, so an asset that has a
|
|
# model but no vendor of its own is showing a blank the database can
|
|
# fill. Flagged rather than merged silently: the edit form still has
|
|
# an empty vendor box, and a page implying otherwise would be lying.
|
|
if not self.vendor and self.model.vendor:
|
|
result['vendorname'] = self.model.vendor.vendor
|
|
result['vendorfrommodel'] = True
|
|
# Exposed under its OWN name. modeltypes is the catalog-wide list
|
|
# covering every kind of asset, so it is not interchangeable with
|
|
# this asset's own type and must never be substituted for it.
|
|
if self.model.modeltype:
|
|
result['modeltypename'] = self.model.modeltype.modeltype
|
|
|
|
# Add controller info
|
|
if self.controllervendor:
|
|
result['controllervendorname'] = self.controllervendor.vendor
|
|
if self.controllermodel:
|
|
result['controllermodelname'] = self.controllermodel.modelnumber
|
|
|
|
return result
|