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:
@@ -1,6 +1,7 @@
|
||||
"""Quotes: the customer's cart, approved at once when it can be (app/quote_review.py)."""
|
||||
import hashlib
|
||||
import json
|
||||
from datetime import datetime, timezone
|
||||
from decimal import Decimal
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
@@ -13,7 +14,7 @@ from ..core.auth import owner
|
||||
from ..core.models import QuoteRequest
|
||||
from ..core.pricing import price
|
||||
from .. import quote_review
|
||||
from ..grade_check import Files, mismatch
|
||||
from ..grade_check import Files, mismatch, resolution_issue
|
||||
from ..runtime import freight, payment, quote_view, require_delivery_available, storage, upload_row
|
||||
from ..scanning import require_clean
|
||||
|
||||
@@ -27,6 +28,12 @@ def create_quote(body: QuoteRequest, session_id=Depends(owner)):
|
||||
require_delivery_available(body.freight.service)
|
||||
draft = body.model_dump(mode='json', exclude={'request_key'})
|
||||
digest = hashlib.sha256(json.dumps(draft, sort_keys=True).encode()).hexdigest()
|
||||
accepted_at = datetime.now(timezone.utc).isoformat()
|
||||
for item in draft['items']:
|
||||
if item.get('residue_accepted'):
|
||||
item['residue_accepted_at'] = accepted_at
|
||||
if item.get('stroke_choice'):
|
||||
item['stroke_choice_at'] = accepted_at
|
||||
reason = quote_review.review_reason(draft)
|
||||
if reason is not None:
|
||||
# Waits for review: check the delivery now, priced at approval.
|
||||
@@ -51,7 +58,11 @@ def create_quote(body: QuoteRequest, session_id=Depends(owner)):
|
||||
# The grade came from the browser and is shown with the order (it no
|
||||
# longer sets the price): before a cart is approved at checkout, the
|
||||
# server works it out from the files.
|
||||
note = mismatch(Files(storage), draft['items'], rows) if reason is None else None
|
||||
files = Files(storage)
|
||||
issue = resolution_issue(files, draft['items'], rows)
|
||||
if issue:
|
||||
raise HTTPException(422, issue)
|
||||
note = mismatch(files, draft['items'], rows) if reason is None else None
|
||||
reason = reason or note
|
||||
uid = uuid4()
|
||||
c.execute('INSERT INTO dtf_local.quotes(id,owner,request_key,request_hash,draft,review_note) VALUES(%s,%s,%s,%s,%s,%s) ON CONFLICT(owner,request_key) DO NOTHING',
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -78,9 +78,13 @@ def approve(c, row, items, reviewer):
|
||||
'quality_status': original['quality_status'],
|
||||
'quality_acknowledged': original['quality_acknowledged'],
|
||||
'residue_accepted': original.get('residue_accepted', 0),
|
||||
**({'residue_accepted_at': original['residue_accepted_at']}
|
||||
if original.get('residue_accepted_at') else {}),
|
||||
**({'stroke_px': original['stroke_px'], 'stroke_class': original['stroke_class']}
|
||||
if original.get('stroke_class') else {}),
|
||||
**({'stroke_choice': original['stroke_choice']} if original.get('stroke_choice') else {}),
|
||||
**({'stroke_choice_at': original['stroke_choice_at']}
|
||||
if original.get('stroke_choice_at') else {}),
|
||||
**({'split': original['split']} if original.get('split') else {})})
|
||||
bill_splits(priced)
|
||||
metres = sum(Decimal(i['billed_metres']) for i in priced)
|
||||
|
||||
Reference in New Issue
Block a user