diff --git a/config.example.json b/config.example.json index 744e19a..285bcf3 100644 --- a/config.example.json +++ b/config.example.json @@ -17,7 +17,8 @@ {"family": "Minion Pro", "style": "Semibold"}, {"family": "Linux Libertine", "style": "Regular"}, {"family": "DejaVu Serif", "style": "Book"} - ] + ], + "WAIT_AFTER_PRINT_s": 2 }, "WEBSITE": { "HTML_TITLE": "Label Designer", diff --git a/container/templates/container/container_print_label.html b/container/templates/container/container_print_label.html index 5b7fd7c..30ebb35 100644 --- a/container/templates/container/container_print_label.html +++ b/container/templates/container/container_print_label.html @@ -14,7 +14,7 @@
-
+ {% csrf_token %} diff --git a/container/views.py b/container/views.py index faa8680..5341a91 100644 --- a/container/views.py +++ b/container/views.py @@ -1,3 +1,5 @@ +import time + from django.views import generic from .models import Container, ContainerType import logging, json, re @@ -152,8 +154,12 @@ class ContainerPrintLabelView(LoginRequiredMixin, generic.DetailView): be_class = backend_factory(selected_backend)['backend_class'] be = be_class(config['PRINTER']['PRINTER']) context['logs'].append('Got backend driver') - for i in range(1, num_copies): + context['logs'].append(f'Start printing {num_copies} labels') + for i in range(0, num_copies): + context['logs'].append(f'printing #{i}') be.write(qlr.data) + if 'WAIT_AFTER_PRINT_s' in config['LABEL']: + time.sleep(config['LABEL']['WAIT_AFTER_PRINT_s']) context['logs'].append('Data sent to printer') be.dispose()