From 0c02c33a871448b572046425063aff68ad271f44 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Mon, 29 Jan 2018 11:26:08 +0100 Subject: [PATCH 01/23] Add number of copies control --- .../browser/templates/stickers_preview.pt | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/bika/lims/browser/templates/stickers_preview.pt b/bika/lims/browser/templates/stickers_preview.pt index 53eafd103d..0663a5b4a3 100644 --- a/bika/lims/browser/templates/stickers_preview.pt +++ b/bika/lims/browser/templates/stickers_preview.pt @@ -61,6 +61,23 @@ background-color: #bbb; text-shadow: 1px 1px 1px #aaa; } + #sticker-preview-header #sticker-copies input { + text-align:center; + width:15mm; + margin:0 0 10px 0; + background-color: #aaa; + border-radius: 5px; + color: #fff; + font-family: Helvetica,Arial; + font-size: 9pt; + font-weight: bold; + padding: 4px 2px; + text-decoration: none; + text-shadow: 1px 1px 1px #999; + text-transform: uppercase; + border:none; + cursor:pointer; + } #sticker-rule { color: rgb(51, 51, 51); height: 10mm; @@ -221,6 +238,15 @@ +
+ + + /> +
Date: Mon, 29 Jan 2018 12:03:59 +0100 Subject: [PATCH 02/23] Get the number of sticker copies from the template --- bika/lims/browser/stickers.py | 11 +++++++++++ bika/lims/browser/templates/stickers_preview.pt | 4 +--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bika/lims/browser/stickers.py b/bika/lims/browser/stickers.py index bdafcedc2b..ef7ec940ec 100644 --- a/bika/lims/browser/stickers.py +++ b/bika/lims/browser/stickers.py @@ -66,6 +66,7 @@ def __call__(self): pdfstream = self.pdf_from_post() return pdfstream + self.copies_count = self.get_copies_count() self.rendered_items = [] items = self.request.get('items', '') # If filter by type is given in the request, only the templates under @@ -324,3 +325,13 @@ def pdf_from_post(self): pdf_fn = tempfile.mktemp(suffix='.pdf') pdf_file = createPdf(htmlreport=reporthtml, outfile=pdf_fn) return pdf_file + + def get_copies_count(self): + """Return the copies_count request paramteter + """ + copies_count = 1 + try: + copies_count = int(self.request.form.get("copies_count", 1)) + except (TypeError, ValueError): + copies_count = 1 + return copies_count diff --git a/bika/lims/browser/templates/stickers_preview.pt b/bika/lims/browser/templates/stickers_preview.pt index 0663a5b4a3..86a03a5bd2 100644 --- a/bika/lims/browser/templates/stickers_preview.pt +++ b/bika/lims/browser/templates/stickers_preview.pt @@ -241,11 +241,9 @@
- /> + tal:attributes="value view/copies_count"/>
From 056af875f0673af3d6487b92c901452650e93d4b Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Mon, 29 Jan 2018 12:28:46 +0100 Subject: [PATCH 03/23] Remove unnecessary variable definition --- bika/lims/browser/stickers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bika/lims/browser/stickers.py b/bika/lims/browser/stickers.py index ef7ec940ec..9aee59e63a 100644 --- a/bika/lims/browser/stickers.py +++ b/bika/lims/browser/stickers.py @@ -329,7 +329,6 @@ def pdf_from_post(self): def get_copies_count(self): """Return the copies_count request paramteter """ - copies_count = 1 try: copies_count = int(self.request.form.get("copies_count", 1)) except (TypeError, ValueError): From ed1c4e12342e6f603270ac7d90e09c797c7fe87c Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Mon, 29 Jan 2018 12:29:21 +0100 Subject: [PATCH 04/23] Correct typo --- bika/lims/browser/stickers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bika/lims/browser/stickers.py b/bika/lims/browser/stickers.py index 9aee59e63a..90f2fd5a2a 100644 --- a/bika/lims/browser/stickers.py +++ b/bika/lims/browser/stickers.py @@ -327,7 +327,7 @@ def pdf_from_post(self): return pdf_file def get_copies_count(self): - """Return the copies_count request paramteter + """Return the copies_count request parameter """ try: copies_count = int(self.request.form.get("copies_count", 1)) From 421e44366d905e34fedb02000cca422d82961bea Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Mon, 29 Jan 2018 13:24:25 +0100 Subject: [PATCH 05/23] Implement POST action when number of copies changes and bind it to Sticker view --- .../browser/templates/stickers_preview.pt | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/bika/lims/browser/templates/stickers_preview.pt b/bika/lims/browser/templates/stickers_preview.pt index 86a03a5bd2..6cdd5f3dc9 100644 --- a/bika/lims/browser/templates/stickers_preview.pt +++ b/bika/lims/browser/templates/stickers_preview.pt @@ -161,6 +161,9 @@ $('select#template').change(function(e) { reload($('select#template').val()); }); + $('#copies_count').change(function(e) { + update_sticker_copies($('#copies_count').val()); + }); var stickwidth = $('.sticker').first().width(); $('#sticker-rule').css({'width':stickwidth,'max-width':stickwidth}); $('#sticker-rule').fadeIn(); @@ -190,6 +193,31 @@ }); } + /** + * Re-loads the stickers preview when the number of copies changes + */ + function update_sticker_copies(copies) { + var baseurl = $('body').attr('data-itemsurl'); + $('#stickers-wrapper').fadeTo('fast', 0.4); + $.ajax({ + url: baseurl, + type: 'POST', + async: true, + data: {"copies_count": copies} + }) + .always(function(data) { + var htmldata = data; + htmldata = $(htmldata).find('#copies_count').html(); + $('#copies_count').html(htmldata); + $('#stickers-wrapper').fadeTo('fast', 1); + // reload barcoding + bika.lims.BarcodeUtils.load(); + var stickwidth = $('.sticker').first().width(); + $('#sticker-rule').css({'width':stickwidth,'max-width':stickwidth}); + $('#sticker-rule').fadeIn(); + }); + } + function printPdf() { var url = window.location.href; // Get the stickers style @@ -240,7 +268,7 @@
- From f1a0697747172b1ce65ee2dd503025c4e089410b Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Mon, 29 Jan 2018 14:21:54 +0100 Subject: [PATCH 06/23] Add logic for showing multiple copies of stickers, update post actions to send both template and copies when changes in the form are detected. --- bika/lims/browser/stickers.py | 5 ++-- .../browser/templates/stickers_preview.pt | 26 +++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/bika/lims/browser/stickers.py b/bika/lims/browser/stickers.py index 90f2fd5a2a..916dcc8902 100644 --- a/bika/lims/browser/stickers.py +++ b/bika/lims/browser/stickers.py @@ -149,8 +149,9 @@ def _populateItems(self, item): elif portal_type == 'Batch': return [[None, None, item]] items = [] - for part in parts: - items.append([ar, sample, part]) + for copy in range(self.copies_count): + for part in parts: + items.append([ar, sample, part]) return items def getAvailableTemplates(self): diff --git a/bika/lims/browser/templates/stickers_preview.pt b/bika/lims/browser/templates/stickers_preview.pt index 6cdd5f3dc9..54122e3494 100644 --- a/bika/lims/browser/templates/stickers_preview.pt +++ b/bika/lims/browser/templates/stickers_preview.pt @@ -159,10 +159,10 @@ window.location = $(this).attr('data-url'); }); $('select#template').change(function(e) { - reload($('select#template').val()); + reload($('select#template').val(), $('#copies_count').val()); }); $('#copies_count').change(function(e) { - update_sticker_copies($('#copies_count').val()); + update_sticker_copies($('#copies_count').val(), $('select#template').val()); }); var stickwidth = $('.sticker').first().width(); $('#sticker-rule').css({'width':stickwidth,'max-width':stickwidth}); @@ -171,14 +171,14 @@ /** * Re-loads the stickers preview by using the template specified */ - function reload(template) { + function reload(template, copies_count) { var baseurl = $('body').attr('data-itemsurl'); $('#stickers-wrapper').fadeTo('fast', 0.4); $.ajax({ url: baseurl, type: 'POST', async: true, - data: {"template": template} + data: {"template": template, "copies_count": copies_count} }) .always(function(data) { var htmldata = data; @@ -196,25 +196,26 @@ /** * Re-loads the stickers preview when the number of copies changes */ - function update_sticker_copies(copies) { + function update_sticker_copies(copies, template) { var baseurl = $('body').attr('data-itemsurl'); $('#stickers-wrapper').fadeTo('fast', 0.4); $.ajax({ url: baseurl, type: 'POST', async: true, - data: {"copies_count": copies} + data: {"copies_count": copies, "template": template} }) .always(function(data) { var htmldata = data; - htmldata = $(htmldata).find('#copies_count').html(); - $('#copies_count').html(htmldata); + htmldata = $(htmldata).find('#stickers-wrapper').html(); + $('#stickers-wrapper').html(htmldata); $('#stickers-wrapper').fadeTo('fast', 1); // reload barcoding bika.lims.BarcodeUtils.load(); var stickwidth = $('.sticker').first().width(); $('#sticker-rule').css({'width':stickwidth,'max-width':stickwidth}); $('#sticker-rule').fadeIn(); + $('#stickers-wrapper').fadeIn(); }); } @@ -293,11 +294,10 @@
- -
-
+ +
+
From c7b2d3cf55ce1ce278d318c4b2dde43e41f44b85 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Mon, 29 Jan 2018 14:26:28 +0100 Subject: [PATCH 07/23] Make sticker copies of the same sample go together (group stickers by sample). --- bika/lims/browser/stickers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bika/lims/browser/stickers.py b/bika/lims/browser/stickers.py index 916dcc8902..33a4e82022 100644 --- a/bika/lims/browser/stickers.py +++ b/bika/lims/browser/stickers.py @@ -149,8 +149,8 @@ def _populateItems(self, item): elif portal_type == 'Batch': return [[None, None, item]] items = [] - for copy in range(self.copies_count): - for part in parts: + for part in parts: + for copy in range(self.copies_count): items.append([ar, sample, part]) return items From 93470ad1d4f51afc86b457a0e0e2cfa8c4203465 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Tue, 30 Jan 2018 09:58:54 +0100 Subject: [PATCH 08/23] Add field in bika set up to set the default number of copies --- bika/lims/content/bikasetup.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bika/lims/content/bikasetup.py b/bika/lims/content/bikasetup.py index 8328114ff4..811467ceff 100644 --- a/bika/lims/content/bikasetup.py +++ b/bika/lims/content/bikasetup.py @@ -735,6 +735,16 @@ def getCounterTypes(self, instance=None): description=_("Select which sticker should be used as the 'large' sticker by default") ) ), + IntegerField( + 'DefaultNumberOfCopies', + schemata="Sticker", + required="1", + default="1", + widget=IntegerWidget( + label=_("Number of copies"), + description=_("Set the default number of copies to be printed for each sticker") + ) + ), IDFormattingField( 'IDFormatting', schemata="ID Server", From 44b24949f601f92189528e2a9fe7f2a85e10ff41 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Tue, 30 Jan 2018 10:19:44 +0100 Subject: [PATCH 09/23] Class constructor and get default number of copies when first loading the view --- bika/lims/browser/stickers.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bika/lims/browser/stickers.py b/bika/lims/browser/stickers.py index 33a4e82022..104d6983b6 100644 --- a/bika/lims/browser/stickers.py +++ b/bika/lims/browser/stickers.py @@ -51,10 +51,12 @@ class Sticker(BrowserView): -- code_...mm.{css,pt} -- other_worksheet_stickers_... """ - template = ViewPageTemplateFile("templates/stickers_preview.pt") - item_index = 0 - current_item = None - rendered_items = [] + def __init__(self): + self.template = ViewPageTemplateFile("templates/stickers_preview.pt") + self.item_index = 0 + self.current_item = None + self.rendered_items = [] + self.copies_count = None def __call__(self): # Need to generate a PDF with the stickers? @@ -66,7 +68,11 @@ def __call__(self): pdfstream = self.pdf_from_post() return pdfstream - self.copies_count = self.get_copies_count() + if self.copies_count is None: + self.copies_count = self.context.bika_setup.getDefaultNumberOfCopies() + else: + self.copies_count = self.get_copies_count() + self.rendered_items = [] items = self.request.get('items', '') # If filter by type is given in the request, only the templates under From f3e615ecbdf70bf2ca33694e05b90fec0de7a3f8 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Tue, 30 Jan 2018 12:17:01 +0100 Subject: [PATCH 10/23] Corrections: 1- Get default number of copies when request is empty, else get the number from the request. 2- Correct constructor --- bika/lims/browser/stickers.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/bika/lims/browser/stickers.py b/bika/lims/browser/stickers.py index 104d6983b6..2574b8274c 100644 --- a/bika/lims/browser/stickers.py +++ b/bika/lims/browser/stickers.py @@ -51,13 +51,19 @@ class Sticker(BrowserView): -- code_...mm.{css,pt} -- other_worksheet_stickers_... """ - def __init__(self): - self.template = ViewPageTemplateFile("templates/stickers_preview.pt") + template = ViewPageTemplateFile("templates/stickers_preview.pt") + + def __init__(self, context, request): self.item_index = 0 self.current_item = None self.rendered_items = [] self.copies_count = None + self.context = context + self.request = request + + super(Sticker, self).__init__(context, request) + def __call__(self): # Need to generate a PDF with the stickers? if self.request.form.get('pdf', '0') == '1': @@ -68,10 +74,7 @@ def __call__(self): pdfstream = self.pdf_from_post() return pdfstream - if self.copies_count is None: - self.copies_count = self.context.bika_setup.getDefaultNumberOfCopies() - else: - self.copies_count = self.get_copies_count() + self.copies_count = self.get_copies_count() self.rendered_items = [] items = self.request.get('items', '') @@ -336,8 +339,8 @@ def pdf_from_post(self): def get_copies_count(self): """Return the copies_count request parameter """ - try: + if self.request.form.get('copies_count', None) is None: + copies_count = self.context.bika_setup.getDefaultNumberOfCopies() + else: copies_count = int(self.request.form.get("copies_count", 1)) - except (TypeError, ValueError): - copies_count = 1 return copies_count From ccc587a9e1bcac920dbe2099319f32b5dbde6427 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Tue, 30 Jan 2018 12:23:51 +0100 Subject: [PATCH 11/23] modify method to get number of copies --- bika/lims/browser/stickers.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bika/lims/browser/stickers.py b/bika/lims/browser/stickers.py index 2574b8274c..3252b510ce 100644 --- a/bika/lims/browser/stickers.py +++ b/bika/lims/browser/stickers.py @@ -339,8 +339,11 @@ def pdf_from_post(self): def get_copies_count(self): """Return the copies_count request parameter """ - if self.request.form.get('copies_count', None) is None: + try: + copies_count = int(self.request.form.get("copies_count")) + except (TypeError, ValueError): + # default number of copies is a mandatory integer field in bika setup + # so theoretically this should never fail copies_count = self.context.bika_setup.getDefaultNumberOfCopies() - else: - copies_count = int(self.request.form.get("copies_count", 1)) + return copies_count From 1d986b8b58be06877ab10570ab2ac18b0fb8433e Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Tue, 30 Jan 2018 12:56:56 +0100 Subject: [PATCH 12/23] Rename bika with senaite --- bika/lims/browser/stickers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bika/lims/browser/stickers.py b/bika/lims/browser/stickers.py index 3252b510ce..17e5301fa4 100644 --- a/bika/lims/browser/stickers.py +++ b/bika/lims/browser/stickers.py @@ -342,7 +342,7 @@ def get_copies_count(self): try: copies_count = int(self.request.form.get("copies_count")) except (TypeError, ValueError): - # default number of copies is a mandatory integer field in bika setup + # default number of copies is a mandatory integer field in senaite setup # so theoretically this should never fail copies_count = self.context.bika_setup.getDefaultNumberOfCopies() From c8f7656b0ef33dfe660491a3fcd97fe180156cf5 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Wed, 31 Jan 2018 09:47:35 +0100 Subject: [PATCH 13/23] Move super class constructor to the begining of the init method --- bika/lims/browser/stickers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bika/lims/browser/stickers.py b/bika/lims/browser/stickers.py index 17e5301fa4..ad8363f699 100644 --- a/bika/lims/browser/stickers.py +++ b/bika/lims/browser/stickers.py @@ -54,6 +54,8 @@ class Sticker(BrowserView): template = ViewPageTemplateFile("templates/stickers_preview.pt") def __init__(self, context, request): + super(Sticker, self).__init__(context, request) + self.item_index = 0 self.current_item = None self.rendered_items = [] @@ -62,7 +64,7 @@ def __init__(self, context, request): self.context = context self.request = request - super(Sticker, self).__init__(context, request) + def __call__(self): # Need to generate a PDF with the stickers? From 20baa51ebbac5d44bf33a820a950f52b92b9c2f6 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Wed, 31 Jan 2018 10:09:09 +0100 Subject: [PATCH 14/23] Fix typos and documentation --- bika/lims/browser/stickers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bika/lims/browser/stickers.py b/bika/lims/browser/stickers.py index ad8363f699..f773332123 100644 --- a/bika/lims/browser/stickers.py +++ b/bika/lims/browser/stickers.py @@ -318,7 +318,7 @@ def _getStickersTemplatesDirectory(self, resource_name): for the stickers deppending on the filter_by_type. :param resource_name: The name of the resource folder. :type resource_name: string - :resturns: a string as a path + :returns: a string as a path """ templates_dir =\ queryResourceDirectory('stickers', resource_name).directory @@ -339,7 +339,10 @@ def pdf_from_post(self): return pdf_file def get_copies_count(self): - """Return the copies_count request parameter + """Return the copies_count number request parameter + + :returns: the number of copies for each sticker as stated + in the request """ try: copies_count = int(self.request.form.get("copies_count")) From 0afc80072f371cffab183a8db9c36749305feeec Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Wed, 31 Jan 2018 10:17:58 +0100 Subject: [PATCH 15/23] Refactor logic of creating as many copies as stickers wanted into a new method and make it also work with Batches and Worksheets --- bika/lims/browser/stickers.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/bika/lims/browser/stickers.py b/bika/lims/browser/stickers.py index f773332123..e42ec8ed70 100644 --- a/bika/lims/browser/stickers.py +++ b/bika/lims/browser/stickers.py @@ -91,6 +91,9 @@ def __call__(self): # Default fallback, load from context self.items = [self.context, ] + # before retrieving the required data for each type of object copy + # each object as many times as the number of desired sticker copies + self.items = self._resolve_number_of_copies(self.items) new_items = [] for i in self.items: outitems = self._populateItems(i) @@ -161,8 +164,7 @@ def _populateItems(self, item): return [[None, None, item]] items = [] for part in parts: - for copy in range(self.copies_count): - items.append([ar, sample, part]) + items.append([ar, sample, part]) return items def getAvailableTemplates(self): @@ -338,6 +340,21 @@ def pdf_from_post(self): pdf_file = createPdf(htmlreport=reporthtml, outfile=pdf_fn) return pdf_file + def _resolve_number_of_copies(self, items): + """For the given objects generate as many copies as the desired + number of stickers. The desired number of stickers for each + object is given by copies_count + + :param items: list of objects whose stickers are going to be previewed. + :returns: list containing n copies of each object in the items list, + where n is self.copies_count + """ + copied_items = [] + for obj in items: + for copy in range(self.copies_count): + copied_items.append(obj) + return copied_items + def get_copies_count(self): """Return the copies_count number request parameter From 70e22f745465cf008be106143ff54fbde524482d Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Wed, 31 Jan 2018 10:21:34 +0100 Subject: [PATCH 16/23] Documentation --- bika/lims/browser/stickers.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bika/lims/browser/stickers.py b/bika/lims/browser/stickers.py index e42ec8ed70..f5c12788eb 100644 --- a/bika/lims/browser/stickers.py +++ b/bika/lims/browser/stickers.py @@ -346,8 +346,10 @@ def _resolve_number_of_copies(self, items): object is given by copies_count :param items: list of objects whose stickers are going to be previewed. + :type items: list :returns: list containing n copies of each object in the items list, where n is self.copies_count + :rtype: list """ copied_items = [] for obj in items: @@ -360,6 +362,7 @@ def get_copies_count(self): :returns: the number of copies for each sticker as stated in the request + :rtype: int """ try: copies_count = int(self.request.form.get("copies_count")) From bf217180db7d1e2cefe37bdc622376d82aad32b7 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Wed, 31 Jan 2018 10:24:35 +0100 Subject: [PATCH 17/23] Remove update_sticker_copies function since reload function provides the same functionality --- .../browser/templates/stickers_preview.pt | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/bika/lims/browser/templates/stickers_preview.pt b/bika/lims/browser/templates/stickers_preview.pt index 54122e3494..94c53c3002 100644 --- a/bika/lims/browser/templates/stickers_preview.pt +++ b/bika/lims/browser/templates/stickers_preview.pt @@ -193,32 +193,6 @@ }); } - /** - * Re-loads the stickers preview when the number of copies changes - */ - function update_sticker_copies(copies, template) { - var baseurl = $('body').attr('data-itemsurl'); - $('#stickers-wrapper').fadeTo('fast', 0.4); - $.ajax({ - url: baseurl, - type: 'POST', - async: true, - data: {"copies_count": copies, "template": template} - }) - .always(function(data) { - var htmldata = data; - htmldata = $(htmldata).find('#stickers-wrapper').html(); - $('#stickers-wrapper').html(htmldata); - $('#stickers-wrapper').fadeTo('fast', 1); - // reload barcoding - bika.lims.BarcodeUtils.load(); - var stickwidth = $('.sticker').first().width(); - $('#sticker-rule').css({'width':stickwidth,'max-width':stickwidth}); - $('#sticker-rule').fadeIn(); - $('#stickers-wrapper').fadeIn(); - }); - } - function printPdf() { var url = window.location.href; // Get the stickers style From ac805ca45d002fb747c2dc500126f649eacb636f Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Wed, 31 Jan 2018 10:26:02 +0100 Subject: [PATCH 18/23] Bind a change in the number of copies to the reload function --- bika/lims/browser/templates/stickers_preview.pt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bika/lims/browser/templates/stickers_preview.pt b/bika/lims/browser/templates/stickers_preview.pt index 94c53c3002..366ebbe026 100644 --- a/bika/lims/browser/templates/stickers_preview.pt +++ b/bika/lims/browser/templates/stickers_preview.pt @@ -162,7 +162,7 @@ reload($('select#template').val(), $('#copies_count').val()); }); $('#copies_count').change(function(e) { - update_sticker_copies($('#copies_count').val(), $('select#template').val()); + reload($('select#template').val(), $('#copies_count').val()); }); var stickwidth = $('.sticker').first().width(); $('#sticker-rule').css({'width':stickwidth,'max-width':stickwidth}); From 6dd880185a1bacd0d9687b65d9f1b22626448791 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Wed, 31 Jan 2018 10:33:23 +0100 Subject: [PATCH 19/23] Remove blank lines --- bika/lims/browser/stickers.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/bika/lims/browser/stickers.py b/bika/lims/browser/stickers.py index f5c12788eb..47ac6e4fc0 100644 --- a/bika/lims/browser/stickers.py +++ b/bika/lims/browser/stickers.py @@ -64,8 +64,6 @@ def __init__(self, context, request): self.context = context self.request = request - - def __call__(self): # Need to generate a PDF with the stickers? if self.request.form.get('pdf', '0') == '1': From 10e1e6cf00429c638bf598888e87a363640cc4d7 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Wed, 31 Jan 2018 10:51:58 +0100 Subject: [PATCH 20/23] Render stickers only of items that have a valid item_id --- bika/lims/browser/templates/stickers_preview.pt | 1 + 1 file changed, 1 insertion(+) diff --git a/bika/lims/browser/templates/stickers_preview.pt b/bika/lims/browser/templates/stickers_preview.pt index 366ebbe026..29b639db41 100644 --- a/bika/lims/browser/templates/stickers_preview.pt +++ b/bika/lims/browser/templates/stickers_preview.pt @@ -270,6 +270,7 @@
From a50cb45d1e4f91ffc1df5c2ab661e5c662fa35a3 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Wed, 31 Jan 2018 11:03:20 +0100 Subject: [PATCH 21/23] Remove rendered_items variable from code since it is no longer used --- bika/lims/browser/stickers.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bika/lims/browser/stickers.py b/bika/lims/browser/stickers.py index 47ac6e4fc0..e8df00db79 100644 --- a/bika/lims/browser/stickers.py +++ b/bika/lims/browser/stickers.py @@ -58,7 +58,6 @@ def __init__(self, context, request): self.item_index = 0 self.current_item = None - self.rendered_items = [] self.copies_count = None self.context = context @@ -76,7 +75,6 @@ def __call__(self): self.copies_count = self.get_copies_count() - self.rendered_items = [] items = self.request.get('items', '') # If filter by type is given in the request, only the templates under # the path with the type name will be given as vocabulary. @@ -256,9 +254,7 @@ def nextItem(self): """ if self.item_index == len(self.items): self.item_index = 0 - self.rendered_items = [] self.current_item = self.items[self.item_index] - self.rendered_items.append(self.current_item[2].getId()) self.item_index += 1 return self.current_item From 372527d3144eea3d230311a522c2e9ac018639c2 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Wed, 31 Jan 2018 11:06:13 +0100 Subject: [PATCH 22/23] Remove blank lines --- bika/lims/browser/stickers.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/bika/lims/browser/stickers.py b/bika/lims/browser/stickers.py index e8df00db79..a4a04e2ab0 100644 --- a/bika/lims/browser/stickers.py +++ b/bika/lims/browser/stickers.py @@ -55,11 +55,9 @@ class Sticker(BrowserView): def __init__(self, context, request): super(Sticker, self).__init__(context, request) - self.item_index = 0 self.current_item = None self.copies_count = None - self.context = context self.request = request From 99cad8afac82470453fff86d67cdabfca09e91f0 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Wed, 31 Jan 2018 11:45:48 +0100 Subject: [PATCH 23/23] Update Changes log --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 47fbc39051..a9eb7de22b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,8 @@ Changelog **Added** +- #618 When previewing stickers the number of copies to print for each sticker can be modified. +- #618 The default number of sticker copies can be set and edited in the setup Sticker's tab. **Removed**