Feature work from the 2026-07 session: Settings IA - Replace the flat 27-card settings hub with a persistent two-pane shell (SettingsLayout.vue): grouped, searchable left rail + content pane. - Nest all settings/* routes under the shell via router post-processing; shared nav catalog in settingsNav.js. Group by asset class (PCs, Printers, Equipment, Network) so per-type settings stop scattering. Custom fields (core) - customfields + customfieldvalues tables (migration 7d14), CRUD API at /api/customfields, per-asset value get/save. - Settings management page + reusable CustomFieldsSection (detail) and CustomFieldsInputs (form) wired into all four asset types. Warranty (new plugin) - plugins/warranty: warranties + warrantyassets (migration 7d15), derived coverage status, provider abstraction (manual now; Dell/Lenovo/HP stubs). - API CRUD + per-asset panel + report buckets; WarrantyPanel on all four detail pages; Warranties management page; Warranty report + Reports card. - Seed warranty.* permissions. Printer drivers - printerdrivers table (migration 7d13) linked to printer models; drivers now surface on the matching printer's detail page. Other - PCDetail rebalanced (Network + Status + Warranty + custom fields on the right). - Rename PCs list "Features" column to "Remote Access"; fix badge hover underline. - Drop equipment islocationonly field. - Centralize asset-type label/route maps into utils/assetTypes.js. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
123 lines
3.4 KiB
Python
123 lines
3.4 KiB
Python
"""Printer plugin models - new Asset-based architecture."""
|
|
|
|
from shopdb.api import db, BaseModel
|
|
|
|
|
|
class PrinterType(BaseModel):
|
|
"""
|
|
Printer type classification.
|
|
|
|
Examples: Laser, Inkjet, Label, MFP, Plotter, etc.
|
|
"""
|
|
__tablename__ = 'printertypes'
|
|
|
|
printertypeid = db.Column(db.Integer, primary_key=True)
|
|
printertype = 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"<PrinterType {self.printertype}>"
|
|
|
|
|
|
class Printer(BaseModel):
|
|
"""
|
|
Printer-specific extension data (new Asset architecture).
|
|
|
|
Links to core Asset table via assetid.
|
|
Stores printer-specific fields like type, Windows name, share name, etc.
|
|
"""
|
|
__tablename__ = 'printers'
|
|
|
|
printerid = 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
|
|
)
|
|
|
|
# Printer classification
|
|
printertypeid = db.Column(
|
|
db.Integer,
|
|
db.ForeignKey('printertypes.printertypeid'),
|
|
nullable=True
|
|
)
|
|
|
|
# Vendor
|
|
vendorid = db.Column(
|
|
db.Integer,
|
|
db.ForeignKey('vendors.vendorid'),
|
|
nullable=True
|
|
)
|
|
modelnumberid = db.Column(
|
|
db.Integer,
|
|
db.ForeignKey('models.modelnumberid'),
|
|
nullable=True
|
|
)
|
|
|
|
# Network identity
|
|
hostname = db.Column(
|
|
db.String(100),
|
|
index=True,
|
|
comment='Network hostname'
|
|
)
|
|
|
|
# Windows/Network naming
|
|
windowsname = db.Column(
|
|
db.String(255),
|
|
comment='Windows printer name (e.g., \\\\server\\printer)'
|
|
)
|
|
sharename = db.Column(
|
|
db.String(100),
|
|
comment='CSF/share name'
|
|
)
|
|
|
|
# Installation
|
|
iscsf = db.Column(db.Boolean, default=False, comment='Is CSF printer')
|
|
installpath = db.Column(db.String(255), comment='Driver install path')
|
|
|
|
# Printer PIN (for secure print)
|
|
pin = db.Column(db.String(20))
|
|
|
|
# Features
|
|
iscolor = db.Column(db.Boolean, default=False, comment='Color capable')
|
|
isduplex = db.Column(db.Boolean, default=False, comment='Duplex capable')
|
|
isnetwork = db.Column(db.Boolean, default=True, comment='Network connected')
|
|
|
|
# Relationships
|
|
asset = db.relationship(
|
|
'Asset',
|
|
backref=db.backref('printer', uselist=False, lazy='joined')
|
|
)
|
|
printertype = db.relationship('PrinterType', backref='printers')
|
|
vendor = db.relationship('Vendor', backref='printer_items')
|
|
model = db.relationship('Model', backref='printer_items')
|
|
|
|
__table_args__ = (
|
|
db.Index('idx_printer_type', 'printertypeid'),
|
|
db.Index('idx_printer_hostname', 'hostname'),
|
|
db.Index('idx_printer_windowsname', 'windowsname'),
|
|
)
|
|
|
|
def __repr__(self):
|
|
return f"<Printer {self.hostname or self.assetid}>"
|
|
|
|
def to_dict(self):
|
|
"""Convert to dictionary with related names."""
|
|
result = super().to_dict()
|
|
|
|
# Add related object names
|
|
if self.printertype:
|
|
result['printertypename'] = self.printertype.printertype
|
|
if self.vendor:
|
|
result['vendorname'] = self.vendor.vendor
|
|
if self.model:
|
|
result['modelname'] = self.model.modelnumber
|
|
|
|
return result
|