Commit 8fbe0fdc authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Renforcement assertion pour bloquer la validation ou le refus d'une...

Renforcement assertion pour bloquer la validation ou le refus d'une candidature à sa propre composante uniquement (#60566)
parent 8b1baf89
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -12,12 +12,12 @@
                <th>Composante</th>
                <th>Etat</th>
                <th>Date commission</th>
                <th v-if="canValiderCandidature || canRefuserCandidature">Action</th>
                <th>Action</th>
            </tr>
            </thead>
            <tbody>
            <tr v-if="candidatures.length == 0">
                <td v-if="canValiderCandidature" colspan="5" style="text-align:center;">Aucune candidature</td>
                <td  colspan="5" style="text-align:center;">Aucune candidature</td>

            </tr>

@@ -37,8 +37,8 @@
                    <u-date v-if="candidature.dateCommission" :value="candidature.dateCommission"/>
                </td>

                <td v-if="this.canValiderCandidature || this.canRefuserCandidature" style="text-align:center;">
                    <a v-if="!candidature.validation && this.canValiderCandidature"
                <td style="text-align:center;">
                    <a v-if="!candidature.validation && candidature.canValider"
                       :href="urlAccepterCandidature(candidature)"
                       class="btn btn-success"
                       data-content="Êtes vous sûr de vouloir accepter cette candidature ?"
@@ -48,7 +48,7 @@
                       @click.prevent="validerCandidature">
                        <i class="fa-solid fa-check"></i>
                    </a>&nbsp;
                    <a v-if="this.canRefuserCandidature" :href="urlRefuserCandidature(candidature)"
                    <a v-if="!candidature.motif && candidature.canRefuser" :href="urlRefuserCandidature(candidature)"
                       class="btn btn-danger"
                       data-content="Êtes vous sûr de vouloir refuser cette candidature ?"
                       data-title="Refuser la candidature"
@@ -81,8 +81,6 @@ export default {
    name: "ListeCandidatures.vue",
    props: {
        intervenant: {required: true},
        canValiderCandidature: {type: Boolean, required: false},
        canRefuserCandidature: {type: Boolean, required: false},
        renseignerDonneesPersonnelles: {type: Boolean, required: false},

    },
+3 −2
Original line number Diff line number Diff line
@@ -91,12 +91,14 @@ return [
                    'controller' => OffreEmploiController::class,
                    'action'     => 'accepter-candidature',
                    'privileges' => Privileges::MISSION_CANDIDATURE_VALIDER,
                    'assertion'  => Assertion\OffreEmploiAssertion::class,
                ],
                'refuser-candidature'  => [
                    'route'      => '/refuser-candidature/:candidature',
                    'controller' => OffreEmploiController::class,
                    'action'     => 'refuser-candidature',
                    'privileges' => Privileges::MISSION_CANDIDATURE_REFUSER,
                    'assertion'  => Assertion\OffreEmploiAssertion::class,
                ],


@@ -167,7 +169,6 @@ return [
                Privileges::MISSION_OFFRE_EMPLOI_VALIDER,
                Privileges::MISSION_OFFRE_EMPLOI_POSTULER,
                Privileges::MISSION_CANDIDATURE_VISUALISATION,
                Privileges::MISSION_CANDIDATURE_VALIDER,
                Privileges::MISSION_OFFRE_EMPLOI_SUPPRESSION,

            ],
@@ -179,7 +180,7 @@ return [
                Privileges::MISSION_CANDIDATURE_VALIDER,
                Privileges::MISSION_CANDIDATURE_REFUSER,
            ],
            'resources'  => ['Intervenant'],
            'resources'  => 'Candidature',
            'assertion'  => Assertion\OffreEmploiAssertion::class,
        ],

+15 −8
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ use Application\Service\Traits\WorkflowServiceAwareTrait;
use Intervenant\Entity\Db\Intervenant;
use Laminas\Permissions\Acl\Resource\ResourceInterface;
use Lieu\Entity\Db\Structure;
use Mission\Entity\Db\Candidature;
use Mission\Entity\Db\OffreEmploi;
use UnicaenApp\Service\EntityManagerAwareInterface;
use UnicaenApp\Service\EntityManagerAwareTrait;
@@ -87,9 +88,10 @@ class OffreEmploiAssertion extends AbstractAssertion implements EntityManagerAwa
                        return $this->assertOffreEmploiSupprimer($role, $entity);
                }
            break;
            case $entity instanceof Intervenant:
            case $entity instanceof Candidature:
                switch ($privilege) {
                    case Privileges::MISSION_CANDIDATURE_VALIDER:
                    case Privileges::MISSION_CANDIDATURE_REFUSER:
                        return $this->assertCandidatureValider($role, $entity);
                }
            break;
@@ -121,16 +123,19 @@ class OffreEmploiAssertion extends AbstractAssertion implements EntityManagerAwa
        if (!$entity) {
            $entity = $this->getMvcEvent()->getParam('volumeHoraireMission');
        }
        if (!$entity) {
            $entity = $this->getMvcEvent()->getParam('candidature');
        }
        if (!$entity) {
            return false;
        }

        switch ($action) {
            case 'candidature':
                if ($entity instanceof Intervenant){
                    // à revoir : réorganiser l'assertion
                    // intégrer le workflow
                    return $entity->getStatut()->getOffreEmploiPostuler();
            case 'accepter-candidature':
            case 'refuser-candidature':
                if ($entity instanceof Candidature){
                    $assert = $this->assertCandidatureValider($role, $entity);
                    return $assert;
                }
                break;
        }
@@ -258,14 +263,16 @@ class OffreEmploiAssertion extends AbstractAssertion implements EntityManagerAwa



    protected function assertCandidatureValider (Role $role, Intervenant $intervenant)
    protected function assertCandidatureValider (Role $role, Candidature $candidature)
    {
        $codeEtape = WfEtape::CANDIDATURE_VALIDATION;
        $intervenant = $candidature->getIntervenant();
        $wfEtape   = $this->getServiceWorkflow()->getEtape($codeEtape, $intervenant);
        $structureOffre = $candidature->getOffre()->getStructure();

        return $this->asserts([
            $wfEtape && $wfEtape->isAtteignable(),
            $this->haveRole(),
            $this->assertStructure($role, $structureOffre),
        ]);
    }

+11 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Mission\Service;

use Application\Acl\Role;
use Application\Provider\Privilege\Privileges;
use Application\Service\AbstractEntityService;
use Application\Service\Traits\ContextServiceAwareTrait;
use Application\Service\Traits\ParametresServiceAwareTrait;
@@ -108,13 +109,22 @@ class CandidatureService extends AbstractEntityService
        $query  = $this->getEntityManager()->createQuery($dql)->setParameters($parameters);
        $result = $query->getResult();

        $triggers = [];
        $triggers = [
            '/'                      => function (Candidature $original, array $extracted) {
                $extracted['canValider']    = $this->getAuthorize()->isAllowed($original, Privileges::MISSION_CANDIDATURE_VALIDER);
                $extracted['canRefuser'] = $this->getAuthorize()->isAllowed($original, Privileges::MISSION_CANDIDATURE_REFUSER);

                return $extracted;
            },
        ];

        $properties = [
            'id',
            'motif',
            'validation',
            'dateCommission',
            'canValider',
            'canRefuser',
            ['offre', ['id', 'typeMission', 'titre', ['structure', ['libelleCourt']]]],
            ['intervenant', ['id', 'nomUsuel', 'prenom', 'emailPro', 'code', ['structure', ['libelleLong', 'libelleCourt', 'code', 'id']], ['statut', ['libelle', 'code']]]],
        ];
+0 −6
Original line number Diff line number Diff line
<?php

use Application\Provider\Privilege\Privileges;

$this->intervenant($intervenant)->renderTitle('Candidature');
$canValiderCandidature = $this->isAllowed($intervenant, Privileges::MISSION_CANDIDATURE_VALIDER);
$canRefuserCandidature = $this->isAllowed($intervenant, Privileges::MISSION_CANDIDATURE_REFUSER);


echo $this->vue('mission/liste-candidatures', [

    'intervenant'                   => $intervenant->getId(),
    'canValiderCandidature'         => $canValiderCandidature,
    'canRefuserCandidature'         => $canRefuserCandidature,
    'renseignerDonneesPersonnelles' => $renseignerDonneesPersonnelles,
]);