1
0
forked from ScoDoc/ScoDoc

fixes: modalite, ...

This commit is contained in:
Emmanuel Viennet 2021-08-09 11:33:04 +02:00
parent 379b2591fd
commit cae4686fc4
7 changed files with 29 additions and 33 deletions

View File

@ -33,7 +33,7 @@ from app.models.formations import (
from app.models.formsemestre import (
FormSemestre,
NotesFormsemestreEtape,
FormModalite,
NotesFormModalite,
NotesFormsemestreUECoef,
NotesFormsemestreUEComputationExpr,
NotesFormsemestreCustomMenu,

View File

@ -88,6 +88,7 @@ class NotesModule(db.Model):
heures_td = db.Column(db.Float)
heures_tp = db.Column(db.Float)
coefficient = db.Column(db.Float) # coef PPN
ects = db.Column(db.Float) # Crédits ECTS
ue_id = db.Column(db.Integer, db.ForeignKey("notes_ue.id"), index=True)
formation_id = db.Column(db.Integer, db.ForeignKey("notes_formations.id"))
matiere_id = db.Column(db.Integer, db.ForeignKey("notes_matieres.id"))

View File

@ -25,7 +25,7 @@ class FormSemestre(db.Model):
date_debut = db.Column(db.Date())
date_fin = db.Column(db.Date())
etat = db.Column(db.Boolean(), nullable=False, default=True) # False si verrouillé
modalite = db.Column(db.String(16), db.ForeignKey("form_modalite.modalite"))
modalite = db.Column(db.String(16), db.ForeignKey("notes_form_modalites.modalite"))
# gestion compensation sem DUT:
gestion_compensation = db.Column(db.Boolean(), nullable=False, default=False)
# ne publie pas le bulletin XML:
@ -52,7 +52,7 @@ class FormSemestre(db.Model):
def __init__(self, **kwargs):
super(FormSemestre, self).__init__(**kwargs)
if self.modalite is None:
self.modalite = FormModalite.DEFAULT_MODALITE
self.modalite = NotesFormModalite.DEFAULT_MODALITE
# Association id des utilisateurs responsables (aka directeurs des etudes) du semestre
@ -79,11 +79,13 @@ class NotesFormsemestreEtape(db.Model):
etape_apo = db.Column(db.String(APO_CODE_STR_LEN))
class FormModalite(db.Model):
class NotesFormModalite(db.Model):
"""Modalités de formation, utilisées pour la présentation
(grouper les semestres, générer des codes, etc.)
"""
__tablename__ = "notes_form_modalites"
id = db.Column(db.Integer, primary_key=True)
modalite = db.Column(db.String(16), unique=True, index=True) # code
titre = db.Column(db.Text()) # texte explicatif
@ -97,7 +99,7 @@ class FormModalite(db.Model):
"""Create default modalities"""
numero = 0
for (code, titre) in (
(FormModalite.DEFAULT_MODALITE, "Formation Initiale"),
(NotesFormModalite.DEFAULT_MODALITE, "Formation Initiale"),
("FAP", "Apprentissage"),
("FC", "Formation Continue"),
("DEC", "Formation Décalées"),
@ -108,9 +110,9 @@ class FormModalite(db.Model):
("EXT", "Extérieur"),
("OTHER", "Autres formations"),
):
modalite = FormModalite.query.filter_by(modalite=code).first()
modalite = NotesFormModalite.query.filter_by(modalite=code).first()
if modalite is None:
modalite = FormModalite(modalite=code, titre=titre, numero=numero)
modalite = NotesFormModalite(modalite=code, titre=titre, numero=numero)
db.session.add(modalite)
numero += 1
db.session.commit()
@ -249,7 +251,7 @@ class NotesEvaluation(db.Model):
id = db.Column(db.Integer, primary_key=True)
evaluation_id = db.synonym("id")
moduleimpl_id = db.Column(
db.Integer, db.ForeignKey("notes_moduleimpl.moduleimpl_id"), index=True
db.Integer, db.ForeignKey("notes_moduleimpl.id"), index=True
)
jour = db.Column(db.Date)
heure_debut = db.Column(db.Time)

View File

@ -195,10 +195,12 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
)
# Liste des ID de semestres
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute("select semestre_id from notes_semestres")
semestre_id_list = [str(x[0]) for x in cursor.fetchall()]
if F["type_parcours"] is not None:
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
NB_SEM = parcours.NB_SEM
else:
NB_SEM = 10 # fallback, max 10 semestres
semestre_id_list = [-1] + [str(x) for x in range(1, NB_SEM + 1)]
semestre_id_labels = []
for sid in semestre_id_list:
if sid == "-1":
@ -680,10 +682,10 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
if tf[0] == 0 or msg:
return (
'<p>Formation <a class="discretelink" href="ue_list?formation_id=%(formation_id)s"><em>%(titre)s</em> (%(acronyme)s), version %(version)d, code %(formation_code)s</a></p>'
'<p>Formation <a class="discretelink" href="ue_list?formation_id=%(formation_id)s"><em>%(titre)s</em> (%(acronyme)s), version %(version)s, code %(formation_code)s</a></p>'
% F
+ msg
+ tf[1]
+ str(tf[1])
)
elif tf[0] == -1:
return "<h4>annulation</h4>"

View File

@ -156,7 +156,6 @@ class SemSet(dict):
)
ndb.SimpleQuery(
self.context,
"INSERT INTO notes_semset_formsemestre (formsemestre_id, semset_id) VALUES (%(formsemestre_id)s, %(semset_id)s)",
{"formsemestre_id": formsemestre_id, "semset_id": self.semset_id},
)
@ -164,7 +163,6 @@ class SemSet(dict):
def remove(self, formsemestre_id):
ndb.SimpleQuery(
self.context,
"DELETE FROM notes_semset_formsemestre WHERE semset_id=%(semset_id)s AND formsemestre_id=%(formsemestre_id)s",
{"formsemestre_id": formsemestre_id, "semset_id": self.semset_id},
)

View File

@ -73,7 +73,9 @@ class ScoTag(object):
if not self.title:
raise ScoValueError("invalid empty tag")
r = ndb.SimpleDictFetch(
"SELECT * FROM " + self.tag_table + " WHERE title = %(title)s",
"SELECT id as tag_id, * FROM "
+ self.tag_table
+ " WHERE title = %(title)s",
{"title": self.title},
)
if r:
@ -97,8 +99,7 @@ class ScoTag(object):
"""
args = {"tag_id": self.tag_id}
ndb.SimpleQuery(
self.context,
"DELETE FROM " + self.tag_table + " t WHERE t.tag_id = %(tag_id)s",
"DELETE FROM " + self.tag_table + " t WHERE t.id = %(tag_id)s",
args,
)
@ -106,7 +107,6 @@ class ScoTag(object):
"""Associate tag to given object"""
args = {self.obj_colname: object_id, "tag_id": self.tag_id}
r = ndb.SimpleDictFetch(
self.context,
"SELECT * FROM "
+ self.assoc_table
+ " a WHERE a."
@ -120,7 +120,7 @@ class ScoTag(object):
# log("tag %s with %s" % (object_id, self.title))
cnx = ndb.GetDBConnexion()
query = f"""INSERT INTO {self.assoc_table}
(tag_id, f{self.obj_colname})
(tag_id, {self.obj_colname})
VALUES"""
ndb.SimpleQuery(
query + " (%(tag_id)s, %(object_id)s)",
@ -136,7 +136,6 @@ class ScoTag(object):
# log("removing tag %s from %s" % (self.title, object_id))
args = {"object_id": object_id, "tag_id": self.tag_id}
ndb.SimpleQuery(
self.context,
"DELETE FROM "
+ self.assoc_table
+ " a WHERE a."
@ -145,7 +144,6 @@ class ScoTag(object):
args,
)
r = ndb.SimpleDictFetch(
self.context,
"""SELECT * FROM notes_modules_tags mt WHERE tag_id = %(tag_id)s
""",
args,
@ -153,8 +151,7 @@ class ScoTag(object):
if not r:
# tag no more used, delete
ndb.SimpleQuery(
self.context,
"""DELETE FROM notes_tags t WHERE t.tag_id = %(tag_id)s""",
"""DELETE FROM notes_tags t WHERE t.id = %(tag_id)s""",
args,
)
@ -172,7 +169,6 @@ class ModuleTag(ScoTag):
if not formation_code:
# tous les modules de toutes les formations !
r = ndb.SimpleDictFetch(
self.context,
"SELECT id AS"
+ self.obj_colname
+ " FROM "
@ -184,7 +180,6 @@ class ModuleTag(ScoTag):
args["formation_code"] = formation_code
r = ndb.SimpleDictFetch(
self.context,
"""SELECT mt.module_id
FROM notes_modules_tags mt, notes_modules m, notes_formations f
WHERE mt.tag_id = %(tag_id)s
@ -220,7 +215,7 @@ def module_tag_list(context, module_id=""):
r = ndb.SimpleDictFetch(
"""SELECT t.title
FROM notes_modules_tags mt, notes_tags t
WHERE mt.tag_id = t.tag_id
WHERE mt.tag_id = t.id
AND mt.module_id = %(module_id)s
""",
{"module_id": module_id},

View File

@ -19,9 +19,8 @@ from flask.cli import with_appcontext
from app import create_app, cli, db
from app.auth.models import User, Role, UserRole
from app import models
from app.models import ScoPreferences, FormSemestre, FormModalite
from app.views import notes, scolar, absences
import app.utils as utils
@ -67,9 +66,6 @@ def make_shell_context():
"logout_user": logout_user,
"admin": admin,
"ctx": app.test_request_context(),
# "FormModalite": FormModalite,
# "ScoPreferences": ScoPreferences,
# "FormSemestre": FormSemestre,
"models": models,
}
@ -98,6 +94,8 @@ def user_db_init(): # user-db-init
u=user
)
)
# Modalités:
models.NotesFormModalite.insert_modalites()
@app.cli.command()