feat: keep rejected applications visible, enable deletion for admins
This commit is contained in:
@@ -4,8 +4,10 @@ namespace App\Controller\Admin\Application;
|
|||||||
|
|
||||||
use App\Entity\Application;
|
use App\Entity\Application;
|
||||||
use App\Event\ApplicationDeletedEvent;
|
use App\Event\ApplicationDeletedEvent;
|
||||||
|
use App\Htmx\HxRedirectResponse;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||||
@@ -22,20 +24,26 @@ class DeleteController extends AbstractController
|
|||||||
#[Route('/admin/application/delete/{uuid}', name: 'app_admin_application_delete')]
|
#[Route('/admin/application/delete/{uuid}', name: 'app_admin_application_delete')]
|
||||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||||
#[IsGranted('DELETE', subject: 'application')]
|
#[IsGranted('DELETE', subject: 'application')]
|
||||||
public function index(Application $application): Response
|
public function index(Application $application, Request $request): Response
|
||||||
{
|
{
|
||||||
$this->entityManager->remove($application);
|
if (true === $request->isMethod(Request::METHOD_POST)) {
|
||||||
$this->entityManager->flush();
|
$this->entityManager->remove($application);
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
$this->eventDispatcher->dispatch(
|
$this->eventDispatcher->dispatch(
|
||||||
new ApplicationDeletedEvent($application),
|
new ApplicationDeletedEvent($application),
|
||||||
ApplicationDeletedEvent::NAME
|
ApplicationDeletedEvent::NAME
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addFlash('success', 'Die Bewerbung wurde gelöscht');
|
$this->addFlash('success', 'Die Bewerbung wurde gelöscht');
|
||||||
|
|
||||||
return $this->redirectToRoute('app_administrative_assignment_detail', [
|
return new HxRedirectResponse($this->generateUrl('app_administrative_assignment_detail', [
|
||||||
'uuid' => $application->getAssignment()->getUuid(),
|
'uuid' => $application->getAssignment()->getUuid(),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('admin/application/modal_delete.html.twig', [
|
||||||
|
'application' => $application,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,12 +83,8 @@ class ApplicationRepository extends ServiceEntityRepository
|
|||||||
->select('application', 'teamer', 'feedback')
|
->select('application', 'teamer', 'feedback')
|
||||||
->innerJoin('application.teamer', 'teamer')
|
->innerJoin('application.teamer', 'teamer')
|
||||||
->leftJoin('teamer.feedback', 'feedback')
|
->leftJoin('teamer.feedback', 'feedback')
|
||||||
->where($qb->expr()->andX(
|
->where($qb->expr()->eq('application.assignment', ':assignment'))
|
||||||
$qb->expr()->eq('application.assignment', ':assignment'),
|
|
||||||
$qb->expr()->neq('application.status', ':status')
|
|
||||||
))
|
|
||||||
->setParameter('assignment', $assignment)
|
->setParameter('assignment', $assignment)
|
||||||
->setParameter('status', Application::STATUS_REJECTED)
|
|
||||||
->getQuery()
|
->getQuery()
|
||||||
->getResult()
|
->getResult()
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ class ApplicationVoter extends Voter
|
|||||||
if ($this->security->isGranted('ROLE_ADMINISTRATIVE') && in_array($attribute, $adminAttributes)) {
|
if ($this->security->isGranted('ROLE_ADMINISTRATIVE') && in_array($attribute, $adminAttributes)) {
|
||||||
$assignment = $application->getAssignment();
|
$assignment = $application->getAssignment();
|
||||||
return match ($attribute) {
|
return match ($attribute) {
|
||||||
static::VIEW, static::STATUS => Application::STATUS_REJECTED !== $status,
|
static::STATUS, static::DELETE => true,
|
||||||
static::DELETE => Application::STATUS_REJECTED === $status,
|
static::VIEW => Application::STATUS_REJECTED !== $status,
|
||||||
static::DISPOSE => Application::STATUS_REJECTED !== $status
|
static::DISPOSE => Application::STATUS_REJECTED !== $status
|
||||||
&& $assignment->getAvailableDispositions() > $assignment->getDispositions()->count(),
|
&& $assignment->getAvailableDispositions() > $assignment->getDispositions()->count(),
|
||||||
default => false,
|
default => false,
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div>
|
<div>
|
||||||
Möchtest du die Bewerbung von {{ application.teamer }} wirklich löschen?
|
Möchtest du die Bewerbung von <em>{{ application.teamer }}</em> wirklich löschen?
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user