feat(입출고): 입고증 사진 왼쪽·오른쪽 회전 — 돌린 상태로 저장
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
GET /inout/settings?panel=1 옵션 팝업 내용(톱니, ERP 관리자) — 공장 목록·발주 담당·입고 담당
|
||||
POST /inout/settings/… 옵션 저장 — 팝업(X-Inout-Options: 1)이면 JSON, 아니면 목록으로 이동
|
||||
POST /inout/settings/products/import|save · /products/{code}/exclude|restore 옵션 → 상품 정보(단가·무게·은 함유량, 004)
|
||||
POST /inout/orders/{id}/receipts/{rid}/photos · /orders/{id}/photos/{pid}/delete · GET /inout/photos/{pid} 입고증 사진
|
||||
POST /inout/orders/{id}/receipts/{rid}/photos · /orders/{id}/photos/{pid}/delete|rotate · GET /inout/photos/{pid} 입고증 사진
|
||||
GET|POST /inout/orders/{id}/mail 발주 메일 미리보기·발송(발주 담당 본인 Gmail, 사람이 눌러야 보냄)
|
||||
GET|POST /inout/orders/{id}/receipts/{rid}/mail 입고 요청 메일(물류센터, 입고 담당 본인 Gmail, 005)
|
||||
POST /inout/settings/logistics 옵션 → 물류센터(입고 요청 메일 받는 주소·참조, 005)
|
||||
@@ -486,7 +486,7 @@ def receipt_delete(request: Request, order_id: int, receipt_id: int) -> Any:
|
||||
_PHOTO_HEADERS = {
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"Content-Security-Policy": "default-src 'none'; img-src 'self'; style-src 'unsafe-inline'; sandbox",
|
||||
"Cache-Control": "private, max-age=86400",
|
||||
"Cache-Control": "private, no-cache",
|
||||
}
|
||||
|
||||
|
||||
@@ -530,6 +530,21 @@ def receipt_photo_delete(request: Request, order_id: int, photo_id: int) -> Any:
|
||||
return _redirect(f"/inout/orders/{order_id}", "사진을 지웠습니다.")
|
||||
|
||||
|
||||
@router.post("/orders/{order_id}/photos/{photo_id}/rotate")
|
||||
def receipt_photo_rotate(request: Request, order_id: int, photo_id: int, degrees: int = Query(...)) -> Any:
|
||||
"""크게 보기 창의 회전 버튼 — 창을 닫지 않게 JSON 으로 답한다(화면이 사진을 다시 받아 그림)."""
|
||||
got = _ctx(request)
|
||||
if not isinstance(got, tuple):
|
||||
return got
|
||||
st, user = got
|
||||
_require(st, user, "receive")
|
||||
try:
|
||||
st.rotate_receipt_photo(order_id, photo_id, degrees)
|
||||
except (ValueError, LookupError) as exc:
|
||||
return JSONResponse({"error": str(exc)}, status_code=400)
|
||||
return JSONResponse({"ok": True})
|
||||
|
||||
|
||||
@router.get("/photos/{photo_id}")
|
||||
def photo_view(request: Request, photo_id: int) -> Response:
|
||||
_user(request)
|
||||
@@ -537,12 +552,18 @@ def photo_view(request: Request, photo_id: int) -> Response:
|
||||
row = st.get_photo(photo_id) if st is not None else None
|
||||
if row is None:
|
||||
raise HTTPException(status_code=404, detail="사진을 찾을 수 없습니다.")
|
||||
from hashlib import md5 # noqa: WPS433
|
||||
from urllib.parse import quote # noqa: WPS433
|
||||
|
||||
data = bytes(row["data"])
|
||||
# 돌린 사진이 하루 동안 예전 모습으로 남지 않게 — 브라우저가 매번 내용이 같은지 묻는다(no-cache + ETag)
|
||||
etag = '"' + md5(data, usedforsecurity=False).hexdigest() + '"'
|
||||
if request.headers.get("if-none-match") == etag:
|
||||
return Response(status_code=304, headers={"ETag": etag, "Cache-Control": _PHOTO_HEADERS["Cache-Control"]})
|
||||
name = quote(str(row["filename"] or f"photo-{photo_id}"))
|
||||
disp = "attachment" if row["content_type"] == "image/heic" else "inline" # HEIC 은 브라우저가 못 보여 줌 → 내려받기
|
||||
return Response(content=bytes(row["data"]), media_type=row["content_type"],
|
||||
headers={**_PHOTO_HEADERS, "Content-Disposition": f"{disp}; filename*=UTF-8''{name}"})
|
||||
return Response(content=data, media_type=row["content_type"],
|
||||
headers={**_PHOTO_HEADERS, "ETag": etag, "Content-Disposition": f"{disp}; filename*=UTF-8''{name}"})
|
||||
|
||||
|
||||
# ────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user