Commit 54dd445c authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

[FIX] Validation de la version corrigée de la thèse par le président du jury :...

[FIX] Validation de la version corrigée de la thèse par le président du jury : améliorations (transaction bdd, remontée erreur, messages).
parent cba3f46f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ Journal des modifications
- [FIX] Utilisation de UrlService (plutôt que UrlHelper) pour générer l'URL d'usurpation d'identité à partir d'un individu.
- [FIX] Notifications Admission et Formation
- [FIX] Erreur lors de l'envoi de la notif 'Demande des pré-rapports de soutenance' (variable 'rapporteur' non transmise à UrlService).
- [FIX] Validation de la version corrigée de la thèse par le président du jury : améliorations (transaction bdd, remontée erreur, messages).

9.2.0
-----
+5 −0
Original line number Diff line number Diff line
<?php

namespace Depot;

use Depot\Assertion\These\TheseAssertion;
use Depot\Controller\Factory\ValidationControllerFactory;
use Depot\Controller\ValidationController;
use Depot\Process\Validation\DepotValidationProcess;
use Depot\Process\Validation\DepotValidationProcessFactory;
use Depot\Provider\Privilege\DepotPrivileges;
use Depot\Provider\Privilege\ValidationPrivileges;
use Depot\Service\Validation\DepotValidationService;
@@ -170,6 +174,7 @@ return [
    'service_manager' => [
        'factories' => [
            DepotValidationService::class => DepotValidationServiceFactory::class,
            DepotValidationProcess::class => DepotValidationProcessFactory::class,
        ],
    ],
    'controllers' => [
+5 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ use Application\Service\Role\RoleService;
use Application\Service\Utilisateur\UtilisateurService;
use Application\Service\Validation\ValidationService;
use Depot\Controller\ValidationController;
use Depot\Process\Validation\DepotValidationProcess;
use Depot\Service\Notification\DepotNotificationFactory;
use Depot\Service\These\DepotService;
use Depot\Service\Validation\DepotValidationService;
@@ -50,6 +51,10 @@ class ValidationControllerFactory implements FactoryInterface
        $depotNotificationFactory = $container->get(DepotNotificationFactory::class);
        $controller->setDepotNotificationFactory($depotNotificationFactory);

        /** @var DepotValidationProcess $depotValidationProcess */
        $depotValidationProcess = $container->get(DepotValidationProcess::class);
        $controller->setDepotValidationProcess($depotValidationProcess);

        return $controller;
    }
}
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ use These\Entity\Db\These;
 * @method modifierRdvBuUrl(These $these)
 * @method validerRdvBuUrl(These $these)
 * @method devaliderRdvBuUrl(These $these)
 * @method validationTheseCorrigeeUrl(These $these)
 * @method validationDepotTheseCorrigeeUrl(These $these)
 * @method validationCorrectionTheseUrl(These $these)
 * @method validerDepotTheseCorrigeeUrl(These $these)
+25 −64
Original line number Diff line number Diff line
@@ -7,10 +7,13 @@ use Application\Entity\Db\TypeValidation;
use Application\Service\Role\ApplicationRoleServiceAwareTrait;
use Application\Service\Utilisateur\UtilisateurServiceAwareTrait;
use Application\Service\Validation\ValidationServiceAwareTrait;
use Depot\Process\Validation\DepotValidationProcessAwareTrait;
use Depot\Provider\Privilege\ValidationPrivileges;
use Depot\Service\Notification\DepotNotificationFactoryAwareTrait;
use Depot\Service\These\DepotServiceAwareTrait;
use Depot\Service\Validation\DepotValidationServiceAwareTrait;
use Exception;
use Laminas\Http\Response;
use Laminas\View\Model\ViewModel;
use Notification\Service\NotifierServiceAwareTrait;
use These\Entity\Db\Acteur;
@@ -27,9 +30,12 @@ class ValidationController extends AbstractController
    use UtilisateurServiceAwareTrait;
    use DepotServiceAwareTrait;
    use ValidationServiceAwareTrait;
    use DepotValidationProcessAwareTrait;

    public function pageDeCouvertureAction(): ViewModel
    {
        // todo : utiliser un process pour remonter les erreurs proprement, cf. modifierValidationCorrectionTheseAction()

        $these = $this->requestedThese();
        $result = $this->confirm()->execute();
        $action = $this->params()->fromQuery('action');
@@ -82,6 +88,8 @@ class ValidationController extends AbstractController

    public function rdvBuAction()
    {
        // todo : utiliser un process pour remonter les erreurs proprement, cf. modifierValidationCorrectionTheseAction()

        $these = $this->requestedThese();
        $result = $this->confirm()->execute();
        $action = $this->params()->fromQuery('action');
@@ -172,6 +180,8 @@ class ValidationController extends AbstractController

    public function modifierValidationDepotTheseCorrigeeAction(): ViewModel
    {
        // todo : utiliser un process pour remonter les erreurs proprement, cf. modifierValidationCorrectionTheseAction()

        $these = $this->requestedThese();
        $result = $this->confirm()->execute();
        $action = $this->params()->fromQuery('action');
@@ -222,86 +232,37 @@ class ValidationController extends AbstractController
        return $viewModel;
    }

    public function modifierValidationCorrectionTheseAction()
    public function modifierValidationCorrectionTheseAction(): Response
    {
        $these = $this->requestedThese();
        $result = $this->confirm()->execute();
        $action = $this->params()->fromQuery('action');

        $notificationLogs = [];

        // si un tableau est retourné par le plugin, l'opération a été confirmée
        if (is_array($result)) {
        try {
            if ($action === 'valider') {
                $this->assertIsAllowed($these, ValidationPrivileges::VALIDATION_CORRECTION_THESE);

                $validation = $this->depotValidationService->validateCorrectionThese($these);
                $validation = $this->depotValidationProcess->validateCorrectionThese($these);
                $successMessage = "Validation enregistrée avec succès.";

                // notification par mail si plus aucune validation attendue
                $results = $this->depotValidationService->getValidationsAttenduesPourCorrectionThese($these);
                if (count($results) === 0) {
                    //Met à jour le témoin correction effectuée pour une thèse provenant de SyGAL
                    if(!$these->getSource()->getImportable()){
                        $these->setCorrectionEffectuee("O");
                        $this->theseService->update($these);
                    }
                    // notification de la MDD
                    $notification = $this->depotNotificationFactory->createNotificationValidationCorrectionThese($these);
                    $notificationResult = $this->notifierService->trigger($notification);
                    $notificationLogs = array_merge_recursive($notificationLogs, array_filter([
                        'success' => $notificationResult->getSuccessMessages(),
                        'danger' => $notificationResult->getErrorMessages(),
                    ]));

                    // notification du doctorant
                    try {
                        $notification = $this->depotNotificationFactory->createNotificationValidationCorrectionTheseEtudiant($these);
                        $notificationResult = $this->notifierService->trigger($notification);
                        $notificationLogs = array_merge_recursive($notificationLogs, array_filter([
                            'success' => $notificationResult->getSuccessMessages(),
                            'danger' => $notificationResult->getErrorMessages(),
                        ]));
                    } catch (\Notification\Exception\RuntimeException $e) {
                        $notificationLogs = array_merge_recursive($notificationLogs, [
                            'danger' => $e->getMessage(),
                        ]);
                    }
                }
            }
            elseif ($action === 'devalider') {
            } elseif ($action === 'devalider') {
                $this->assertIsAllowed($these, ValidationPrivileges::VALIDATION_CORRECTION_THESE_SUPPR);

                $validation = $this->depotValidationService->unvalidateCorrectionThese($these);
                $validation = $this->depotValidationProcess->unvalidateCorrectionThese($these);
                $successMessage = "Validation annulée avec succès.";

                // pas de notification par mail
            }
            else {
            } else {
                throw new RuntimeException("Action inattendue!");
            }
            $this->flashMessenger()->addSuccessMessage($successMessage);
        } catch (Exception $e) {
            $this->flashMessenger()->addErrorMessage("Validation impossible. " . $e->getMessage());
        }

            $tvCode = $validation->getTypeValidation()->getCode();
            $this->flashMessenger()->addMessage($successMessage, "$tvCode/success");

        $notificationLogs = $this->depotValidationProcess->getNotificationLogs();
        if (isset($notificationLogs['info'])) {
                $this->flashMessenger()->addMessage($notificationLogs['success'], "$tvCode/info");
            $this->flashMessenger()->addInfoMessage($notificationLogs['success']);
        }
        if (isset($notificationLogs['danger'])) {
                $this->flashMessenger()->addMessage($notificationLogs['danger'], "$tvCode/danger");
            }
            $this->flashMessenger()->addErrorMessage($notificationLogs['danger']);
        }

        // récupération du modèle de vue auprès du plugin et passage de variables classique
        $viewModel = $this->confirm()->getViewModel();

        $viewModel->setVariables([
            'title'  => "Validation des corrections de la thèse",
            'these'  => $these,
            'action' => $action,
        ]);

        $viewModel->setTemplate('depot/validation/these-corrigee/modifier-validation-correction');

        return $viewModel;
        return $this->redirect()->toUrl($this->urlDepot()->validationTheseCorrigeeUrl($these));
    }
}
 No newline at end of file
Loading