Fixed label print copies and added sleep after print

This commit is contained in:
Dirk Jahnke 2022-04-22 17:55:17 +02:00
parent fe24a5972d
commit 7e977881b4
3 changed files with 10 additions and 3 deletions

View File

@ -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",

View File

@ -14,7 +14,7 @@
<img class="img-fluid shadow p-3 mb-5 bg-body rounded" src="{{ barcode_img }}">
</div>
<div class="col-sm-12">
<form method="gest">
<form method="get">
{% csrf_token %}
<label for="num_copies">Number of copies:</label><input type="number" id="num_copies" size="2" min="1" max="8" name="num_copies" value="1">
<input type="submit" class="btn btn-primary" value="Print">

View File

@ -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()