Merge pull request #370 from eReuse/bugfix/3859-print-labels
Bugfix/3859 print labels
This commit is contained in:
commit
42d89def9a
|
@ -114,21 +114,35 @@ class PrintLabelsView(View):
|
||||||
|
|
||||||
|
|
||||||
class LabelDetailView(View):
|
class LabelDetailView(View):
|
||||||
|
"""This View is used to print labels from multiple devices"""
|
||||||
|
|
||||||
|
methods = ['POST', 'GET']
|
||||||
decorators = [login_required]
|
decorators = [login_required]
|
||||||
template_name = 'labels/label_detail.html'
|
template_name = 'labels/print_labels.html'
|
||||||
|
title = 'Design and implementation of labels'
|
||||||
|
|
||||||
def dispatch_request(self, id):
|
def dispatch_request(self, id):
|
||||||
lots = Lot.query.filter(Lot.owner_id == current_user.id)
|
lots = Lot.query.filter(Lot.owner_id == current_user.id)
|
||||||
tag = (
|
tag = (
|
||||||
Tag.query.filter(Tag.owner_id == current_user.id).filter(Tag.id == id).one()
|
Tag.query.filter(Tag.owner_id == current_user.id).filter(Tag.id == id).one()
|
||||||
)
|
)
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'lots': lots,
|
'lots': lots,
|
||||||
'tag': tag,
|
'page_title': self.title,
|
||||||
'page_title': '{} Tag'.format(tag.code),
|
|
||||||
'version': __version__,
|
'version': __version__,
|
||||||
|
'referrer': request.referrer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
devices = []
|
||||||
|
if tag.device:
|
||||||
|
form = PrintLabelsForm(devices=str(tag.device.id))
|
||||||
|
devices = [tag.device]
|
||||||
|
else:
|
||||||
|
form = PrintLabelsForm()
|
||||||
|
|
||||||
|
form._devices = devices
|
||||||
|
context['form'] = form
|
||||||
|
context['devices'] = devices
|
||||||
return flask.render_template(self.template_name, **context)
|
return flask.render_template(self.template_name, **context)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-switch">
|
<div class="form-switch">
|
||||||
<input class="form-check-input" name="tags" type="checkbox" id="tagsCheck">
|
<input class="form-check-input" name="tags" type="checkbox" id="tagsCheck">
|
||||||
<label class="form-check-label" for="tagsCheck">Tags</label>
|
<label class="form-check-label" for="tagsCheck">Unique Identifiers</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-switch">
|
<div class="form-switch">
|
||||||
<input class="form-check-input" name="serial_number" type="checkbox" id="serialNumberCheck">
|
<input class="form-check-input" name="serial_number" type="checkbox" id="serialNumberCheck">
|
||||||
|
|
|
@ -17,7 +17,7 @@ from ereuse_devicehub.workbench.views import workbench
|
||||||
# from flask_wtf.csrf import CSRFProtect
|
# from flask_wtf.csrf import CSRFProtect
|
||||||
|
|
||||||
|
|
||||||
# from werkzeug.contrib.profiler import ProfilerMiddleware
|
# from werkzeug.middleware.profiler import ProfilerMiddleware
|
||||||
|
|
||||||
|
|
||||||
SENTRY_DSN = config('SENTRY_DSN', None)
|
SENTRY_DSN = config('SENTRY_DSN', None)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from ereuse_devicehub.devicehub import Devicehub
|
from werkzeug.middleware.profiler import ProfilerMiddleware
|
||||||
from werkzeug.contrib.profiler import ProfilerMiddleware
|
|
||||||
|
|
||||||
|
from ereuse_devicehub.devicehub import Devicehub
|
||||||
|
|
||||||
app = Devicehub(inventory='dbtest')
|
app = Devicehub(inventory='dbtest')
|
||||||
app.config["SQLALCHEMY_RECORD_QUERIES"] = True
|
app.config["SQLALCHEMY_RECORD_QUERIES"] = True
|
||||||
|
|
|
@ -356,7 +356,6 @@ def test_label_details(user3: UserClientFlask):
|
||||||
user3.post(uri, data=data)
|
user3.post(uri, data=data)
|
||||||
|
|
||||||
body, status = user3.get('/labels/tag1/')
|
body, status = user3.get('/labels/tag1/')
|
||||||
assert "tag1" in body
|
|
||||||
assert "Print Label" in body
|
assert "Print Label" in body
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue