forked from ScoDoc/DocScoDoc
Messages erreurs quand saisie champs trop longs
This commit is contained in:
parent
9cd31e66f0
commit
9b5b4777e2
@ -4,9 +4,6 @@
|
||||
"""
|
||||
|
||||
from app import db
|
||||
from app.models import APO_CODE_STR_LEN
|
||||
from app.models import SHORT_STR_LEN
|
||||
from app.models import CODE_STR_LEN
|
||||
|
||||
|
||||
class Absence(db.Model):
|
||||
|
@ -4,9 +4,6 @@
|
||||
"""
|
||||
|
||||
from app import db
|
||||
from app.models import APO_CODE_STR_LEN
|
||||
from app.models import SHORT_STR_LEN
|
||||
from app.models import CODE_STR_LEN
|
||||
|
||||
|
||||
class Entreprise(db.Model):
|
||||
|
@ -8,9 +8,6 @@ from flask import g, url_for
|
||||
|
||||
from app import db
|
||||
from app import models
|
||||
from app.models import APO_CODE_STR_LEN
|
||||
from app.models import SHORT_STR_LEN
|
||||
from app.models import CODE_STR_LEN
|
||||
|
||||
|
||||
class Identite(db.Model):
|
||||
|
@ -4,9 +4,6 @@
|
||||
"""
|
||||
|
||||
from app import db
|
||||
from app.models import APO_CODE_STR_LEN
|
||||
from app.models import SHORT_STR_LEN
|
||||
from app.models import CODE_STR_LEN
|
||||
from app.models import UniteEns
|
||||
|
||||
import app.scodoc.notesdb as ndb
|
||||
|
@ -4,9 +4,7 @@
|
||||
"""
|
||||
|
||||
from app import db
|
||||
from app.models import APO_CODE_STR_LEN
|
||||
from app.models import SHORT_STR_LEN
|
||||
from app.models import CODE_STR_LEN
|
||||
|
||||
|
||||
class Scolog(db.Model):
|
||||
|
@ -5,9 +5,7 @@
|
||||
from typing import Any
|
||||
|
||||
from app import db
|
||||
from app.models import APO_CODE_STR_LEN
|
||||
from app.models import SHORT_STR_LEN
|
||||
from app.models import CODE_STR_LEN
|
||||
from app.models import GROUPNAME_STR_LEN
|
||||
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
"""
|
||||
|
||||
from app import db
|
||||
from app.models import APO_CODE_STR_LEN
|
||||
from app.models import SHORT_STR_LEN
|
||||
from app.models import CODE_STR_LEN
|
||||
|
||||
|
@ -265,8 +265,11 @@ def DBUpdateArgs(cnx, table, vals, where=None, commit=False, convert_empty_to_nu
|
||||
cursor.execute(req, vals)
|
||||
# log('req=%s\n'%req)
|
||||
# log('vals=%s\n'%vals)
|
||||
except psycopg2.errors.StringDataRightTruncation:
|
||||
cnx.rollback()
|
||||
raise ScoValueError("champs de texte trop long !")
|
||||
except:
|
||||
cnx.commit() # get rid of this transaction
|
||||
cnx.rollback() # get rid of this transaction
|
||||
log('Exception in DBUpdateArgs:\n\treq="%s"\n\tvals="%s"\n' % (req, vals))
|
||||
raise # and re-raise exception
|
||||
if commit:
|
||||
|
@ -33,6 +33,7 @@ from flask import g, url_for, request
|
||||
|
||||
from app import db
|
||||
from app import log
|
||||
from app.models import SHORT_STR_LEN
|
||||
from app.models.formations import Formation
|
||||
from app.models.modules import Module
|
||||
|
||||
@ -209,6 +210,7 @@ def formation_edit(formation_id=None, create=False):
|
||||
"size": 12,
|
||||
"title": "Code formation",
|
||||
"explanation": "code interne. Toutes les formations partageant le même code sont compatibles (compensation de semestres, capitalisation d'UE). Laisser vide si vous ne savez pas, ou entrer le code d'une formation existante.",
|
||||
"validator": lambda val, _: len(val) < SHORT_STR_LEN,
|
||||
},
|
||||
),
|
||||
(
|
||||
|
@ -32,6 +32,7 @@ import flask
|
||||
from flask import url_for, render_template
|
||||
from flask import g, request
|
||||
from flask_login import current_user
|
||||
from app.models import APO_CODE_STR_LEN
|
||||
from app.models import Matiere, Module, UniteEns
|
||||
|
||||
import app.scodoc.notesdb as ndb
|
||||
@ -397,21 +398,21 @@ def module_delete(module_id=None):
|
||||
return flask.redirect(dest_url)
|
||||
|
||||
|
||||
def do_module_edit(val):
|
||||
def do_module_edit(vals: dict) -> None:
|
||||
"edit a module"
|
||||
from app.scodoc import sco_edit_formation
|
||||
|
||||
# check
|
||||
mod = module_list({"module_id": val["module_id"]})[0]
|
||||
mod = module_list({"module_id": vals["module_id"]})[0]
|
||||
if module_is_locked(mod["module_id"]):
|
||||
# formation verrouillée: empeche de modifier certains champs:
|
||||
protected_fields = ("coefficient", "ue_id", "matiere_id", "semestre_id")
|
||||
for f in protected_fields:
|
||||
if f in val:
|
||||
del val[f]
|
||||
if f in vals:
|
||||
del vals[f]
|
||||
# edit
|
||||
cnx = ndb.GetDBConnexion()
|
||||
_moduleEditor.edit(cnx, val)
|
||||
_moduleEditor.edit(cnx, vals)
|
||||
Formation.query.get(mod["formation_id"]).invalidate_cached_sems()
|
||||
|
||||
|
||||
@ -604,6 +605,7 @@ def module_edit(module_id=None):
|
||||
"title": "Code Apogée",
|
||||
"size": 25,
|
||||
"explanation": "(optionnel) code élément pédagogique Apogée ou liste de codes ELP séparés par des virgules",
|
||||
"validator": lambda val, _: len(val) < APO_CODE_STR_LEN,
|
||||
},
|
||||
),
|
||||
(
|
||||
|
@ -33,6 +33,7 @@ from flask import url_for, render_template
|
||||
from flask import g, request
|
||||
from flask_login import current_user
|
||||
|
||||
from app.models import APO_CODE_STR_LEN
|
||||
from app.models import Formation, UniteEns, ModuleImpl, Module
|
||||
import app.scodoc.notesdb as ndb
|
||||
import app.scodoc.sco_utils as scu
|
||||
@ -324,6 +325,7 @@ def ue_edit(ue_id=None, create=False, formation_id=None):
|
||||
"title": "Code Apogée",
|
||||
"size": 25,
|
||||
"explanation": "(optionnel) code élément pédagogique Apogée ou liste de codes ELP séparés par des virgules",
|
||||
"validator": lambda val, _: len(val) < APO_CODE_STR_LEN,
|
||||
},
|
||||
),
|
||||
(
|
||||
|
@ -33,6 +33,7 @@ from flask_login import current_user
|
||||
|
||||
from app import db
|
||||
from app.auth.models import User
|
||||
from app.models import APO_CODE_STR_LEN, SHORT_STR_LEN
|
||||
from app.models import ModuleImpl, Evaluation, EvaluationUEPoids
|
||||
import app.scodoc.notesdb as ndb
|
||||
import app.scodoc.sco_utils as scu
|
||||
@ -359,6 +360,7 @@ def do_formsemestre_createwithmodules(edit=False):
|
||||
mf_manual = {
|
||||
"size": 12,
|
||||
"template": '<tr%(item_dom_attr)s><td class="tf-fieldlabel">%(label)s</td><td class="tf-field">%(elem)s',
|
||||
"validator": lambda val, _: len(val) < APO_CODE_STR_LEN,
|
||||
}
|
||||
if etapes:
|
||||
mf = {
|
||||
@ -495,6 +497,7 @@ def do_formsemestre_createwithmodules(edit=False):
|
||||
"size": 8,
|
||||
"title": "Couleur fond des bulletins",
|
||||
"explanation": "version web seulement (ex: #ffeeee)",
|
||||
"validator": lambda val, _: len(val) < SHORT_STR_LEN,
|
||||
},
|
||||
),
|
||||
(
|
||||
|
@ -45,6 +45,7 @@ from flask import g, request
|
||||
from flask import url_for, make_response
|
||||
|
||||
from app import db
|
||||
from app.models import GROUPNAME_STR_LEN, SHORT_STR_LEN
|
||||
from app.models.groups import Partition
|
||||
import app.scodoc.sco_utils as scu
|
||||
import app.scodoc.notesdb as ndb
|
||||
@ -870,10 +871,11 @@ def editPartitionForm(formsemestre_id=None):
|
||||
page_title="Partitions...",
|
||||
javascripts=["js/editPartitionForm.js"],
|
||||
),
|
||||
# limite à SHORT_STR_LEN
|
||||
r"""<script type="text/javascript">
|
||||
function checkname() {
|
||||
var val = document.editpart.partition_name.value.replace(/^\s+/, "").replace(/\s+$/, "");
|
||||
if (val.length > 0) {
|
||||
if ((val.length > 0)&&(val.length < 32)) {
|
||||
document.editpart.ok.disabled = false;
|
||||
} else {
|
||||
document.editpart.ok.disabled = true;
|
||||
@ -1124,6 +1126,7 @@ def partition_rename(partition_id):
|
||||
"default": partition["partition_name"],
|
||||
"allow_null": False,
|
||||
"size": 12,
|
||||
"validator": lambda val, _: len(val) < SHORT_STR_LEN,
|
||||
},
|
||||
),
|
||||
),
|
||||
@ -1231,6 +1234,7 @@ def group_rename(group_id):
|
||||
"default": group["group_name"],
|
||||
"size": 12,
|
||||
"allow_null": False,
|
||||
"validator": lambda val, _: len(val) < GROUPNAME_STR_LEN,
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -256,6 +256,10 @@ function createGroup() {
|
||||
alert("Nom de groupe vide !");
|
||||
return false;
|
||||
}
|
||||
if (group_name.length >= 32) { // SHORT_STR_LEN
|
||||
alert("Nom de groupe trop long !");
|
||||
return false;
|
||||
}
|
||||
// check name:
|
||||
for (var group_id in groupBoxes) {
|
||||
if (group_id != 'extend') {
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
{# -*- mode: jinja-html -*- #}
|
||||
{{ sco_header|safe }}
|
||||
<h2 class="formsemestre">Affectation aux groupes de {{ partition["partition_name"] }}</h2>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user