Add optional battery metadata fields
New nullable columns on Battery: size, chemistry, capacity_mah, tested_capacity_mah, tested_date, charge_cycles, purchase_date. Battery detail page shows all populated fields and a full edit form with select dropdowns for size and chemistry (with Other fallback). Capacity health % shown in green/orange/red when both nominal and tested capacity are set. Dashboard gains a Size column.
This commit is contained in:
@@ -37,6 +37,15 @@ class Battery(Base):
|
||||
device_id = Column(Integer, ForeignKey("device.id", ondelete="SET NULL"), nullable=True)
|
||||
notes = Column(Text, nullable=True)
|
||||
|
||||
# Optional metadata
|
||||
size = Column(String(20), nullable=True) # AA, AAA, 18650, CR2032 …
|
||||
chemistry = Column(String(20), nullable=True) # NiMH, Alkaline, Li-ion …
|
||||
capacity_mah = Column(Integer, nullable=True) # nominal capacity in mAh
|
||||
tested_capacity_mah = Column(Integer, nullable=True) # last measured capacity in mAh
|
||||
tested_date = Column(String(10), nullable=True) # YYYY-MM-DD of last test
|
||||
charge_cycles = Column(Integer, nullable=True) # number of charge cycles
|
||||
purchase_date = Column(String(10), nullable=True) # YYYY-MM-DD when purchased
|
||||
|
||||
device = relationship("Device", back_populates="batteries")
|
||||
|
||||
def is_available(self):
|
||||
|
||||
Reference in New Issue
Block a user