Skip to content

Commit 97ee0b5

Browse files
authored
Render temporary barcodes for dewars (#6)
1 parent b3e462e commit 97ee0b5

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/scaup/assets/text.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
LABEL_INSTRUCTIONS_STEP_1 = (
22
"Print tracking labels, and affix one of them to the dewar. If you're sending multiple "
33
+ "dewars, ensure the dewar code on the label matches the dewar code on the dewar."
4+
+ "\n\nIf a dewar doesn't have a barcode (such as the ones on the last page) already, cut out "
5+
+ "the barcode on the last page and affix it to the dewar. If you're sending multiple dewars, ensure "
6+
+ "the dewar matches the barcode you've selected for it previously. \n\nIgnore the last page if "
7+
+ "you already have barcodes on your dewars."
48
)
59

610
LABEL_INSTRUCTIONS_STEP_2 = "Affix the other label to the dewar case"
@@ -16,3 +20,7 @@
1620
+ "returned to your institution. \nWhen you receive your dewar, feel free to discard any labels from the "
1721
+ "previous steps."
1822
)
23+
24+
TEMPORARY_DEWAR_TEXT = (
25+
"FOR STAFF: This is a temporary barcode. Replace it with a permanent sticker before the end of the visit."
26+
)

src/scaup/crud/pdf.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
LABEL_INSTRUCTIONS_STEP_2,
1515
LABEL_INSTRUCTIONS_STEP_3,
1616
LABEL_INSTRUCTIONS_STEP_4,
17+
TEMPORARY_DEWAR_TEXT,
1718
)
1819

1920
from ..assets.paths import (
@@ -165,6 +166,25 @@ def add_instruction_text(self, text: str):
165166
new_y="NEXT",
166167
)
167168

169+
def add_barcodes(self, dewars: List[Row]):
170+
for i, dewar in enumerate(dewars):
171+
if i % 4 == 0:
172+
y_pos = 10
173+
self.add_page()
174+
175+
self.code39("*" + dewar.code + "*", x=35, y=y_pos, w=2, h=25)
176+
177+
self.set_y(y_pos + 26)
178+
self.set_font("helvetica", size=26, style="B")
179+
self.cell(w=0, text=dewar.code, align="C", new_y="NEXT", new_x="LMARGIN")
180+
181+
self.set_font("helvetica", size=16, style="B")
182+
self.multi_cell(w=0, text=TEMPORARY_DEWAR_TEXT, align="C")
183+
184+
self.image(CUT_HERE, x="L", y=y_pos + 55, w=194)
185+
186+
y_pos += 70
187+
168188
def add_dewar(self, dewar: Row):
169189
if dewar.barCode is None or dewar.externalId is None:
170190
raise HTTPException(
@@ -313,6 +333,8 @@ def get_shipping_labels(shipment_id: int, token: str):
313333
for dewar in data:
314334
pdf.add_dewar(dewar)
315335

336+
pdf.add_barcodes(data)
337+
316338
headers = {
317339
"Content-Disposition": (
318340
"inline;"

0 commit comments

Comments
 (0)