ScoDoc/app/scodoc/sco_edit_apc.py
2021-11-17 10:28:51 +01:00

123 lines
4.2 KiB
Python

##############################################################################
#
# ScoDoc
#
# Copyright (c) 1999 - 2021 Emmanuel Viennet. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Emmanuel Viennet emmanuel.viennet@viennet.net
#
##############################################################################
"""Édition formation APC (BUT)
"""
import flask
from flask import url_for, render_template
from flask import g, request
from flask_login import current_user
from app.models.formations import Formation, UniteEns, Matiere, Module
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
from app.scodoc import sco_groups
from app.scodoc.sco_utils import ModuleType
def html_edit_formation_apc(
formation,
editable=True,
tag_editable=True,
):
"""Formulaire html pour visualisation ou édition d'une formation APC.
- Les UEs
- Les ressources
- Les SAÉs
"""
parcours = formation.get_parcours()
assert parcours.APC_SAE
ressources = formation.modules.filter_by(module_type=ModuleType.RESSOURCE)
saes = formation.modules.filter_by(module_type=ModuleType.SAE)
other_modules = formation.modules.filter(
Module.module_type != ModuleType.SAE
and Module.module_type != ModuleType.RESSOURCE
)
arrow_up, arrow_down, arrow_none = sco_groups.get_arrow_icons_tags()
delete_icon = scu.icontag(
"delete_small_img", title="Supprimer (module inutilisé)", alt="supprimer"
)
delete_disabled_icon = scu.icontag(
"delete_small_dis_img", title="Suppression impossible (module utilisé)"
)
H = [
render_template(
"pn/form_ues.html",
formation=formation,
editable=editable,
arrow_up=arrow_up,
arrow_down=arrow_down,
arrow_none=arrow_none,
delete_icon=delete_icon,
delete_disabled_icon=delete_disabled_icon,
),
render_template(
"pn/form_mods.html",
formation=formation,
titre="Ressources",
create_element_msg="créer une nouvelle ressource",
modules=ressources,
module_type=ModuleType.RESSOURCE,
editable=editable,
arrow_up=arrow_up,
arrow_down=arrow_down,
arrow_none=arrow_none,
delete_icon=delete_icon,
delete_disabled_icon=delete_disabled_icon,
scu=scu,
),
render_template(
"pn/form_mods.html",
formation=formation,
titre="Situations d'Apprentissage et d'Évaluation (SAÉs)",
create_element_msg="créer une nouvelle SAÉ",
modules=saes,
module_type=ModuleType.SAE,
editable=editable,
arrow_up=arrow_up,
arrow_down=arrow_down,
arrow_none=arrow_none,
delete_icon=delete_icon,
delete_disabled_icon=delete_disabled_icon,
scu=scu,
),
render_template(
"pn/form_mods.html",
formation=formation,
titre="Autres modules (non BUT)",
create_element_msg="créer un nouveau module",
modules=other_modules,
module_type=ModuleType.STANDARD,
editable=editable,
arrow_up=arrow_up,
arrow_down=arrow_down,
arrow_none=arrow_none,
delete_icon=delete_icon,
delete_disabled_icon=delete_disabled_icon,
scu=scu,
),
]
return "\n".join(H)