diff --git a/blueprints/public/routes_company_edit.py b/blueprints/public/routes_company_edit.py index 15a4bf6..aa8f45a 100644 --- a/blueprints/public/routes_company_edit.py +++ b/blueprints/public/routes_company_edit.py @@ -237,7 +237,8 @@ def _save_description(db, company): else: company.category_id = None - # Logo upload + # Logo upload — save as static/img/companies/{slug}.{ext} + # company_detail.html expects logo at this path with webp→svg fallback logo_file = request.files.get('logo_file') if logo_file and logo_file.filename: import os @@ -246,12 +247,15 @@ def _save_description(db, company): 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_dir = os.path.join('static', 'img', 'companies') + os.makedirs(logo_dir, exist_ok=True) + # Remove old logo files for this company (different extensions) + for old_ext in allowed: + 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}.{ext}") logo_file.save(filepath) - company.logo_dark_bg = os.path.join('uploads', 'logos', filename) logger.info(f"Logo uploaded for company {company.id}: {filepath}") diff --git a/templates/company_edit.html b/templates/company_edit.html index 8c534bf..558c5d3 100644 --- a/templates/company_edit.html +++ b/templates/company_edit.html @@ -841,15 +841,11 @@
- {% if company.logo_dark_bg %} -
- Logo +
+ Logo
- {% else %} -
- Brak logo -
- {% endif %}

PNG, JPG, SVG lub WebP. Zalecany rozmiar: min. 200x200px.