forked from ScoDoc/ScoDoc
moduleimpl_status: affect modules sans resp. au resp. du formsemestre
This commit is contained in:
parent
612f95efaa
commit
7473334387
@ -33,7 +33,7 @@ import datetime
|
||||
from flask import g, render_template, url_for
|
||||
from flask_login import current_user
|
||||
|
||||
from app import db
|
||||
from app import db, log
|
||||
from app.auth.models import User
|
||||
from app.comp import res_sem
|
||||
from app.comp.res_common import ResultatsSemestre
|
||||
@ -43,6 +43,7 @@ import app.scodoc.sco_utils as scu
|
||||
from app.scodoc import sco_assiduites as scass
|
||||
from app.scodoc.codes_cursus import UE_SPORT
|
||||
from app.scodoc.sco_cursus_dut import formsemestre_has_decisions
|
||||
from app.scodoc.sco_exceptions import ScoValueError
|
||||
from app.scodoc.sco_permissions import Permission
|
||||
|
||||
from app.scodoc import htmlutils
|
||||
@ -250,6 +251,22 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
|
||||
arrow_up, arrow_down, arrow_none = sco_groups.get_arrow_icons_tags()
|
||||
#
|
||||
module_resp = db.session.get(User, modimpl.responsable_id)
|
||||
if module_resp is None:
|
||||
# l'utilisateur a été supprimé par erreur
|
||||
# ré-affecte le module au 1er resp. du semestre
|
||||
if modimpl.formsemestre.responsables:
|
||||
log(
|
||||
f"""Modimpl resp. {modimpl} suppressed: affecting to {
|
||||
modimpl.formsemestre.responsables[0]}"""
|
||||
)
|
||||
modimpl.responsable_id = modimpl.formsemestre.responsables[0].id
|
||||
db.session.add(modimpl)
|
||||
db.session.commit()
|
||||
else:
|
||||
raise ScoValueError(
|
||||
"Module et semestre sans responsables: contacter l'assistance"
|
||||
)
|
||||
|
||||
mod_type_name = scu.MODULE_TYPE_NAMES[module.module_type]
|
||||
H = [
|
||||
f"""<h2 class="formsemestre">{mod_type_name}
|
||||
|
Loading…
Reference in New Issue
Block a user