Add logo upload to admin organizer edit page
Admin can now view the current logo and upload a new one via the organizer edit form. Uses VichUploader with the existing organizer_logo mapping. Adds test with fixture image. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -472,6 +472,12 @@ class AdminController extends AbstractController
|
||||
$user->setCity(trim($request->request->getString('city')));
|
||||
$user->setOffer($request->request->getString('offer'));
|
||||
$user->setCommissionRate((float) $request->request->getString('commission_rate'));
|
||||
|
||||
$logoFile = $request->files->get('logo');
|
||||
if ($logoFile) {
|
||||
$user->setLogoFile($logoFile);
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', sprintf('Organisateur %s %s mis a jour.', $user->getFirstName(), $user->getLastName()));
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<p class="font-bold text-gray-500 italic">{{ user.companyName }} — {{ user.email }}</p>
|
||||
</div>
|
||||
|
||||
<form method="post" action="{{ path('app_admin_edit_organizer', {id: user.id}) }}">
|
||||
<form method="post" action="{{ path('app_admin_edit_organizer', {id: user.id}) }}" enctype="multipart/form-data">
|
||||
<div class="flex flex-wrap gap-6 mb-8">
|
||||
<div class="flex-1 min-w-[300px]">
|
||||
<div class="admin-card">
|
||||
@@ -99,6 +99,29 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap gap-6 mb-8">
|
||||
<div class="flex-1 min-w-[300px]">
|
||||
<div class="admin-card">
|
||||
<h2 class="text-sm font-black uppercase tracking-widest mb-4">Logo</h2>
|
||||
<div class="flex items-center gap-6">
|
||||
{% if user.logoName %}
|
||||
<div class="shrink-0">
|
||||
<img src="{{ vich_uploader_asset(user, 'logoFile') }}" alt="Logo {{ user.companyName }}" class="w-24 h-24 object-contain border-2 border-gray-900">
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="w-24 h-24 border-2 border-dashed border-gray-300 flex items-center justify-center shrink-0">
|
||||
<span class="text-xs text-gray-400 font-bold uppercase">Aucun logo</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="flex-1">
|
||||
<label for="edit_logo" class="admin-form-label font-black uppercase text-gray-400">Changer le logo</label>
|
||||
<input type="file" id="edit_logo" name="logo" accept="image/*" class="admin-form-input-lg">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3">
|
||||
<button type="submit"
|
||||
class="admin-btn-lg font-black uppercase text-sm tracking-widest hover:bg-green-500 hover:text-black transition-all">
|
||||
|
||||
@@ -509,6 +509,42 @@ class AdminControllerTest extends WebTestCase
|
||||
self::assertSame(0.5, $orga->getCommissionRate());
|
||||
}
|
||||
|
||||
public function testEditOrganizerWithLogo(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$em = static::getContainer()->get(EntityManagerInterface::class);
|
||||
$admin = $this->createUser(['ROLE_ROOT']);
|
||||
$orga = $this->createOrganizer($em);
|
||||
$orga->setIsApproved(true);
|
||||
$orga->setOffer('basic');
|
||||
$orga->setCommissionRate(3.0);
|
||||
$em->flush();
|
||||
|
||||
$logo = new \Symfony\Component\HttpFoundation\File\UploadedFile(
|
||||
__DIR__.'/../fixtures/logo.png',
|
||||
'logo.png',
|
||||
'image/png',
|
||||
null,
|
||||
true,
|
||||
);
|
||||
|
||||
$client->loginUser($admin);
|
||||
$client->request('POST', '/admin/organisateur/'.$orga->getId().'/modifier', [
|
||||
'first_name' => $orga->getFirstName(),
|
||||
'last_name' => $orga->getLastName(),
|
||||
'email' => $orga->getEmail(),
|
||||
'company_name' => $orga->getCompanyName(),
|
||||
'siret' => $orga->getSiret(),
|
||||
'offer' => 'basic',
|
||||
'commission_rate' => '3',
|
||||
], ['logo' => $logo]);
|
||||
|
||||
self::assertResponseRedirects('/admin/organisateurs?tab=approved');
|
||||
|
||||
$em->refresh($orga);
|
||||
self::assertNotNull($orga->getLogoName());
|
||||
}
|
||||
|
||||
public function testEditOrganizerRedirectsIfNotApproved(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
|
||||
BIN
tests/fixtures/logo.png
vendored
Normal file
BIN
tests/fixtures/logo.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 79 B |
Reference in New Issue
Block a user