Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/config/routing/admin_event.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ admin_event_special_price:
path: /special_price
defaults: {_controller: AppBundle\Controller\Admin\Event\SpecialPriceAction}

admin_event_special_price_extend:
path: /special_price/{id}/extend
defaults: {_controller: AppBundle\Controller\Admin\Event\ExtendSpecialPriceAction}
requirements:
id: \d+

admin_event_prices:
path: /prices
defaults: {_controller: AppBundle\Controller\Admin\Event\PricesAction }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace AppBundle\Controller\Admin\Event;

use AppBundle\Event\AdminEventSelection;
use AppBundle\Event\Model\Repository\TicketSpecialPriceRepository;
use AppBundle\Event\Model\TicketSpecialPrice;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;

class ExtendSpecialPriceAction extends AbstractController
{
public function __construct(
private readonly TicketSpecialPriceRepository $ticketSpecialPriceRepository,
) {}

public function __invoke(int $id, AdminEventSelection $eventSelection): Response
{
$specialPrice = $this->ticketSpecialPriceRepository->get($id);

if (!$specialPrice instanceof TicketSpecialPrice) {
throw $this->createNotFoundException();
}

$newDateEnd = clone $specialPrice->getDateEnd();
$newDateEnd->modify(sprintf('+%d days', SpecialPriceAction::EXTEND_DAYS));
$specialPrice->setDateEnd($newDateEnd);

$this->ticketSpecialPriceRepository->save($specialPrice);

$this->addFlash('notice', sprintf('La validité du token a été prolongée de %d jours.', SpecialPriceAction::EXTEND_DAYS));

return $this->redirectToRoute('admin_event_special_price', [
'id' => $eventSelection->event->getId(),
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

class SpecialPriceAction extends AbstractController
{
public const EXTEND_DAYS = 3; // jours

public function __construct(
private readonly TicketSpecialPriceRepository $ticketSpecialPriceRepository,
private readonly Authentication $authentication,
Expand Down Expand Up @@ -53,6 +55,7 @@ public function __invoke(Request $request, AdminEventSelection $eventSelection):
'title' => 'Gestion des prix custom',
'form' => $form->createView(),
'event_select_form' => $eventSelection->selectForm(),
'extend_days' => self::EXTEND_DAYS,
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public static function initMetadata(SerializerFactoryInterface $serializerFactor
->addField([
'columnName' => 'id',
'fieldName' => 'id',
'primary' => true,
'type' => 'int',
])
->addField([
Expand Down
8 changes: 8 additions & 0 deletions templates/admin/event/special_price.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<th>Date de début</th>
<th>Date de fin</th>
<th>Utilisé ?</th>
<th></th>
<th>Lien</th>
</thead>
<tbody>
Expand All @@ -34,6 +35,13 @@
<span class="ui red label">non</span>
{% endif %}
</td>
<td>
<a href="{{ path('admin_event_special_price_extend', {'id': row.special_price.id}) }}"
data-tooltip="Prolonger la validité de {{ extend_days }} jours"
class="ui icon button">
<i class="clock outline icon"></i>
</a>
</td>
<td><a href="{{ path('ticket', {'eventSlug' : event.path, 'token': row.special_price.token }) }}">Lien</a></td>

</tr>
Expand Down
14 changes: 14 additions & 0 deletions tests/behat/features/Admin/Events/TokensVIsiteurs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,17 @@ Feature: Administration - Évènements - Tokens Visiteurs
# Lien d'un token
And I follow "Lien"
Then I should see "Spécial Forum * 2€ TTC"

@reloadDbWithTestData
Scenario: Prolonger la validité d'un token visiteur
Given I am logged in as admin and on the Administration
And I follow "Tokens visiteurs"
# Ajout d'un token
When I fill in "ticket_special_price[price]" with "2"
And I fill in "ticket_special_price[description]" with "Token visiteur de test"
And I press "Enregistrer"
Then I should see "Le token a été enregistré"
# Prolongation du token
And I should see tooltip "Prolonger la validité de 3 jours"
When I follow the button of tooltip "Prolonger la validité de 3 jours"
Then I should see "La validité du token a été prolongée de 3 jours."
Loading