feat(non-loanable-devices): implement non-loanable device management
- Add non_loanable_devices table to database schema - Add web interface routes: /non_loanable_devices, /add_non_loanable_device, /edit_non_loanable_device, /delete_non_loanable_device - Add CLI menu options 8-10 for non-loanable device management - Add templates for non-loanable device CRUD operations - Update README.md with new feature documentation - Update REQUIREMENTS.md marking non-loanable devices as implemented - Add gestiontablets.sh script Implements: #porDefinir Registrar nuevos dispositivos no prestables
This commit is contained in:
parent
ac73e5dc93
commit
d3d1fb1b32
10 changed files with 417 additions and 6 deletions
|
|
@ -44,6 +44,22 @@ def init_db():
|
|||
)
|
||||
''')
|
||||
|
||||
# Create non_loanable_devices table
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS non_loanable_devices (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
brand TEXT NOT NULL,
|
||||
model TEXT NOT NULL,
|
||||
serial_number TEXT UNIQUE NOT NULL,
|
||||
device_type TEXT NOT NULL,
|
||||
location TEXT,
|
||||
status TEXT DEFAULT 'available',
|
||||
notes TEXT,
|
||||
purchase_date TEXT,
|
||||
purchase_cost REAL
|
||||
)
|
||||
''')
|
||||
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
|
|
@ -202,6 +218,59 @@ def show_loan_history():
|
|||
|
||||
conn.close()
|
||||
|
||||
|
||||
def add_non_loanable_device(brand, model, serial_number, device_type, location='', notes='', purchase_date='', purchase_cost=None):
|
||||
"""Add a new non-loanable device to inventory"""
|
||||
conn = sqlite3.connect('tablets.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
try:
|
||||
cursor.execute('''
|
||||
INSERT INTO non_loanable_devices
|
||||
(brand, model, serial_number, device_type, location, status, notes, purchase_date, purchase_cost)
|
||||
VALUES (?, ?, ?, ?, ?, 'available', ?, ?, ?)
|
||||
''', (brand, model, serial_number, device_type, location, notes, purchase_date, purchase_cost))
|
||||
conn.commit()
|
||||
print(f"✓ Added non-loanable device: {brand} {model} ({serial_number}) - Type: {device_type}")
|
||||
except sqlite3.IntegrityError:
|
||||
print(f"✗ Error: Serial number {serial_number} already exists")
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
def show_non_loanable_devices():
|
||||
"""Show all non-loanable devices"""
|
||||
conn = sqlite3.connect('tablets.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute("SELECT id, brand, model, serial_number, device_type, location, status FROM non_loanable_devices")
|
||||
devices = cursor.fetchall()
|
||||
|
||||
print("\n=== Non-Loanable Devices ===")
|
||||
if devices:
|
||||
for device in devices:
|
||||
print(f"ID: {device[0]}, Type: {device[4]}, {device[1]} {device[2]} ({device[3]}), Location: {device[5] or 'N/A'}, Status: {device[6]}")
|
||||
else:
|
||||
print("No non-loanable devices")
|
||||
|
||||
conn.close()
|
||||
|
||||
|
||||
def delete_non_loanable_device(device_id):
|
||||
"""Delete a non-loanable device"""
|
||||
conn = sqlite3.connect('tablets.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute("DELETE FROM non_loanable_devices WHERE id = ?", (device_id,))
|
||||
conn.commit()
|
||||
|
||||
if cursor.rowcount > 0:
|
||||
print(f"✓ Non-loanable device {device_id} deleted")
|
||||
else:
|
||||
print(f"✗ Error: Device {device_id} not found")
|
||||
|
||||
conn.close()
|
||||
|
||||
def main():
|
||||
"""Main menu"""
|
||||
init_db()
|
||||
|
|
@ -218,9 +287,12 @@ def main():
|
|||
print("5. Show Available Tablets")
|
||||
print("6. Show Active Loans")
|
||||
print("7. Show Loan History")
|
||||
print("8. Exit")
|
||||
print("8. Add Non-Loanable Device")
|
||||
print("9. Show Non-Loanable Devices")
|
||||
print("10. Delete Non-Loanable Device")
|
||||
print("11. Exit")
|
||||
|
||||
choice = input("Enter your choice (1-8): ")
|
||||
choice = input("Enter your choice (1-11): ")
|
||||
|
||||
if choice == '1':
|
||||
print("\n=== Add Tablet ===")
|
||||
|
|
@ -269,6 +341,28 @@ def main():
|
|||
show_loan_history()
|
||||
|
||||
elif choice == '8':
|
||||
print("\n=== Add Non-Loanable Device ===")
|
||||
brand = input("Brand: ")
|
||||
model = input("Model: ")
|
||||
serial_number = input("Serial Number: ")
|
||||
device_type = input("Device Type (e.g., projector, monitor): ")
|
||||
location = input("Location (optional): ")
|
||||
notes = input("Notes (optional): ")
|
||||
add_non_loanable_device(brand, model, serial_number, device_type, location, notes)
|
||||
|
||||
elif choice == '9':
|
||||
show_non_loanable_devices()
|
||||
|
||||
elif choice == '10':
|
||||
print("\n=== Delete Non-Loanable Device ===")
|
||||
show_non_loanable_devices()
|
||||
device_id = input("Enter Device ID to delete: ")
|
||||
try:
|
||||
delete_non_loanable_device(int(device_id))
|
||||
except ValueError:
|
||||
print("✗ Error: Invalid ID format")
|
||||
|
||||
elif choice == '11':
|
||||
print("Goodbye!")
|
||||
break
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue