Skip to content

add test print button in admin panel - #196

Open
LookleftPL wants to merge 5 commits into
developfrom
feature/test-print-admin
Open

add test print button in admin panel#196
LookleftPL wants to merge 5 commits into
developfrom
feature/test-print-admin

Conversation

@LookleftPL

@LookleftPL LookleftPL commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Description

This pull request adds a test print button for admins so they can quickly check whether a printer works correctly.
issue: #185
Changes:

  1. I added a function 'trigger_test_print_view ' in 'control/views.py'. This function first checks if the test print is possible(user is an admin, request is POST, and etc.). Then it triggers a test print. Returns JSON with a status.
  2. Now printing logic is in file 'printing/services.py' with additional functions for finding pdf and triggering the test print with pdf. PDFs are located in 'backend/control/documents/'. There are 2 documents : 'test_page_grayscale.pdf' and test_page_colored.pdf
  3. In a file 'backend/control/admin.py' I added 'get_urls' and 'test_print_controls' functions. 'get_urls' adds the link for the test print and 'test_print_controls' adds 4 test print buttons in django admin.
  4. Added a 'admin_test_print.js' in static files. It handles button clicks in admin panel and send a POST request.
  5. Earlier the logic was in the api views ( 'api/views.py'). Now 'api/views.py' only calls functions from 'printing/services.py' and if error occurs it handles it.

@LookleftPL
LookleftPL force-pushed the feature/test-print-admin branch from cdad0b2 to b5a564a Compare August 7, 2026 17:37
@LookleftPL LookleftPL changed the title feature: add test print button using JS fetch and refactor print services add test print button using in admin panel Aug 9, 2026
@LookleftPL LookleftPL changed the title add test print button using in admin panel add test print button in admin panel Aug 9, 2026
@LookleftPL
LookleftPL force-pushed the feature/test-print-admin branch from b5a564a to d4d9685 Compare August 12, 2026 10:42
@LookleftPL
LookleftPL marked this pull request as ready for review August 13, 2026 11:32
@LookleftPL
LookleftPL force-pushed the feature/test-print-admin branch from f966666 to f0436a8 Compare August 13, 2026 11:46
Comment thread backend/api/views.py Outdated
Comment on lines +290 to +292
except Exception:
# re-raise so higher-level handlers can manage it
raise

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of the try-except block if all exceptions are re-thrown?

Comment thread CHANGELOG.md Outdated
Comment on lines 81 to 82
[#196]: https://github.com/KSIUJ/gutenberg/pull/196
[#194]: https://github.com/KSIUJ/gutenberg/pull/194

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[#196]: https://github.com/KSIUJ/gutenberg/pull/196
[#194]: https://github.com/KSIUJ/gutenberg/pull/194
[#194]: https://github.com/KSIUJ/gutenberg/pull/194
[#196]: https://github.com/KSIUJ/gutenberg/pull/196

Comment thread backend/control/admin.py
Comment on lines +53 to +67
def test_print_controls(self, obj):
"""
Renders action buttons for test prints in different configurations (simplex/duplex, color/black and white).
"""
if not obj or not obj.pk:
return "-"

url = reverse('admin:control_printer_test_print', args=[obj.pk])

test_variants = [
('B&W Simplex', False, False, 'btn-bw-simplex'),
('Color Simplex', True, False, 'btn-color-simplex'),
('B&W Duplex', False, True, 'btn-bw-duplex'),
('Color Duplex', True, True, 'btn-color-duplex'),
]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The term simplex is not used anywhere else in the UI or code. I would also avoid the term duplex - most of the code and the entire web UI use the terms one-sided and two-sided.

I would suggest sticking to one naming convention (both in the UI and in code) and in my opinion one-sided/two-sided is easier to understand for unfamiliar users.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The term black and white is incorrect here.
We support two color modes:

  1. colored,
  2. grayscale (monochrome in the Internet Printing Protocol)

grayscale (monochrome) is different from black and white (IPP: bi-level) - the former can print a spectrum of colors from white to black, while the latter can only print two colors

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current webapp UI:
Image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also use this opportunity to adjust these terms in the admin panel:

Image

@LookleftPL
LookleftPL force-pushed the feature/test-print-admin branch from f0436a8 to a52c26e Compare August 17, 2026 14:17
@LookleftPL
LookleftPL force-pushed the feature/test-print-admin branch from a52c26e to 6513515 Compare August 19, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants