+++ /dev/null
-/*
- * Copyright © FYLAB and the Conseil Régional d'Île-de-France, 2009
- * This file is part of L'Interface Libre et Interactive de l'Enseignement (Lilie).
- *
- * Lilie is free software. You can redistribute it and/or modify since
- * you respect the terms of either (at least one of the both license) :
- * - under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- * - the CeCILL-C as published by CeCILL-C; either version 1 of the
- * License, or any later version
- *
- * There are special exceptions to the terms and conditions of the
- * licenses as they are applied to this software. View the full text of
- * the exception in file LICENSE.txt in the directory of this software
- * distribution.
- *
- * Lilie is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * Licenses for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the CeCILL-C along with Lilie. If not, see :
- * <http://www.gnu.org/licenses/> and
- * <http://www.cecill.info/licences.fr.html>.
- */
-
-package org.lilie.services.eliot.notes.domaine
-
-import grails.converters.JSON
-import org.lilie.services.eliot.notes.appreciation.ModeleAppreciationProfesseurService
-import org.lilie.services.eliot.notes.AbstractNotesController
-import org.lilie.services.eliot.notes.ModeleAppreciationProfesseur
-import org.lilie.services.eliot.notes.NotesDroitService
-import org.lilie.services.eliot.notes.ActionEnum
-import org.springframework.dao.DataIntegrityViolationException
-import org.lilie.services.eliot.notes.NotesFonction
-
-class ModeleAppreciationProfesseurController extends AbstractNotesController {
-
- NotesDroitService notesDroitService
- ModeleAppreciationProfesseurService modeleAppreciationProfesseurService
-
- /**
- * Liste les appréciations de l'enseignant
- */
- def liste = {
-
- notesDroitService.verifieAutorisationByEtablissement(
- securiteSession,
- etablissementCourant(),
- ActionEnum.CONSULTATION,
- (List) (NotesFonction.ENSEIGNANT_ASSIMILE +
- NotesFonction.DIRECTION_ASSIMILE
- )
- )
-
- Map result = tryCatch {
- modeleAppreciationProfesseurService.findAll(securiteSession)
- }
-
- render result as JSON
- }
-
- /**
- * Crée un nouveau modèle d'appréciation
- */
- def cree = {
-
- notesDroitService.verifieAutorisationByEtablissement(
- securiteSession,
- etablissementCourant(),
- ActionEnum.CREATION,
- (List) (NotesFonction.ENSEIGNANT_ASSIMILE +
- NotesFonction.DIRECTION_ASSIMILE
- )
- )
-
- Map result = tryCatch {
-
- ModeleAppreciationProfesseur modeleAppreciationProfesseur = null
- String texte = params.texte
-
- if (texte) {
- try {
- modeleAppreciationProfesseur = modeleAppreciationProfesseurService.cree(
- securiteSession,
- texte)
- }
- catch (DataIntegrityViolationException ex) {
- return [
- success: false,
- message: message(code: 'eliot.notes.message.modeleAppreciationExisteDeja')
- ]
- }
- }
-
- return [appreciationId: modeleAppreciationProfesseur?.id]
- }
-
- render result as JSON
- }
-
- /**
- * Supprime un modèle d'appréciation
- */
- def supprime = {
-
- notesDroitService.verifieAutorisationByEtablissement(
- securiteSession,
- etablissementCourant(),
- ActionEnum.SUPPRESSION,
- (List) (NotesFonction.ENSEIGNANT_ASSIMILE +
- NotesFonction.DIRECTION_ASSIMILE
- )
- )
-
- Map result = tryCatch {
-
- Long appreciationId = params.appreciationId ? Long.parseLong(params.appreciationId) : null
-
- ModeleAppreciationProfesseur modeleAppreciationProfesseur = ModeleAppreciationProfesseur.get(appreciationId)
-
- if (modeleAppreciationProfesseur) {
- modeleAppreciationProfesseurService.supprime(
- securiteSession,
- modeleAppreciationProfesseur
- )
- }
- }
-
- render result as JSON
- }
-
-}