diff --git a/ereuse_devicehub/labels/views.py b/ereuse_devicehub/labels/views.py index 421effcb..13766bfe 100644 --- a/ereuse_devicehub/labels/views.py +++ b/ereuse_devicehub/labels/views.py @@ -114,21 +114,35 @@ class PrintLabelsView(View): class LabelDetailView(View): + """This View is used to print labels from multiple devices""" + + methods = ['POST', 'GET'] 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): lots = Lot.query.filter(Lot.owner_id == current_user.id) tag = ( Tag.query.filter(Tag.owner_id == current_user.id).filter(Tag.id == id).one() ) - context = { 'lots': lots, - 'tag': tag, - 'page_title': '{} Tag'.format(tag.code), + 'page_title': self.title, '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) diff --git a/ereuse_devicehub/templates/labels/print_labels.html b/ereuse_devicehub/templates/labels/print_labels.html index c629f887..df419a5f 100644 --- a/ereuse_devicehub/templates/labels/print_labels.html +++ b/ereuse_devicehub/templates/labels/print_labels.html @@ -153,7 +153,7 @@
- +
diff --git a/examples/app.py b/examples/app.py index 47671ec9..623bfaef 100644 --- a/examples/app.py +++ b/examples/app.py @@ -17,7 +17,7 @@ from ereuse_devicehub.workbench.views import workbench # from flask_wtf.csrf import CSRFProtect -# from werkzeug.contrib.profiler import ProfilerMiddleware +# from werkzeug.middleware.profiler import ProfilerMiddleware SENTRY_DSN = config('SENTRY_DSN', None) diff --git a/examples/app_cprofile.py b/examples/app_cprofile.py index e9f7d3fd..834f2f31 100644 --- a/examples/app_cprofile.py +++ b/examples/app_cprofile.py @@ -1,9 +1,9 @@ -from ereuse_devicehub.devicehub import Devicehub -from werkzeug.contrib.profiler import ProfilerMiddleware +from werkzeug.middleware.profiler import ProfilerMiddleware +from ereuse_devicehub.devicehub import Devicehub app = Devicehub(inventory='dbtest') app.config["SQLALCHEMY_RECORD_QUERIES"] = True app.config['PROFILE'] = True app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30]) -app.run(debug = True) +app.run(debug=True) diff --git a/tests/test_render_2_0.py b/tests/test_render_2_0.py index 0ffb4f91..50357d2e 100644 --- a/tests/test_render_2_0.py +++ b/tests/test_render_2_0.py @@ -356,7 +356,6 @@ def test_label_details(user3: UserClientFlask): user3.post(uri, data=data) body, status = user3.get('/labels/tag1/') - assert "tag1" in body assert "Print Label" in body