feat(company): add manual logo upload field in company edit panel
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

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-03-27 17:31:22 +01:00
parent 702ee90de8
commit a199f50d74
2 changed files with 37 additions and 1 deletions

View File

@ -237,6 +237,23 @@ def _save_description(db, company):
else:
company.category_id = None
# Logo upload
logo_file = request.files.get('logo_file')
if logo_file and logo_file.filename:
import os
from werkzeug.utils import secure_filename
allowed = {'png', 'jpg', 'jpeg', 'svg', 'webp'}
ext = logo_file.filename.rsplit('.', 1)[-1].lower() if '.' in logo_file.filename else ''
if ext in allowed:
filename = secure_filename(f"company_{company.id}_logo.{ext}")
upload_dir = os.path.join('static', 'uploads', 'logos')
os.makedirs(upload_dir, exist_ok=True)
filepath = os.path.join(upload_dir, filename)
logo_file.save(filepath)
company.logo_dark_bg = os.path.join('uploads', 'logos', filename)
logger.info(f"Logo uploaded for company {company.id}: {filepath}")
def _save_services(company):
"""Save services tab fields."""

View File

@ -753,7 +753,7 @@
</button>
</div>
<form method="POST" action="{{ url_for('public.company_edit_save', company_id=company.id) }}" id="companyEditForm">
<form method="POST" action="{{ url_for('public.company_edit_save', company_id=company.id) }}" id="companyEditForm" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<input type="hidden" name="active_tab" id="activeTabInput" value="description">
@ -788,6 +788,25 @@
<p class="form-help">Główna kategoria widoczna przy nazwie firmy w katalogu</p>
</div>
<div class="form-group">
<label class="form-label">Logo firmy</label>
<div style="display: flex; align-items: center; gap: 16px; margin-bottom: 8px;">
{% if company.logo_dark_bg %}
<div style="width: 80px; height: 80px; border-radius: 8px; border: 1px solid var(--border, #e0e4eb); overflow: hidden; display: flex; align-items: center; justify-content: center; background: #fff;">
<img src="{{ url_for('static', filename=company.logo_dark_bg) }}" alt="Logo" style="max-width: 100%; max-height: 100%; object-fit: contain;">
</div>
{% else %}
<div style="width: 80px; height: 80px; border-radius: 8px; border: 2px dashed var(--border, #e0e4eb); display: flex; align-items: center; justify-content: center; color: var(--text-secondary, #999); font-size: 12px; text-align: center;">
Brak logo
</div>
{% endif %}
<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>
</div>
</div>
</div>
<div class="form-group">
<label for="year_established" class="form-label">Rok założenia firmy</label>
<input type="number" id="year_established" name="year_established" class="form-input" style="max-width: 200px;"