refactor: translate all docstrings and comments to English (STRICT ENGLISH POLICY complete)
This commit is contained in:
@@ -7,7 +7,7 @@ from slowapi.util import get_remote_address
|
||||
from .. import models, schemas, auth
|
||||
from ..database import get_db
|
||||
|
||||
# [H-02] Rate limiter pentru extract-label endpoint
|
||||
# [H-02] Rate limiter for extract-label endpoint
|
||||
limiter = Limiter(key_func=get_remote_address)
|
||||
|
||||
router = APIRouter(
|
||||
@@ -20,7 +20,7 @@ def read_item_stats(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: auth.TokenData = Depends(auth.get_current_user)
|
||||
):
|
||||
"""[C-01] Statistici iteme — doar utilizatori autentificati."""
|
||||
"""[C-01] Item statistics — only for authenticated users."""
|
||||
total_categories = db.query(models.Category).count()
|
||||
total_items = db.query(models.Item).count()
|
||||
|
||||
@@ -41,7 +41,7 @@ def read_items(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: auth.TokenData = Depends(auth.get_current_user)
|
||||
):
|
||||
"""[C-01] Lista iteme — doar utilizatori autentificati."""
|
||||
"""[C-01] List of items — only for authenticated users."""
|
||||
items = db.query(models.Item).offset(skip).limit(limit).all()
|
||||
return items
|
||||
|
||||
@@ -51,7 +51,7 @@ def read_item(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: auth.TokenData = Depends(auth.get_current_user)
|
||||
):
|
||||
"""[C-01] Obține item — doar utilizatori autentificati."""
|
||||
"""[C-01] Get item — only for authenticated users."""
|
||||
item = db.query(models.Item).filter(models.Item.id == item_id).first()
|
||||
if item is None:
|
||||
raise HTTPException(status_code=404, detail="Item not found")
|
||||
@@ -66,14 +66,14 @@ async def extract_label(
|
||||
file: UploadFile = File(...),
|
||||
current_user: auth.TokenData = Depends(auth.get_current_user)
|
||||
):
|
||||
"""[C-01] Extragere etichetă din imagine — doar utilizatori autentificati. [H-02] Rate limit: 10 req/min per IP."""
|
||||
"""[C-01] Extract label from image — only for authenticated users. [H-02] Rate limit: 10 req/min per IP."""
|
||||
from ..ai_vision import extract_label_info
|
||||
|
||||
# [SECURITY FIX H-03] Validare tip MIME și dimensiune maximă
|
||||
if file.content_type not in _ALLOWED_IMAGE_TYPES:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_415_UNSUPPORTED_MEDIA_TYPE,
|
||||
detail=f"Tip fișier nepermis: {file.content_type}. Acceptat: {', '.join(_ALLOWED_IMAGE_TYPES)}"
|
||||
detail=f"File type not allowed: {file.content_type}. Accepted: {', '.join(_ALLOWED_IMAGE_TYPES)}"
|
||||
)
|
||||
|
||||
contents = await file.read()
|
||||
@@ -81,7 +81,7 @@ async def extract_label(
|
||||
if len(contents) > _MAX_IMAGE_SIZE:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_413_REQUEST_ENTITY_TOO_LARGE,
|
||||
detail="Fișierul depășește limita de 10MB."
|
||||
detail="File exceeds 10MB limit."
|
||||
)
|
||||
|
||||
result = extract_label_info(contents)
|
||||
@@ -93,7 +93,7 @@ def create_item(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: auth.TokenData = Depends(auth.get_current_user)
|
||||
):
|
||||
"""[C-01] Creare item — doar utilizatori autentificati. [M-02] user_id din token."""
|
||||
"""[C-01] Create item — only for authenticated users. [M-02] user_id from token."""
|
||||
# Check if barcode exists
|
||||
db_item = db.query(models.Item).filter(models.Item.barcode == item.barcode).first()
|
||||
if db_item:
|
||||
@@ -104,7 +104,7 @@ def create_item(
|
||||
db.commit()
|
||||
db.refresh(db_item)
|
||||
|
||||
# Audit log the creation — [M-02] user_id din token, nu din body
|
||||
# Audit log the creation — [M-02] user_id from token, not from body
|
||||
audit = models.AuditLog(
|
||||
user_id=current_user.sub,
|
||||
action="CREATE_ITEM",
|
||||
@@ -123,7 +123,7 @@ def update_item(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: auth.TokenData = Depends(auth.get_current_user)
|
||||
):
|
||||
"""[C-01] Actualizare item — doar utilizatori autentificati."""
|
||||
"""[C-01] Update item — only for authenticated users."""
|
||||
db_item = db.query(models.Item).filter(models.Item.id == item_id).first()
|
||||
if not db_item:
|
||||
raise HTTPException(status_code=404, detail="Item not found")
|
||||
@@ -142,7 +142,7 @@ def delete_item(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: auth.TokenData = Depends(auth.get_current_user)
|
||||
):
|
||||
"""[C-01] Ștergere item — doar utilizatori autentificati."""
|
||||
"""[C-01] Delete item — only for authenticated users."""
|
||||
db_item = db.query(models.Item).filter(models.Item.id == item_id).first()
|
||||
if not db_item:
|
||||
raise HTTPException(status_code=404, detail="Item not found")
|
||||
|
||||
Reference in New Issue
Block a user