From 5aafd9ee9184469d419a98dd06a54e75c74244a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cau=C3=AA=20Faleiros?=
Date: Mon, 9 Nov 2026 10:45:43 -0300
Subject: [PATCH] fix: review of phase-2 stage 0 and fronts 5, 6 and 11
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- A paid treatment adds its 24 h to Arte recebida's acceptable time, on
the card and in Números (fronts 5 and 11).
- TINY_PRODUCT_TREATMENT is a required Tiny setting once the treatment
has a price, instead of every treated order failing at the Tiny.
- A quote reads each PDF once: Files caches the header and the DPI.
- A proof made from the parent's final split into parts uses the part
that holds the finest stroke, not the last one (0.1).
- Prumo report: one format line per item, the time from the claim (kept
on the finished print file), and the stroke class in customer words.
- The Site says the Prumo checks the art, and a too-tall PNG no longer
says "Este PDF".
Co-Authored-By: Claude Opus 5.5
---
app/api/operator.py | 24 +++++++++++---
app/grade_check.py | 27 +++++++++++-----
app/printjobs.py | 65 ++++++++++++++++++++++++++++++++------
app/prumo.py | 26 +++++++++++----
app/tiny.py | 9 +++++-
tests/stage_limits_test.py | 15 ++++++++-
tests/test_grade_check.py | 33 +++++++++++++++++++
tests/test_proof_cut.py | 16 ++++++++++
tests/test_prumo.py | 28 ++++++++++++++--
tests/test_tiny.py | 11 +++++++
web/site-pdf.js | 10 +++---
11 files changed, 227 insertions(+), 37 deletions(-)
diff --git a/app/api/operator.py b/app/api/operator.py
index 9410471..8e675c1 100644
--- a/app/api/operator.py
+++ b/app/api/operator.py
@@ -262,6 +262,10 @@ def assign_late(c, orders, limits):
since = since or order['created_at']
hours = max(0.0, (now - since).total_seconds() / 3600)
limit_hours = float(limit['hours'])
+ # A paid treatment gives Art received its extra hours to prepare the art.
+ treatment = (order.get('snapshot') or {}).get('treatment') or {}
+ if order['state'] == 'rec' and treatment:
+ limit_hours += float(treatment.get('hours', 24))
order['state_hours'] = round(hours, 2)
order['limit_hours'] = limit_hours
order['limit_by'] = limit['responsible']
@@ -1426,10 +1430,14 @@ def production_stats(days: int | None = Query(default=None, ge=7, le=365), start
FROM dtf_local.orders o WHERE {REAL_ORDER} AND o.state<>'fin' GROUP BY o.state''').fetchall()
# Passages past each stage's acceptable time (front 11), in the
# selected period and today.
- late_rows = c.execute(f'''SELECT state,
- extract(epoch FROM until-at) - {waited('s.id', 's.at', 's.until')} AS seconds,
- (until AT TIME ZONE 'America/Sao_Paulo')::date AS day
- FROM ({spans}) s WHERE until IS NOT NULL''', period + period).fetchall()
+ # Each passage carries whether its order paid for treatment, which only
+ # Art received counts (front 5).
+ late_rows = c.execute(f'''SELECT s.state,
+ extract(epoch FROM s.until-s.at) - {waited('s.id', 's.at', 's.until')} AS seconds,
+ (s.until AT TIME ZONE 'America/Sao_Paulo')::date AS day,
+ o.snapshot->'treatment' AS treatment
+ FROM ({spans}) s LEFT JOIN dtf_local.orders o ON o.id=s.id WHERE s.until IS NOT NULL''',
+ period + period).fetchall()
printed = machine_output(c, start, end)
# Rework of the period (D-02 to D-04): the authorized ones, by the day
# they were opened, over the film the machines printed in it.
@@ -1513,7 +1521,13 @@ def production_stats(days: int | None = Query(default=None, ge=7, le=365), start
late = {state: {'count': 0, 'today': 0} for state in ('rec', 'tra', 'imp', 'rev', 'fin')}
for row in late_rows:
limit = limits.get(row['state'])
- if limit and row['seconds'] > limit['hours'] * 3600:
+ if not limit:
+ continue
+ hours = float(limit['hours'])
+ treatment = row.get('treatment') or {}
+ if row['state'] == 'rec' and treatment:
+ hours += float(treatment.get('hours', 24))
+ if row['seconds'] > hours * 3600:
late[row['state']]['count'] += 1
if row['day'] == today:
late[row['state']]['today'] += 1
diff --git a/app/grade_check.py b/app/grade_check.py
index b0cd2dc..6c46521 100644
--- a/app/grade_check.py
+++ b/app/grade_check.py
@@ -135,18 +135,29 @@ class Files:
def __init__(self, storage):
self.storage = storage
+ # A PDF is read once per quote: source_dpi, resolution_issue and
+ # mismatch all ask for the same files.
+ self._heads = {}
+ self._dpis = {}
def head(self, row):
- return self.storage.client.get_object(Bucket=self.storage.bucket, Key=row['object_key'],
- Range=f'bytes=0-{HEAD_BYTES - 1}')['Body'].read()
+ key = row['object_key']
+ if key not in self._heads:
+ self._heads[key] = self.storage.client.get_object(
+ Bucket=self.storage.bucket, Key=key, Range=f'bytes=0-{HEAD_BYTES - 1}')['Body'].read()
+ return self._heads[key]
def pdf_dpi(self, row):
- if row['size'] > PDF_MAX_BYTES:
- return None
- with tempfile.NamedTemporaryFile(suffix='.pdf') as handle:
- self.storage.client.download_fileobj(self.storage.bucket, row['object_key'], handle)
- handle.flush()
- return pdf_dpi(handle.name)
+ key = row['object_key']
+ if key not in self._dpis:
+ if row['size'] > PDF_MAX_BYTES:
+ self._dpis[key] = None
+ else:
+ with tempfile.NamedTemporaryFile(suffix='.pdf') as handle:
+ self.storage.client.download_fileobj(self.storage.bucket, key, handle)
+ handle.flush()
+ self._dpis[key] = pdf_dpi(handle.name)
+ return self._dpis[key]
def source_dpi(files, row, source):
diff --git a/app/printjobs.py b/app/printjobs.py
index 0c16a3e..1956d39 100644
--- a/app/printjobs.py
+++ b/app/printjobs.py
@@ -16,6 +16,7 @@ Sheets of several GB are the normal order: a PNG or a PDF is read band by
band, so its size does not matter. Any other file above LARGE_SOURCE_BYTES
is prepared by hand from the original.
"""
+import io
import logging
import multiprocessing
import os
@@ -53,6 +54,36 @@ def generated_identity(order_id):
return uuid5(NAMESPACE_URL, f'dtf-print-file:{order_id}')
+def proof_part(heights_cm, original_height_cm, fraction):
+ """Which part of a split final holds the finest stroke, and where inside it.
+
+ `heights_cm` are the parts' heights in order, `fraction` the stroke's
+ position on the original film (0 at the top, 1 at the bottom). A single
+ part returns the same fraction, as before.
+ """
+ heights = [float(height) for height in heights_cm]
+ if not heights:
+ return 0, 0.0
+ position = min(1.0, max(0.0, float(fraction or 0))) * float(original_height_cm)
+ start = 0.0
+ for index, height in enumerate(heights):
+ end = start + height
+ if position <= end or index == len(heights) - 1:
+ inside = (position - start) / height if height > 0 else 0.0
+ return index, min(1.0, max(0.0, inside))
+ start = end
+ return len(heights) - 1, 1.0
+
+
+def png_height_cm(storage, row):
+ """A PNG's height in cm at 300 DPI, from its header alone (a Range read)."""
+ head = storage.client.get_object(Bucket=storage.bucket, Key=row['object_key'],
+ Range='bytes=0-65535')['Body'].read()
+ with Image.open(io.BytesIO(head)) as image:
+ height_px = image.size[1]
+ return float(Decimal(height_px) * Decimal('2.54') / Decimal(300))
+
+
def queue(c, order_id, items, only_missing=False):
"""Queue (or re-queue) generation for every item of an order."""
for index in range(items):
@@ -123,15 +154,26 @@ def render_one(storage):
item = job['snapshot']['items'][job['item_index']]
source_ids = [UUID(u) for u in item['uploads']]
# A format such as CDR needs a human to prepare the full-size final on
- # the parent. The child still generates its own 15 cm proof from that PNG.
+ # the parent. The child still generates its own 15 cm proof from that PNG,
+ # or from the part of it that holds the finest stroke when the film was
+ # cut into parts (item 13).
if job['parent_id']:
- source = c.execute('''SELECT u.id FROM dtf_local.order_files f
+ finals = c.execute('''SELECT u.id,u.object_key FROM dtf_local.order_files f
JOIN dtf_local.uploads u ON u.id=f.upload_id
+ LEFT JOIN dtf_local.print_parts p ON p.order_id=f.order_id
+ AND p.item_index=f.item_index AND p.upload_id=f.upload_id
WHERE f.order_id=%s AND f.item_index=%s AND f.kind='final' AND f.active
AND u.purged_at IS NULL AND u.expires_at>now()
- ORDER BY f.created_at DESC LIMIT 1''',
- (job['parent_id'], item['proof_parent_item_index'])).fetchone()
- if source:
+ ORDER BY p.part NULLS LAST, f.created_at''',
+ (job['parent_id'], item['proof_parent_item_index'])).fetchall()
+ if finals:
+ source = finals[0]
+ if len(finals) > 1:
+ heights = [png_height_cm(storage, row) for row in finals]
+ index, fraction = proof_part(heights, item['production']['height_cm'],
+ item.get('proof_y_fraction'))
+ source = finals[index]
+ job['proof_fraction'] = fraction
source_ids = [source['id']]
item = {**item, 'uploads': [str(source['id'])]}
job['proof_fallback'] = True
@@ -194,8 +236,9 @@ def render_one(storage):
expires_at,scan_state,scan_reason,scanned_at)
VALUES(%s,%s,%s,%s,%s,'',true,%s,'clean','generated from scanned artwork',now())''',
(uid, generated_identity(job['order_id']), name, size, key, expiry))
+ # claimed_at stays: the Prumo report measures generation from the claim.
c.execute('''UPDATE dtf_local.print_files SET status='ready', upload_id=%s, detail=%s,
- finished_at=now(),claim_token=NULL,claimed_at=NULL WHERE id=%s''', (stored[0][0], Jsonb(detail), job['id']))
+ finished_at=now(),claim_token=NULL WHERE id=%s''', (stored[0][0], Jsonb(detail), job['id']))
c.execute('DELETE FROM dtf_local.print_parts WHERE order_id=%s AND item_index=%s',
(job['order_id'], job['item_index']))
for number, (uid, _, _, _) in enumerate(stored, 1):
@@ -274,11 +317,15 @@ def produce(storage, job, item, uploads):
width_px, height_px = final.size
width_cm = float(Decimal(width_px) * Decimal('2.54') / Decimal(300))
height_cm = float(Decimal(height_px) * Decimal('2.54') / Decimal(300))
- original_height = float(item['production']['height_cm'])
- fraction = float(item.get('proof_y_fraction') or 0)
+ if job.get('proof_fraction') is not None:
+ # Already relative to the chosen part (proof_part).
+ fraction = float(job['proof_fraction'])
+ else:
+ original_height = float(item['production']['height_cm'])
+ fraction = min(1, float(item.get('proof_y_fraction') or 0) * original_height / height_cm)
source = {'kind': 'sheet', 'width_cm': width_cm, 'length_cm': height_cm,
'copies': 1, 'rotation_degrees': 0, 'mirrored': False, 'measurement': 'file'}
- item = {**item, 'proof_y_fraction': min(1, fraction * original_height / height_cm),
+ item = {**item, 'proof_y_fraction': fraction,
'production': {'version': 3, 'film_width_cm': width_cm,
'height_cm': height_cm, 'sources': [source],
'placements': [{'source_index': 0, 'copy_index': 0,
diff --git a/app/prumo.py b/app/prumo.py
index 9d807d4..d10f27f 100644
--- a/app/prumo.py
+++ b/app/prumo.py
@@ -10,6 +10,12 @@ from zoneinfo import ZoneInfo
LOCAL = ZoneInfo('America/Sao_Paulo')
MANUAL = {'cdr', 'psd', 'psb', 'tif', 'tiff'}
+# The stroke class in the customer's words, without the internal C1/C2/C3 code.
+STROKE_SUMMARY = {
+ 'C1': 'Sua arte tem traços muito finos; a impressão foi ajustada para eles.',
+ 'C2': 'Sua arte tem traços médios; a impressão foi ajustada para eles.',
+ 'C3': 'Sua arte tem áreas cheias; a impressão foi ajustada para elas.',
+}
def _ext(name):
@@ -64,8 +70,14 @@ def report(order, uploads):
names.append(final)
if original and final and _ext(original) != _ext(final):
lines.append(f'{lead}Chegou {_ext(original).upper()}, era {_ext(final).upper()} por dentro — tratado como {_ext(final).upper()}')
- else:
- lines.append(f'{lead}Formato detectado: {_ext(final).upper() or "desconhecido"}')
+ # One format line per item, not one per file: the designer reads what
+ # the item is, and only the files that changed are named above.
+ formats = sorted({_ext(name).upper() or 'desconhecido' for name in names})
+ if len(formats) == 1:
+ count = f' ({len(names)} arquivos)' if len(names) > 1 else ''
+ lines.append(f'{lead}Formato detectado: {formats[0]}{count}')
+ elif formats:
+ lines.append(f'{lead}Formatos detectados: {", ".join(formats)}')
exts = {_ext(name) for name in names}
row = generated.get(index)
ready = bool(row and row.get('status') == 'ready')
@@ -109,8 +121,10 @@ def report(order, uploads):
sizes = [Decimal(str(p.get('to_cm', 0))) - Decimal(str(p.get('from_cm', 0))) for p in parts]
lines.append(f'{lead}{_m(billed)} m → {len(parts)} partes (' +
' + '.join(_m(size) for size in sizes) + ')')
- if ready and row.get('finished_at') and row.get('created_at'):
- seconds = (row['finished_at'] - row['created_at']).total_seconds()
+ # From the claim, not from the queue: the customer waits for the
+ # generation, not for the file's turn.
+ if ready and row.get('finished_at') and row.get('claimed_at'):
+ seconds = (row['finished_at'] - row['claimed_at']).total_seconds()
lines.append(f'{lead}Prumo levou {max(1, round(seconds))} s')
return lines
@@ -127,8 +141,8 @@ def customer_summary(items):
if dots:
lines.append(f'{lead}Há {dots} pontinho{"s" if dots > 1 else ""} solto{"s" if dots > 1 else ""} '
'que você aceitou imprimir.')
- if item.get('stroke_class'):
- lines.append(f'{lead}O traço mais fino foi medido em {item["stroke_class"]}.')
+ if item.get('stroke_class') in STROKE_SUMMARY:
+ lines.append(f'{lead}{STROKE_SUMMARY[item["stroke_class"]]}')
if item.get('stroke_choice') == 'measured':
lines.append(f'{lead}Você escolheu imprimir o traço fino assim mesmo (C1).')
elif item.get('stroke_choice') == 'client_c3':
diff --git a/app/tiny.py b/app/tiny.py
index 4ceb847..9c393a6 100644
--- a/app/tiny.py
+++ b/app/tiny.py
@@ -51,6 +51,8 @@ from urllib.parse import urlencode
import httpx
+from .core.pricing import treatment_cents
+
API = 'https://api.tiny.com.br/public-api/v3'
AUTH = 'https://accounts.tiny.com.br/realms/tiny/protocol/openid-connect'
# Not TINY_PRODUCT_: app/core/secrets.py reads any variable ending in
@@ -166,8 +168,13 @@ def configured():
def required_settings():
"""The OAuth application, and a product id for each mode not sold by SKU."""
- return ['TINY_CLIENT_ID', 'TINY_CLIENT_SECRET', 'TINY_REDIRECT_URI'] + [
+ required = ['TINY_CLIENT_ID', 'TINY_CLIENT_SECRET', 'TINY_REDIRECT_URI'] + [
setting for mode, setting in PRODUCT_SETTINGS.items() if not (sku_prefix(mode) or step_sku(mode))]
+ # A paid treatment is a line of its own: missing, every treated order would
+ # fail at the Tiny, so ask for it with the rest of the settings.
+ if treatment_cents() > 0:
+ required.append('TINY_PRODUCT_TREATMENT')
+ return required
# The stack passes every setting, empty when unset, so empty means "the
diff --git a/tests/stage_limits_test.py b/tests/stage_limits_test.py
index 88d75a0..283cad8 100644
--- a/tests/stage_limits_test.py
+++ b/tests/stage_limits_test.py
@@ -36,7 +36,20 @@ def run():
board = client.call('/operator/board', operator=True)
mine = next(o for o in board['orders'] if o['id'] == str(order))
assert mine['late'] == 'bad' and mine['limit_hours'] == 1, mine
- print('PASS: stage limits are editable and a card past the limit is yellow/red')
+ # A paid treatment gives Art received its extra hours (front 5).
+ with db.connect() as c:
+ c.execute('UPDATE dtf_local.orders SET snapshot = snapshot || %s WHERE id=%s',
+ (Jsonb({'treatment': {'cents': 990, 'hours': 3}}), order))
+ board = client.call('/operator/board', operator=True)
+ mine = next(o for o in board['orders'] if o['id'] == str(order))
+ assert mine['late'] is None and mine['limit_hours'] == 4, mine
+ with db.connect() as c:
+ c.execute("UPDATE dtf_local.orders SET snapshot = snapshot - 'treatment' WHERE id=%s", (order,))
+ board = client.call('/operator/board', operator=True)
+ mine = next(o for o in board['orders'] if o['id'] == str(order))
+ assert mine['late'] == 'bad' and mine['limit_hours'] == 1, mine
+ print('PASS: stage limits are editable, a card past the limit is yellow/red, '
+ 'and a paid treatment adds its hours')
finally:
client.call('/operator/stage-limits', {'limits': defaults}, operator=True)
with db.connect() as c:
diff --git a/tests/test_grade_check.py b/tests/test_grade_check.py
index e616dc3..70aafba 100644
--- a/tests/test_grade_check.py
+++ b/tests/test_grade_check.py
@@ -5,6 +5,7 @@ Runs where Pillow and pikepdf are installed (the API image).
import io
import tempfile
import unittest
+from unittest import mock
import pikepdf
from PIL import Image
@@ -26,6 +27,25 @@ class FakeFiles:
return grade_check.pdf_dpi(handle.name)
+class CountingStorage:
+ """A storage that counts every read, keyed by object_key as the real one."""
+
+ def __init__(self, blobs):
+ self.bucket = 'bucket'
+ self.blobs = blobs
+ self.downloads = 0
+ self.heads = 0
+ self.client = self
+
+ def get_object(self, Bucket, Key, Range=None):
+ self.heads += 1
+ return {'Body': io.BytesIO(self.blobs[Key][:grade_check.HEAD_BYTES])}
+
+ def download_fileobj(self, bucket, key, handle):
+ self.downloads += 1
+ handle.write(self.blobs[key])
+
+
def encoded(fmt, size, **options):
out = io.BytesIO()
Image.new('RGBA' if fmt in ('PNG', 'WEBP') else 'RGB', size, (200, 30, 30)).save(out, fmt, **options)
@@ -81,6 +101,19 @@ class GradeCheckTests(unittest.TestCase):
self.assertEqual(claim(40, [('x.cdr', 57, 0)]), 'Nota não conferida no servidor')
self.assertIsNone(claim(0, [('x.cdr', 57, 0)]))
+ def test_a_file_is_read_once_per_quote(self):
+ storage = CountingStorage({'k.pdf': b'%PDF-1.4 test', 'k.png': encoded('PNG', (100, 50))})
+ files = grade_check.Files(storage)
+ pdf_row = {'object_key': 'k.pdf', 'size': 15, 'name': 'a.pdf'}
+ with mock.patch.object(grade_check, 'pdf_dpi', return_value=300):
+ self.assertEqual(files.pdf_dpi(pdf_row), 300)
+ self.assertEqual(files.pdf_dpi(pdf_row), 300)
+ self.assertEqual(storage.downloads, 1)
+ png_row = {'object_key': 'k.png', 'size': 1, 'name': 'a.png'}
+ self.assertEqual(files.head(png_row)[:8], b'\x89PNG\r\n\x1a\n')
+ self.assertEqual(files.head(png_row)[:8], b'\x89PNG\r\n\x1a\n')
+ self.assertEqual(storage.heads, 1)
+
def test_resolution_boundaries_and_consent(self):
width = lambda dpi: int(dpi * 57 / 2.54) + 1
files = FakeFiles({f'{dpi}.png': encoded('PNG', (width(dpi), 20))
diff --git a/tests/test_proof_cut.py b/tests/test_proof_cut.py
index b9e8ad0..29a628e 100644
--- a/tests/test_proof_cut.py
+++ b/tests/test_proof_cut.py
@@ -2,9 +2,25 @@
import unittest
from decimal import Decimal
+from app.printjobs import proof_part
from app.printpng import proof_cut
+class ProofPartTests(unittest.TestCase):
+ def test_one_part_keeps_the_same_fraction(self):
+ self.assertEqual(proof_part([100], 100, 0.5), (0, 0.5))
+ self.assertEqual(proof_part([30], 30, 0.8), (0, 0.8))
+
+ def test_the_part_holding_the_finest_stroke_is_chosen(self):
+ self.assertEqual(proof_part([1000, 1000, 1000], 3000, 0.1), (0, 0.3))
+ self.assertEqual(proof_part([1000, 1000, 1000], 3000, 0.5), (1, 0.5))
+ self.assertEqual(proof_part([1000, 1000, 1000], 3000, 0.75), (2, 0.25))
+
+ def test_the_fraction_is_recalculated_inside_the_chosen_part(self):
+ self.assertEqual(proof_part([1500, 1500], 3000, 0.75), (1, 0.5))
+ self.assertEqual(proof_part([1500, 1500], 3000, 1), (1, 1))
+
+
class ProofCutTests(unittest.TestCase):
def test_centres_the_window_on_the_finest_stroke(self):
self.assertEqual(proof_cut(100, 15, 0.5), [Decimal('42.5'), Decimal('57.5')])
diff --git a/tests/test_prumo.py b/tests/test_prumo.py
index fb7cb9b..8f538d3 100644
--- a/tests/test_prumo.py
+++ b/tests/test_prumo.py
@@ -17,7 +17,8 @@ class PrumoReportTests(unittest.TestCase):
}
started = datetime(2026, 11, 5, 14, 0, tzinfo=timezone.utc)
return {'snapshot': {'items': [item]}, 'print_files': [{
- 'item_index': 0, 'status': 'ready', 'created_at': started, 'finished_at': started + timedelta(seconds=41),
+ 'item_index': 0, 'status': 'ready', 'created_at': started - timedelta(minutes=5),
+ 'claimed_at': started, 'finished_at': started + timedelta(seconds=41),
'detail': {'format': 'png', 'dpi': 300, 'parts': [
{'from_cm': '0', 'to_cm': '15'}, {'from_cm': '15', 'to_cm': '16'}]},
}]}
@@ -34,13 +35,36 @@ class PrumoReportTests(unittest.TestCase):
self.assertIn('cliente escolheu imprimir em C1', text)
self.assertIn('2 partes (15,00 + 1,00)', text)
self.assertIn('Prumo levou 41 s', text)
+ self.assertNotIn('Prumo levou 341 s', text)
+
+ def test_without_a_claim_time_the_generation_line_is_hidden(self):
+ order = self.order()
+ del order['print_files'][0]['claimed_at']
+ text = '\n'.join(report(order, {'u1': {'name': 'arte.pdf', 'original_name': 'arte.cdr'}}))
+ self.assertNotIn('Prumo levou', text)
+
+ def test_one_format_line_per_item(self):
+ order = self.order()
+ item = order['snapshot']['items'][0]
+ item['uploads'] = ['u1', 'u2', 'u3']
+ uploads = {uid: {'name': f'arte-{uid}.png'} for uid in item['uploads']}
+ text = '\n'.join(report(order, uploads))
+ self.assertEqual(text.count('Formato detectado'), 1)
+ self.assertIn('Formato detectado: PNG (3 arquivos)', text)
+ # Mixed formats name them once, sorted, and the per-file changes stay.
+ uploads['u2'] = {'name': 'arte-u2.pdf', 'original_name': 'arte-u2.cdr'}
+ mixed = '\n'.join(report(order, uploads))
+ self.assertEqual(mixed.count('Formatos detectados'), 1)
+ self.assertIn('Formatos detectados: PDF, PNG', mixed)
+ self.assertIn('Chegou CDR, era PDF por dentro', mixed)
def test_customer_summary_is_plain_language(self):
lines = customer_summary(self.order()['snapshot']['items'])
text = ' '.join(lines)
self.assertIn('96 DPI', text)
self.assertIn('3 pontinhos', text)
- self.assertIn('C2', text)
+ self.assertIn('Sua arte tem traços médios; a impressão foi ajustada para eles.', text)
+ self.assertNotIn('O traço mais fino foi medido em C2.', text)
self.assertIn('C1', text)
self.assertIn('será preparado', text)
self.assertNotIn('foi ampliada', text)
diff --git a/tests/test_tiny.py b/tests/test_tiny.py
index 198313c..962e43f 100644
--- a/tests/test_tiny.py
+++ b/tests/test_tiny.py
@@ -801,5 +801,16 @@ class DefaultSkuTests(unittest.TestCase):
self.assertEqual(tiny.mode_codes('uvfile'), tiny.sku_codes('UV.P'))
+class TreatmentSettingTests(unittest.TestCase):
+ """A paid treatment needs its own Tiny product, asked with the rest."""
+
+ def test_the_treatment_product_is_required_only_when_it_is_paid(self):
+ from app.tiny import required_settings
+ with mock.patch.dict(os.environ, {'TREATMENT_CENTS': '0'}):
+ self.assertNotIn('TINY_PRODUCT_TREATMENT', required_settings())
+ with mock.patch.dict(os.environ, {'TREATMENT_CENTS': '5000'}):
+ self.assertIn('TINY_PRODUCT_TREATMENT', required_settings())
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/web/site-pdf.js b/web/site-pdf.js
index 3c48026..1a010ba 100644
--- a/web/site-pdf.js
+++ b/web/site-pdf.js
@@ -407,8 +407,8 @@ function medirFolha(file){
function textoProgresso(x){
const tempo=x.analiseInicio?' · '+segundosDesde(x.analiseInicio)+' s':'';
- if(x.med && x.med.grande) return 'gerando a prévia e conferindo a arte · '+faltaLeitura(x.leitura)+tempo;
- return (x.pct<50?'lendo o arquivo…':x.pct<70?'medindo a folha…':'conferindo a arte…')+tempo;
+ if(x.med && x.med.grande) return 'o Prumo está gerando a prévia e conferindo a arte · '+faltaLeitura(x.leitura)+tempo;
+ return (x.pct<50?'lendo o arquivo…':x.pct<70?'medindo a folha…':'o Prumo está conferindo a arte…')+tempo;
}
// The file card's thumbnail (52 x 96 px, drawn at twice that for sharp screens).
// At 480 x 720 it is the picture the Kanban shows of the order (checkout.js).
@@ -490,9 +490,9 @@ function detalhesDaFolha(a,i,aberto){
: [a.artes+' peça'+(a.artes===1?'':'s')+' · '+a.aproveitamento+'% da folha com arte',
'Resolução '+a.dpi+' DPI · '+(a.fonteDpi==='imagens'? 'medida imagem por imagem dentro do PDF'
: a.fonteDpi==='vetor'? 'arte vetorial, sem imagem embutida' : 'lida do arquivo'),
- 'Conferido numa grade de '+n1(a.grade)+' mm'];
+ 'Conferido pelo Prumo numa grade de '+n1(a.grade)+' mm'];
return ''+
- 'Ver detalhes da conferência
'+
+ 'Ver o que o Prumo conferiu
'+
linhas.map(l=>''+l+'').join('')+' ';
}
function pintaFolha(){
@@ -534,7 +534,7 @@ function pintaFolha(){
: ' Remonte a folha em '+n1(L)+' cm e suba de novo.')+'
':'');
}else if(x.measurementError){
medida=''+escapeHTML(extDe(x.f.name))+' · '+fmt(x.f.size)+''+
- 'Este PDF não pode ser orçado. '+escapeHTML(x.measurementError)+'
';
+ 'Este arquivo não pode ser orçado. '+escapeHTML(x.measurementError)+'
';
}else{
// Só a abertura manual muda o metro (TAXA_MANUAL); a nota não mexe no preço.
const dif=(x.m>0)? TAXA_MANUAL*cobrar(x.m*(x.rep||1)) : 0;