Skip to content

Commit 33a559a

Browse files
authored
[LIMS-1693] Improve tracking label (#2)
* Improve tracking label Only display instructions once per set of labels, only display 2 first lab contacts * Fix tests * Tracking label layout tweaks
1 parent 2876147 commit 33a559a

File tree

2 files changed

+34
-27
lines changed

2 files changed

+34
-27
lines changed

src/scaup/assets/text.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
LABEL_INSTRUCTIONS_STEP_1 = "Print tracking labels, and affix one of them to the dewar"
1+
LABEL_INSTRUCTIONS_STEP_1 = (
2+
"Print tracking labels, and affix one of them to the dewar. If you're sending multiple "
3+
+ "dewars, ensure the dewar code on the label matches the dewar code on the dewar."
4+
)
25

36
LABEL_INSTRUCTIONS_STEP_2 = "Affix the other label to the dewar case"
47

src/scaup/crud/pdf.py

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,31 @@ def __init__(
120120
self.from_lines = from_lines
121121
self.to_lines = to_lines
122122

123+
# Only display two first local contacts, to save space
124+
if len(lcs := local_contact.split(",")) > 2:
125+
self.local_contact = f"{', '.join(lcs[:2])} + {len(lcs) - 2}"
126+
127+
self.add_page()
128+
129+
# Label instructions
130+
self.image(DIAMOND_LOGO, x="L", y=7, h=15)
131+
self.set_font("helvetica", size=26, style="B")
132+
self.cell(align="R", w=0, text="Instructions", h=15, new_x="LMARGIN")
133+
134+
self.set_y(30)
135+
136+
self.add_instruction_title("1. Affix to dewar")
137+
self.add_instruction_text(LABEL_INSTRUCTIONS_STEP_1)
138+
139+
self.add_instruction_title("2. Affix to dewar case")
140+
self.add_instruction_text(LABEL_INSTRUCTIONS_STEP_2)
141+
142+
self.add_instruction_title("3. Affix airway bill to dewar case")
143+
self.add_instruction_text(LABEL_INSTRUCTIONS_STEP_3)
144+
145+
self.add_instruction_title("4. Request return at the end of your session")
146+
self.add_instruction_text(LABEL_INSTRUCTIONS_STEP_4)
147+
123148
def add_instruction_title(self, text: str):
124149
self.set_font("helvetica", size=26, style="B")
125150
self.cell(
@@ -162,33 +187,12 @@ def add_dewar(self, dewar: Row):
162187
("Printed", str(date.today())),
163188
)
164189

165-
self.add_page()
166-
167-
# Label instructions
168-
self.image(DIAMOND_LOGO, x="L", y=7, h=15)
169-
self.set_font("helvetica", size=26, style="B")
170-
self.cell(align="R", w=0, text="Instructions", h=15, new_x="LMARGIN")
171-
172-
self.set_y(30)
173-
174-
self.add_instruction_title("1. Affix to dewar")
175-
self.add_instruction_text(LABEL_INSTRUCTIONS_STEP_1)
176-
177-
self.add_instruction_title("2. Affix to dewar case")
178-
self.add_instruction_text(LABEL_INSTRUCTIONS_STEP_2)
179-
180-
self.add_instruction_title("3. Affix airway bill to dewar case")
181-
self.add_instruction_text(LABEL_INSTRUCTIONS_STEP_3)
182-
183-
self.add_instruction_title("4. Request return at the end of your session")
184-
self.add_instruction_text(LABEL_INSTRUCTIONS_STEP_4)
185-
186190
if self.from_lines is None:
187191
self.add_page()
188-
self.image(CUT_HERE, x="L", y=140, w=194)
192+
self.image(CUT_HERE, x="L", y=139, w=194)
189193

190194
# If we don't have an address, display both labels in a single page
191-
offset_values = [10, 145] if self.from_lines is None else [10, 10]
195+
offset_values = [0, 143] if self.from_lines is None else [10, 10]
192196

193197
# Tracking labels
194198
for i, offset in enumerate(offset_values):
@@ -238,10 +242,10 @@ def add_dewar(self, dewar: Row):
238242

239243
self.image(DIAMOND_LOGO, x="L", y=7 + offset, h=15)
240244
self.image(THIS_SIDE_UP, x="R", y=7 + offset, w=30)
241-
self.image(img, x=(self.w - 60) / 2, y=offset, h=60, w=60)
242-
self.set_y(y=58 + offset)
245+
self.image(img, x=(self.w - 60) / 2, y=offset, h=55, w=55)
246+
self.set_y(y=54 + offset)
243247
self.cell(w=0, text=str(dewar.barCode), align="C")
244-
self.set_y(65 + offset)
248+
self.set_y(60 + offset)
245249

246250
with self.table(borders_layout="HORIZONTAL_LINES", headings_style=headings_style) as pdf_table:
247251
for row in table:

0 commit comments

Comments
 (0)