Fix: Add _open() and path() methods to TenantAwareFileSystemStorage
Critical fix for Celery photo processing. The storage class now correctly
handles file reading operations by automatically adding tenant_id prefix
when opening files.
Problems fixed:
- Celery tasks could not open image files from storage
- PIL/Pillow couldn't locate files in tenant-specific directories
- temp file deletion was failing due to path validation
Changes:
- Added _open() method to add tenant_id prefix when opening files
- Added path() method to convert relative paths to full filesystem paths
- Updated delete() method to handle paths with or without tenant prefix
- All methods include security checks to prevent cross-tenant access
Testing:
- All 5 existing tests pass
- Verified photo processing task works end-to-end:
* Reads temp image file from disk
* Processes and creates all image versions
* Saves processed files to tenant-specific directory
* Cleans up temporary files correctly
- Files correctly stored in: media/tenants/{tenant_id}/products/{product_id}/{photo_id}/
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -37,10 +37,10 @@
|
||||
<!-- Right Panel (4/12) - Fixed -->
|
||||
<div class="col-md-4">
|
||||
<div class="right-panel-fixed d-flex flex-column">
|
||||
<!-- Информация о складе -->
|
||||
{% if current_warehouse %}
|
||||
<!-- Информация о складе (всегда показываем блок для фиксированной позиции) -->
|
||||
<div class="card mb-2">
|
||||
<div class="card-body py-2 px-3 d-flex justify-content-between align-items-center">
|
||||
{% if current_warehouse %}
|
||||
<div>
|
||||
<small class="text-muted d-block" style="font-size: 0.75rem;">Склад:</small>
|
||||
<strong style="font-size: 0.95rem;">{{ current_warehouse.name }}</strong>
|
||||
@@ -48,9 +48,14 @@
|
||||
<button class="btn btn-sm btn-outline-secondary" id="changeWarehouseBtn" style="font-size: 0.75rem;">
|
||||
<i class="bi bi-arrow-left-right"></i> Сменить
|
||||
</button>
|
||||
{% else %}
|
||||
<div class="text-danger">
|
||||
<small class="d-block" style="font-size: 0.75rem;">Склад:</small>
|
||||
<strong style="font-size: 0.95rem;"><i class="bi bi-exclamation-triangle me-1"></i>Не выбран</strong>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Cart Panel -->
|
||||
<div class="card mb-2 flex-grow-1" style="min-height: 0;">
|
||||
|
||||
Reference in New Issue
Block a user