Commit ac10e5ae authored by Thomas Hamel's avatar Thomas Hamel
Browse files

fix établissement incorrect pour un doctorant lorsque la thèse était saisie dans sygal, maj sql

parent d24b67aa
Loading
Loading
Loading
Loading
+34 −1
Changes for doc/release-notes/8.x.0/01_saisie_these.sql: 34 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -3,6 +3,13 @@
-- Modifications à effectuer afin de pouvoir saisir une thèse dans SyGAL de A à Z.
--

--
-- Suppression préalable des vues matérialisées d'indicateurs.
--
-- Indicateur devenu inutile
DELETE FROM INDICATEUR where id = 1;
call unicaen_indicateur_delete_matviews();

--
-- Table ACTEUR
--
@@ -218,11 +225,11 @@ WHERE ds.libelle = t.lib_disc;
-- ALTER TABLE these DROP COLUMN lib_disc;

-- Colonnes devenues inutiles
-- Attention certaines colonnes sont utilisées dans des vues (Utiliser le script 03_matviews.sql présent ici : doc/release-notes/8.4.0)
ALTER TABLE these DROP COLUMN if exists besoin_expurge;
ALTER TABLE these DROP COLUMN if exists cod_unit_rech;
ALTER TABLE these DROP COLUMN if exists lib_unit_rech;
ALTER TABLE these DROP COLUMN if exists source_code_sav;

-- Supprimer la vue utilisant le champ date_autoris_soutenance
DROP VIEW if exists v_diff_these;
ALTER TABLE these DROP COLUMN if exists date_autoris_soutenance;
@@ -750,3 +757,29 @@ where exists (
    where p.code in ('lister-sien', 'telecharger-sien') and categorie_id in (select id from categorie_privilege where code LIKE 'rapport-csi')
      and pp.profil_id = pp1.profil_id and pp.privilege_id = pp1.privilege_id
);

--
-- Rétablissement des vues matérialisées d'indicateurs.
--
create or replace procedure unicaen_indicateur_recreate_matviews()
    language plpgsql
as $$declare
    v_result indicateur;
    v_name varchar;
    v_template varchar = 'create materialized view %s as %s';
begin
    raise notice '%', 'Création des vues matérialisées manquantes...';
for v_result in
select i.* from indicateur i
                    left join pg_matviews mv on schemaname = 'public' and matviewname = 'mv_indicateur_'||i.id
where mv.matviewname is null
order by i.id
    loop
            v_name = 'mv_indicateur_'||v_result.id;
raise notice '%', format('- %s...', v_name);
execute format(v_template, v_name, v_result.requete);
end loop;
    raise notice '%', 'Terminé.';
end
$$;
call unicaen_indicateur_recreate_matviews();
 No newline at end of file
+10 −8
Changes for module/Doctorant/src/Doctorant/Service/DoctorantService.php: 10 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -9,14 +9,12 @@ use Application\Service\Source\SourceServiceAwareTrait;
use Application\SourceCodeStringHelperAwareTrait;
use Doctorant\Entity\Db\Doctorant;
use Doctorant\Entity\Db\Repository\DoctorantRepository;
use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\ORMException;
use Individu\Entity\Db\Individu;
use Individu\Service\IndividuServiceAwareTrait;
use RuntimeException;
use Structure\Entity\Db\Etablissement;
use Structure\Service\Etablissement\EtablissementServiceAwareTrait;
use UnicaenApp\Exception\RuntimeException;

class DoctorantService extends BaseService
{
@@ -116,14 +114,18 @@ class DoctorantService extends BaseService
        try {
            $this->entityManager->persist($doctorant);
            $this->entityManager->flush();
        } catch (\Doctrine\ORM\Exception\ORMException $e) {
            throw new \UnicaenApp\Exception\RuntimeException("Erreur lors de l'enregistrement du nouvel individu", null, $e);
        } catch (ORMException $e) {
            throw new RuntimeException("Erreur lors de l'enregistrement du nouvel individu", null, $e);
        }
    }

    public function newDoctorant(Individu $individu)
    public function newDoctorant(Individu $individu, Etablissement $etablissement): Doctorant
    {
        $etablissement = $this->etablissementService->getRepository()->find(1);
        try {
            $etablissement = $this->etablissementService->getRepository()->find($etablissement->getId());
        } catch (RuntimeException $e) {
            throw new RuntimeException("Aucun établissement de trouvé avec cet id", null, $e);
        }

        $doctorant = new Doctorant();
        $doctorant->setIndividu($individu);
+9 −10
Changes for module/These/src/These/Controller/TheseSaisieController.php: 9 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ use Doctorant\Service\DoctorantServiceAwareTrait;
use Individu\Service\IndividuServiceAwareTrait;
use Laminas\Form\FieldsetInterface;
use Laminas\Form\Form;
use Laminas\Http\Response;
use Laminas\View\Model\ViewModel;
use These\Entity\Db\These;
use These\Form\Direction\DirectionFormAwareTrait;
@@ -57,11 +58,9 @@ class TheseSaisieController extends AbstractController
        $these = $form->getData();
        $individu = $data["generalites"]['doctorant']["id"] ? $this->individuService->getRepository()->find($data["generalites"]['doctorant']["id"]) : null;
        if ($individu) {
            $doctorant = $this->doctorantService->newDoctorant($individu);
            $etablissement = $these->getEtablissement();
            $doctorant = $this->doctorantService->newDoctorant($individu, $etablissement);
            $these->setDoctorant($doctorant);
            //Ajout du rôle doctorant à l'individu
            $role = $this->roleService->getRepository()->findByCode(Role::CODE_DOCTORANT);
            $this->roleService->addRole($individu, $role->getId());
        }
        $this->theseService->saveThese($these);

@@ -108,7 +107,7 @@ class TheseSaisieController extends AbstractController

        $this->flashMessenger()->addSuccessMessage("Thèse modifiée avec succès.");

//        return $this->redirect()->toRoute('these/identite', ['these' => $these->getId()], [], true);
        return $this->redirect()->toRoute('these/identite', ['these' => $these->getId()], [], true);
    }

    private function getErrorMessages(): array
@@ -153,27 +152,27 @@ class TheseSaisieController extends AbstractController
        return $messages;
    }

    public function generalitesAction()
    public function generalitesAction(): Response|ViewModel
    {
        return $this->modifierTheseSaisiePart($this->getGeneralitesForm(), 'generalites');
    }

    public function structuresAction()
    public function structuresAction(): Response|ViewModel
    {
        return $this->modifierTheseSaisiePart($this->getStructuresForm(), 'structures');
    }

    public function directionAction()
    public function directionAction(): Response|ViewModel
    {
        return $this->modifierTheseSaisiePart($this->getDirectionForm(), 'direction');
    }

    public function financementsAction()
    public function financementsAction(): Response|ViewModel
    {
        return $this->modifierTheseSaisiePart($this->getFinancementsForm(), 'financements');
    }

    private function modifierTheseSaisiePart(Form $form, string $domaine)
    private function modifierTheseSaisiePart(Form $form, string $domaine): Response|ViewModel
    {
        $request = $this->getRequest();
        $these = $this->requestedThese();