Three features: device dropdown filter, charge log history, unassign-all
- Device dropdowns (quick-assign, bulk install, assign page) now only show devices with free slots; full devices are excluded entirely - New ChargeLog model tracks charge dates with optional cycle increment; battery detail page gets a Charge History card with add/delete rows - Device list page gets per-device Unassign All button (with confirmation) via new POST /device/<id>/unassign-all route
This commit is contained in:
@@ -54,6 +54,11 @@ class Battery(Base):
|
||||
order_by="CapacityTest.tested_date",
|
||||
cascade="all, delete-orphan",
|
||||
)
|
||||
charge_logs = relationship(
|
||||
"ChargeLog", back_populates="battery",
|
||||
order_by="ChargeLog.charged_date",
|
||||
cascade="all, delete-orphan",
|
||||
)
|
||||
|
||||
def is_available(self):
|
||||
return self.status == "available"
|
||||
@@ -81,3 +86,18 @@ class CapacityTest(Base):
|
||||
|
||||
def __repr__(self):
|
||||
return f"<CapacityTest {self.battery_id} {self.tested_date} {self.tested_capacity_mah}mAh>"
|
||||
|
||||
|
||||
class ChargeLog(Base):
|
||||
__tablename__ = "charge_log"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
battery_id = Column(Integer, ForeignKey("battery.id", ondelete="CASCADE"), nullable=False)
|
||||
charged_date = Column(String(10), nullable=False) # YYYY-MM-DD
|
||||
increment_cycles = Column(Integer, nullable=False, default=0) # 0 or 1
|
||||
notes = Column(Text, nullable=True)
|
||||
|
||||
battery = relationship("Battery", back_populates="charge_logs")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<ChargeLog {self.battery_id} {self.charged_date}>"
|
||||
|
||||
Reference in New Issue
Block a user