- imptune/api/printers.py: POST /printers (all form fields, checkbox->bool,
FK resolution), DELETE /printers/{id}, grouped list renderer with LEFT JOIN
- imptune/api/clients.py: POST /clients with duplicate-name handling
- imptune/api/pages.py: GET /printers and GET /clients page routes
- imptune/main.py: register printers + clients routers; close db on shutdown
- imptune/db/database.py: close existing connection before re-init (test isolation)
- templates: printers.html, clients.html, printer_form.html (Alpine.js port
auto-derivation), printer_list.html (grouped by client), client_list.html
- tests/conftest.py: close test-thread db connection in fixture teardown
- tests/test_printer_crud.py: updated to use list(select().where()) for DB
queries (avoids Peewee thread-local cursor caching across test boundaries)
Auto-fix [Rule 1 - Bug]: DB test isolation — Peewee thread-local connections
persisted across tests causing stale DB reads; fixed via conftest teardown and
lifespan db.close() on shutdown.
50 lines
1.3 KiB
HTML
50 lines
1.3 KiB
HTML
<div id="printer-list">
|
|
{% if not grouped %}
|
|
<p>No printers configured yet.</p>
|
|
{% else %}
|
|
{% for client_name, printers in grouped.items() %}
|
|
<section>
|
|
<h3>{{ client_name }}</h3>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>IP Address</th>
|
|
<th>Port</th>
|
|
<th>Driver</th>
|
|
<th>Duplex</th>
|
|
<th>Color</th>
|
|
<th>Paper</th>
|
|
<th>Collate</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for p in printers %}
|
|
<tr>
|
|
<td>{{ p.name }}</td>
|
|
<td>{{ p.ip_address }}</td>
|
|
<td>{{ p.port_name }}</td>
|
|
<td>{{ p.driver.original_filename if p.driver_id else '—' }}</td>
|
|
<td>{{ p.duplex_mode }}</td>
|
|
<td>{{ 'Yes' if p.color_mode else 'No' }}</td>
|
|
<td>{{ p.paper_size }}</td>
|
|
<td>{{ 'Yes' if p.collate else 'No' }}</td>
|
|
<td>
|
|
<button
|
|
hx-delete="/printers/{{ p.id }}"
|
|
hx-target="#printer-list"
|
|
hx-swap="outerHTML"
|
|
hx-confirm="Delete '{{ p.name }}'?">
|
|
Delete
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
{% endfor %}
|
|
{% endif %}
|
|
</div>
|