Gestión de las Tablets del IES Schamann (préstamo y devolución).
Find a file
ijuanes 26b77cf0e9 fix(ui): prevent navigation overflow on zoom and small screens
- Add overflow-x: hidden to body to prevent horizontal scroll on zoom
- Add overflow: hidden to .container to prevent margin overflow
- Ensure .nav a has flex: 1 1 auto and min-width: 120px for proper wrapping
- Fixes issue where navigation buttons overflow through right margin when zoomed in

This ensures the navigation bar wraps properly and doesn't cause horizontal
scrolling or overflow issues on any screen size or zoom level.
2026-06-20 01:41:28 +01:00
docs docs: add Spanish translation requirement note to RESPONSIVE_CSS.md 2026-06-20 01:32:48 +01:00
templates fix(ui): prevent navigation overflow on zoom and small screens 2026-06-20 01:41:28 +01:00
tests test: add comprehensive unit test suite 2026-06-17 17:07:20 +01:00
.gitignore Initial commit: Tablet lending system with user-tablet many-to-many relationship 2026-06-03 10:43:17 +01:00
app.py feat(non-loanable-devices): implement non-loanable device management 2026-06-09 23:54:38 +01:00
basic_server.py Initial commit: Tablet lending system with user-tablet many-to-many relationship 2026-06-03 10:43:17 +01:00
check_flask.py Initial commit: Tablet lending system with user-tablet many-to-many relationship 2026-06-03 10:43:17 +01:00
CONTRIBUTING.md Initial commit: Tablet lending system with user-tablet many-to-many relationship 2026-06-03 10:43:17 +01:00
debug_server.py Initial commit: Tablet lending system with user-tablet many-to-many relationship 2026-06-03 10:43:17 +01:00
gestiontablets.sh feat(non-loanable-devices): implement non-loanable device management 2026-06-09 23:54:38 +01:00
index.html Initial commit: Tablet lending system with user-tablet many-to-many relationship 2026-06-03 10:43:17 +01:00
main.py Initial commit: Tablet lending system with user-tablet many-to-many relationship 2026-06-03 10:43:17 +01:00
minimal_app.py feat(non-loanable-devices): implement non-loanable device management 2026-06-09 23:54:38 +01:00
pyproject.toml test: add comprehensive unit test suite 2026-06-17 17:07:20 +01:00
README.md docs: add testing documentation to README and RUNNING.md 2026-06-17 17:10:12 +01:00
REQUIREMENTS.md feat(non-loanable-devices): implement non-loanable device management 2026-06-09 23:54:38 +01:00
requirements.txt Initial commit: Tablet lending system with user-tablet many-to-many relationship 2026-06-03 10:43:17 +01:00
RUNNING.md docs: add testing documentation to README and RUNNING.md 2026-06-17 17:10:12 +01:00
setup.py Initial commit: Tablet lending system with user-tablet many-to-many relationship 2026-06-03 10:43:17 +01:00
simple_app.py feat(non-loanable-devices): implement non-loanable device management 2026-06-09 23:54:38 +01:00
TECHNICAL_SPECIFICATIONS.md docs: add PostgreSQL migration guide for future scalability 2026-06-17 17:22:50 +01:00
test_app.py Initial commit: Tablet lending system with user-tablet many-to-many relationship 2026-06-03 10:43:17 +01:00
working_server.py Initial commit: Tablet lending system with user-tablet many-to-many relationship 2026-06-03 10:43:17 +01:00

Tablet Lending and Return Management System

A simple SQLite-based system for managing tablet lending and returns.

Features

  • Tablet Management: Add, track, and manage tablets in inventory
  • User Management: Register users who can borrow tablets
  • Loan Tracking: Track which tablets are loaned to which users
  • Return Management: Record when tablets are returned
  • History Tracking: Complete history of all loans and returns
  • User Loans View: See all tablets loaned to each user (demonstrates one-to-many relationship)
  • Non-Loanable Devices: Track inventory devices that cannot be loaned (e.g., projectors, monitors)
  • Project Notes: Markdown editor for development documentation

Files

  • minimal_app.py - Interactive command-line application (includes non-loanable device management)
  • test_app.py - Test script that demonstrates functionality
  • tablets.db - SQLite database (created automatically, includes non_loanable_devices table)
  • simple_app.py - Web-based version (requires Flask, includes non-loanable device management)
  • app.py - Alternative web version (requires Flask, includes non-loanable device management)

Quick Start

1. Run the test to see it in action

python3 test_app.py

This will:

  • Create the database
  • Add sample tablets and users
  • Demonstrate loan and return operations
  • Show the complete workflow

2. Run the interactive application

python3 minimal_app.py

This provides a menu-driven interface for:

  • Adding tablets
  • Adding users
  • Loaning tablets
  • Returning tablets
  • Viewing inventory and loan status

3. Database Structure

The system uses three main tables with a many-to-many relationship between users and tablets:

tablets

  • id: Primary key
  • brand: Tablet brand
  • model: Tablet model
  • serial_number: Unique serial number
  • status: 'available' or 'loaned'

users

  • id: Primary key
  • name: User's name
  • identification: Unique identification

loans (junction table)

  • id: Primary key
  • tablet_id: Foreign key to tablets
  • user_id: Foreign key to users
  • loan_date: When the tablet was loaned
  • return_date: When the tablet was returned (NULL if still active)
  • status: 'active' or 'returned'

Note

: The loans table enables a many-to-many relationship. One user can loan multiple tablets (one-to-many from user to loans), and each tablet can be loaned to different users over time. The status field on tablets ensures a device can only be loaned to one user at a time.

Requirements

  • Python 3.x (built-in sqlite3 module)
  • No additional dependencies needed for the command-line version
  • Flask required for web versions (optional)

Usage Examples

Adding a tablet

python3 -c "
import sqlite3
conn = sqlite3.connect('tablets.db')
cursor = conn.cursor()
cursor.execute('INSERT INTO tablets (brand, model, serial_number, status) VALUES (?, ?, ?, ?)', 
               ('Microsoft', 'Surface Pro', 'SN004', 'available'))
conn.commit()
conn.close()
print('Tablet added!')
"

Adding a user

python3 -c "
import sqlite3
conn = sqlite3.connect('tablets.db')
cursor = conn.cursor()
cursor.execute('INSERT INTO users (name, identification) VALUES (?, ?)', 
               ('Alice Brown', 'ID004'))
conn.commit()
conn.close()
print('User added!')
"

Querying available tablets

python3 -c "
import sqlite3
conn = sqlite3.connect('tablets.db')
cursor = conn.cursor()
cursor.execute('SELECT brand, model, serial_number FROM tablets WHERE status = ?', ('available',))
for row in cursor.fetchall():
    print(f'{row[0]} {row[1]} ({row[2]})')
conn.close()
"

Web Version (Optional)

If you want to use the web interface:

  1. Install Flask:
pip install flask
  1. Run the web application:
python3 app.py
  1. Open your browser to: http://localhost:5000

Web Features

  • Home: View available tablets and active loans
  • Loan Tablet: Loan a tablet to a user (with search for large datasets)
  • User Loans: View all tablets loaned to each user - demonstrates the one-to-many relationship (one user, multiple tablets)
  • Loan History: Complete history of all loan and return transactions
  • Non-Loanable Devices: Manage inventory of devices that cannot be loaned (add, edit, delete, view)
  • Project Management: Markdown editor for development notes (saved to notes_development/project_notes.md)

Database Backup

To backup your data:

cp tablets.db tablets_backup_$(date +%Y%m%d).db

Testing

The project includes a comprehensive unit test suite with 46 tests covering core functionality and edge cases.

Running Tests

# Install test dependencies (if not already installed)
source .venv/bin/activate
uv pip install pytest pytest-cov

# Run all tests
python3 -m pytest tests/ -v

# Run with coverage report
python3 -m pytest tests/ --cov=./ --cov-report=term-missing

Test Structure

File Tests Coverage
tests/test_core.py 21 Core operations (tablet, user, loan CRUD)
tests/test_edge_cases.py 14 Edge cases (duplicates, invalid IDs, etc.)
tests/test_minimal_app.py 11 Application function tests

Key Edge Cases Covered

  • Loan a device that's already loaned (prevents double-loaning)
  • Return a non-existent loan (handles gracefully)
  • Duplicate serial numbers (rejected at database level)
  • Duplicate user identifications (rejected at database level)
  • Invalid tablet/user IDs (validated before operations)
  • Multiple loans per user (one-to-many relationship)
  • Loan-return-loan sequence (device lifecycle)

Test Configuration

Tests use isolated temporary databases and automatically clean up after each test run. No impact on production data.

License

This is a simple educational project. Feel free to use and modify it as needed.