Commit 7a907b84 authored by Thomas Hamel's avatar Thomas Hamel
Browse files

ajout de l'autorisation d'inscription pour les thèses importées

parent 1e713a5f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
INSERT INTO public.unicaen_privilege_privilege (categorie_id, code, libelle, ordre)
VALUES ((SELECT id FROM unicaen_privilege_categorie WHERE code = 'autorisation-inscription'), 'acceder-commentaires',
        'Accéder aux commentaires saisis lors d''une autorisation d''inscription sur l''année suivante', 2);


select privilege__grant_privileges_to_profiles('autorisation-inscription',
                                               ARRAY['acceder-commentaires'],
                                               ARRAY['GEST_ED', 'RESP_ED']
       );
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ return [
                    [
                        'privileges' => [
                            AutorisationInscriptionPrivileges::AUTORISATION_INSCRIPTION_AJOUTER,
                            AutorisationInscriptionPrivileges::AUTORISATION_INSCRIPTION_ACCEDER_COMMENTAIRES,
                        ],
                        'resources'  => ['AutorisationInscription'],
                        'assertion' => AutorisationInscriptionAssertion::class,
+6 −11
Original line number Diff line number Diff line
@@ -102,20 +102,15 @@ class AutorisationInscriptionAssertion extends AbstractAssertion implements User
        }

        try {
            $this->rapport = $this->autorisationInscription->getRapport();
            $these = $this->rapport?->getThese();
            switch ($privilege) {
                case AutorisationInscriptionPrivileges::AUTORISATION_INSCRIPTION_AJOUTER:
                    if($this->autorisationInscription->getId()) return false;

                    $this->rapport = $this->autorisationInscription->getRapport();
                    $these = $this->rapport?->getThese();

                    if ($roleEcoleDoctorale = $this->userContextService->getSelectedRoleEcoleDoctorale()) {
                        $this->assertTrue(
                            $these->getEcoleDoctorale()->getStructure()->getId() === $roleEcoleDoctorale->getStructure()->getId(),
                            "La thèse n'est pas rattachée à l'ED " . $roleEcoleDoctorale->getStructure()->getCode()
                        );
                    }
                    return $this->canAjouterAutorisationInscription($these);
                    return $this->userContextService->isStructureDuRoleRespecteeForThese($these) && $this->canAjouterAutorisationInscription($these);
                case AutorisationInscriptionPrivileges::AUTORISATION_INSCRIPTION_ACCEDER_COMMENTAIRES:
                    return $this->userContextService->isStructureDuRoleRespecteeForThese($these);
            }

        } catch (FailedAssertionException $e) {
@@ -130,7 +125,7 @@ class AutorisationInscriptionAssertion extends AbstractAssertion implements User
    private function canAjouterAutorisationInscription(These $these): bool
    {
        //Si la thèse est importée, ne pas donner le droit de créer une autorisation d'inscription (pour l'instant)
        if($these->getSource()->getImportable()) return false;
//        if($these->getSource()->getImportable()) return false;

        $anneesInscriptionThese = array_map(function(TheseAnneeUniv $anneeUniv) {
            return $anneeUniv->getPremiereAnnee();
+6 −3
Original line number Diff line number Diff line
@@ -45,10 +45,13 @@ class AutorisationInscriptionController extends AbstractController
                $autorisationInscription = $form->getData();

                if($autorisationInscription->getThese() && $autorisationInscription->getAutorisationInscription() === true){
                    //on agit sur la thèse seulement si la thèse n'est pas importée d'un système de scolarité (Apogée...)
                    if($these->getSource()->getImportable()){
                        $theseAnneeUnivInscription = $this->theseAnneeUnivService->initFromAutorisationInscription($autorisationInscription);
                        $these->addAnneesUnivInscription($theseAnneeUnivInscription);
                        $this->theseService->saveThese($these);
                    }
                }

                $this->autorisationInscriptionService->create($autorisationInscription);
                $this->flashMessenger()->addSuccessMessage("Avis concernant l'autorisation de réinscription pour l'année {$autorisationInscription->getAnneeUniv()->getAnneeUnivToString()} effectuée avec succès.");
+1 −0
Original line number Diff line number Diff line
@@ -7,4 +7,5 @@ use UnicaenPrivilege\Provider\Privilege\Privileges;
class AutorisationInscriptionPrivileges extends Privileges
{
    public const AUTORISATION_INSCRIPTION_AJOUTER = 'autorisation-inscription-ajouter';
    public const AUTORISATION_INSCRIPTION_ACCEDER_COMMENTAIRES = 'autorisation-inscription-acceder-commentaires';
}
Loading