improve(company): add user feedback for logo upload and conversion
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
- Flash success message showing format conversion (e.g. "JPG do WebP") - Flash error message if conversion fails with suggestion to try another file - Flash warning for unsupported file formats - Form hint explains automatic WebP conversion Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bd179dec97
commit
af9871a127
@ -242,7 +242,6 @@ def _save_description(db, company):
|
||||
if logo_file and logo_file.filename:
|
||||
import os
|
||||
from PIL import Image
|
||||
import io
|
||||
|
||||
allowed = {'png', 'jpg', 'jpeg', 'svg', 'webp'}
|
||||
ext = logo_file.filename.rsplit('.', 1)[-1].lower() if '.' in logo_file.filename else ''
|
||||
@ -254,15 +253,22 @@ def _save_description(db, company):
|
||||
old_path = os.path.join(logo_dir, f"{company.slug}.{old_ext}")
|
||||
if os.path.exists(old_path):
|
||||
os.remove(old_path)
|
||||
filepath = os.path.join(logo_dir, f"{company.slug}.webp")
|
||||
try:
|
||||
if ext == 'svg':
|
||||
# SVG stays as-is (can't convert to webp)
|
||||
filepath = os.path.join(logo_dir, f"{company.slug}.svg")
|
||||
logo_file.save(filepath)
|
||||
flash('Logo zostało zapisane (format SVG).', 'success')
|
||||
else:
|
||||
filepath = os.path.join(logo_dir, f"{company.slug}.webp")
|
||||
img = Image.open(logo_file)
|
||||
img.save(filepath, 'WEBP', quality=85)
|
||||
flash(f'Logo zostało przekonwertowane z {ext.upper()} do WebP i zapisane.', 'success')
|
||||
logger.info(f"Logo uploaded for company {company.id}: {filepath}")
|
||||
except Exception as e:
|
||||
logger.error(f"Logo conversion failed for company {company.id}: {e}")
|
||||
flash('Nie udało się przetworzyć pliku logo. Spróbuj inny plik (PNG, JPG lub WebP).', 'error')
|
||||
else:
|
||||
flash(f'Nieobsługiwany format pliku (.{ext}). Dozwolone: PNG, JPG, SVG, WebP.', 'warning')
|
||||
|
||||
|
||||
def _save_services(company):
|
||||
|
||||
@ -848,7 +848,7 @@
|
||||
</div>
|
||||
<div style="flex: 1;">
|
||||
<input type="file" id="logo_file" name="logo_file" accept="image/png,image/jpeg,image/svg+xml,image/webp" class="form-input" style="padding: 8px;">
|
||||
<p class="form-help" style="margin-top: 4px;">PNG, JPG, SVG lub WebP. Zalecany rozmiar: min. 200x200px.</p>
|
||||
<p class="form-help" style="margin-top: 4px;">PNG, JPG, SVG lub WebP. Pliki graficzne zostaną automatycznie przekonwertowane do formatu WebP. Zalecany rozmiar: min. 200x200px.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user