feat: the site's third-round corrections on acceptance, DPI and the final file

Residue and thin strokes can be accepted on ready sheets and loose art,
with the consent and its time kept on the order. The resolution rule is
96/200 DPI, and a final file must be a transparent 300 DPI PNG. The art
score leaves the customer's cart and buy box (Dropstar, 2026-11-05).
This commit is contained in:
Cauê Faleiros
2026-11-06 10:41:14 -03:00
parent 94f1bfa733
commit 0fc01315c7
13 changed files with 135 additions and 54 deletions

View File

@@ -23,7 +23,9 @@ import os
import struct
import tempfile
DPI_IDEAL = 300
DPI_IDEAL = 200
DPI_REFUSE = 96
PDF_VECTOR_DPI = 300
# The Site analyses PDFs up to 150 MB (GRANDE_BYTES); above that it does not
# grade them, so neither does this.
PDF_MAX_BYTES = 150 * 1048576
@@ -123,7 +125,7 @@ def pdf_dpi(path):
return None
found = [(dpi, area) for dpi, area in found if dpi > 0]
if not found:
return DPI_IDEAL
return PDF_VECTOR_DPI
total = sum(area for _, area in found) or 1
return js_round(sum(dpi * area for dpi, area in found) / total)
@@ -178,6 +180,31 @@ def item_grade(files, item, rows):
return js_round(sum(grade_of(d) for d in dpis) / len(dpis))
def resolution_issue(files, items, rows):
"""Refuse sub-96 DPI and require recorded consent for measurable 96–199 DPI.
Unknown formats remain for manual review; they cannot be treated as a
measured zero DPI or silently called high-resolution artwork.
"""
for index, item in enumerate(items, 1):
dpis = []
for source in item['production']['sources']:
row = rows.get(str(source['upload_id']))
dpi = source_dpi(files, row, source) if row else None
if dpi is None:
dpis = []
break
dpis.append(dpi)
if not dpis:
continue
lowest = min(dpis)
if lowest < DPI_REFUSE:
return f'Item {index}: resolução de {js_round(lowest)} DPI abaixo do mínimo de {DPI_REFUSE} DPI.'
if lowest < DPI_IDEAL and (item['quality_status'] != 'warning' or not item['quality_acknowledged']):
return f'Item {index}: confirme a ressalva de resolução entre {DPI_REFUSE} e {DPI_IDEAL - 1} DPI.'
return None
def mismatch(files, items, rows):
"""Why a cart's grades cannot be approved at checkout, or None."""
for item in items: