forked from ScoDoc/ScoDoc
Fixes #70
This commit is contained in:
parent
4a5d4adee1
commit
9e65fa7654
@ -251,8 +251,8 @@ class exUserFolder(Folder,BasicUserFolder,BasicGroupFolderMixin,
|
|||||||
('Manager',)),
|
('Manager',)),
|
||||||
|
|
||||||
('View', ('manage_changePassword',
|
('View', ('manage_changePassword',
|
||||||
'manage_forgotPassword', 'docLogin','docLoginRedirect',
|
'manage_forgotPassword','docLoginRedirect',
|
||||||
'docLogout', 'logout', 'DialogHeader',
|
'logout', 'DialogHeader',
|
||||||
'DialogFooter', 'manage_signupUser',
|
'DialogFooter', 'manage_signupUser',
|
||||||
'MessageDialog', 'redirectToLogin','manage_changeProps'),
|
'MessageDialog', 'redirectToLogin','manage_changeProps'),
|
||||||
('Anonymous', 'Authenticated', 'Manager')),
|
('Anonymous', 'Authenticated', 'Manager')),
|
||||||
@ -269,7 +269,7 @@ class exUserFolder(Folder,BasicUserFolder,BasicGroupFolderMixin,
|
|||||||
('Access contents information', ('hasProperty', 'propertyIds',
|
('Access contents information', ('hasProperty', 'propertyIds',
|
||||||
'propertyValues','propertyItems',
|
'propertyValues','propertyItems',
|
||||||
'getProperty', 'getPropertyType',
|
'getProperty', 'getPropertyType',
|
||||||
'propertyMap', 'docLogin','docLoginRedirect',
|
'propertyMap', 'docLoginRedirect',
|
||||||
'DialogHeader', 'DialogFooter',
|
'DialogHeader', 'DialogFooter',
|
||||||
'MessageDialog', 'redirectToLogin',),
|
'MessageDialog', 'redirectToLogin',),
|
||||||
('Anonymous', 'Authenticated', 'Manager')),
|
('Anonymous', 'Authenticated', 'Manager')),
|
||||||
|
64
config/fix_bug70_db.py
Normal file
64
config/fix_bug70_db.py
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
# -*- mode: python -*-
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""Fix bug #70
|
||||||
|
|
||||||
|
Utiliser comme:
|
||||||
|
scotests/scointeractive.sh DEPT config/fix_bug70_db.py
|
||||||
|
|
||||||
|
"""
|
||||||
|
context = context.Notes # pylint: disable=undefined-variable
|
||||||
|
REQUEST = REQUEST # pylint: disable=undefined-variable
|
||||||
|
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import sco_utils
|
||||||
|
import notesdb
|
||||||
|
import sco_formsemestre
|
||||||
|
import sco_formsemestre_edit
|
||||||
|
import sco_moduleimpl
|
||||||
|
|
||||||
|
G = sco_fake_gen.ScoFake(context.Notes)
|
||||||
|
|
||||||
|
|
||||||
|
def fix_formsemestre_formation_bug70(formsemestre_id):
|
||||||
|
"""Le bug #70 a pu entrainer des incohérences
|
||||||
|
lors du clonage avorté de semestres.
|
||||||
|
Cette fonction réassocie le semestre à la formation
|
||||||
|
à laquelle appartiennent ses modulesimpls.
|
||||||
|
2021-04-23
|
||||||
|
"""
|
||||||
|
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
|
||||||
|
cursor = notesdb.SimpleQuery(
|
||||||
|
context,
|
||||||
|
"""SELECT m.formation_id
|
||||||
|
FROM notes_modules m, notes_moduleimpl mi
|
||||||
|
WHERE mi.module_id = m.module_id
|
||||||
|
AND mi.formsemestre_id = %(formsemestre_id)s
|
||||||
|
""",
|
||||||
|
{"formsemestre_id": formsemestre_id},
|
||||||
|
)
|
||||||
|
modimpls_formations = set([x[0] for x in cursor])
|
||||||
|
if len(modimpls_formations) > 1:
|
||||||
|
# this is should not occur
|
||||||
|
G.log(
|
||||||
|
"Warning: fix_formsemestre_formation_bug70: modules from several formations in sem %s"
|
||||||
|
% formsemestre_id
|
||||||
|
)
|
||||||
|
elif len(modimpls_formations) == 1:
|
||||||
|
modimpls_formation_id = modimpls_formations.pop()
|
||||||
|
if modimpls_formation_id != sem["formation_id"]:
|
||||||
|
# Bug #70: fix
|
||||||
|
G.log("fix_formsemestre_formation_bug70: fixing %s" % formsemestre_id)
|
||||||
|
sem["formation_id"] = modimpls_formation_id
|
||||||
|
context.do_formsemestre_edit(sem, html_quote=False)
|
||||||
|
|
||||||
|
|
||||||
|
formsemestre_ids = [
|
||||||
|
x[0]
|
||||||
|
for x in notesdb.SimpleQuery(
|
||||||
|
context, "SELECT formsemestre_id FROM notes_formsemestre", {}
|
||||||
|
)
|
||||||
|
]
|
||||||
|
for formsemestre_id in formsemestre_ids:
|
||||||
|
fix_formsemestre_formation_bug70(formsemestre_id)
|
18
config/postupgrade.py
Executable file → Normal file
18
config/postupgrade.py
Executable file → Normal file
@ -11,15 +11,16 @@ _before_ upgrading the database.
|
|||||||
E. Viennet, June 2008
|
E. Viennet, June 2008
|
||||||
Mar 2017: suppress upgrade of very old Apache configs
|
Mar 2017: suppress upgrade of very old Apache configs
|
||||||
Aug 2020: move photos to .../var/scodoc/
|
Aug 2020: move photos to .../var/scodoc/
|
||||||
|
Apr 2021: bug #70
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import glob
|
import glob
|
||||||
import shutil
|
import shutil
|
||||||
from scodocutils import log, SCODOC_DIR, SCODOC_VAR_DIR, SCODOC_LOGOS_DIR
|
from scodocutils import log, SCODOC_DIR, SCODOC_VAR_DIR, SCODOC_LOGOS_DIR, SCO_TMPDIR
|
||||||
|
|
||||||
if os.getuid() != 0:
|
if os.getuid() != 0:
|
||||||
log('postupgrade.py: must be run as root')
|
log("postupgrade.py: must be run as root")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
@ -54,6 +55,19 @@ for d in glob.glob( SCODOC_DIR + "/logos_*" ):
|
|||||||
log("Moving %s to %s" % (d, SCODOC_LOGOS_DIR))
|
log("Moving %s to %s" % (d, SCODOC_LOGOS_DIR))
|
||||||
shutil.move(d, SCODOC_LOGOS_DIR)
|
shutil.move(d, SCODOC_LOGOS_DIR)
|
||||||
|
|
||||||
|
# Fix bug #70
|
||||||
|
depts = [
|
||||||
|
os.path.splitext(os.path.basename(f))[0] for f in glob.glob(depts_dir + "/*.cfg")
|
||||||
|
]
|
||||||
|
for dept in depts:
|
||||||
|
fixed_filename = SCO_TMPDIR + "/.%s_bug70_fixed" % dept
|
||||||
|
if not os.path.exists(fixed_filename):
|
||||||
|
log("fixing #70 on %s" % dept)
|
||||||
|
os.system("../scotests/scointeractive.sh -x %s config/fix_bug70_db.py" % dept)
|
||||||
|
# n'essaie qu'une foixs, même en cas d'échec
|
||||||
|
f = open(fixed_filename, "a")
|
||||||
|
f.close()
|
||||||
|
|
||||||
# Continue here...
|
# Continue here...
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
|
1
config/scodocutils.py
Normal file → Executable file
1
config/scodocutils.py
Normal file → Executable file
@ -30,6 +30,7 @@ SCODOC_VAR_DIR = os.environ.get("SCODOC_VAR_DIR", "")
|
|||||||
if not SCODOC_VAR_DIR:
|
if not SCODOC_VAR_DIR:
|
||||||
log("Error: environment variable SCODOC_VAR_DIR is not defined")
|
log("Error: environment variable SCODOC_VAR_DIR is not defined")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
SCO_TMPDIR = os.path.join(SCODOC_VAR_DIR, "tmp")
|
||||||
SCODOC_LOGOS_DIR = os.environ.get("SCODOC_LOGOS_DIR", "")
|
SCODOC_LOGOS_DIR = os.environ.get("SCODOC_LOGOS_DIR", "")
|
||||||
|
|
||||||
|
|
||||||
|
6
debug.py
6
debug.py
@ -57,17 +57,19 @@ import sco_bulletins_xml
|
|||||||
# Prend le premier departement comme context
|
# Prend le premier departement comme context
|
||||||
|
|
||||||
|
|
||||||
def go(app, n=0):
|
def go(app, n=0, verbose=True):
|
||||||
context = app.ScoDoc.objectValues("Folder")[n].Scolarite
|
context = app.ScoDoc.objectValues("Folder")[n].Scolarite
|
||||||
|
if verbose:
|
||||||
print("context in dept ", context.DeptId())
|
print("context in dept ", context.DeptId())
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
def go_dept(app, dept):
|
def go_dept(app, dept, verbose=True):
|
||||||
objs = app.ScoDoc.objectValues("Folder")
|
objs = app.ScoDoc.objectValues("Folder")
|
||||||
for o in objs:
|
for o in objs:
|
||||||
context = o.Scolarite
|
context = o.Scolarite
|
||||||
if context.DeptId() == dept:
|
if context.DeptId() == dept:
|
||||||
|
if verbose:
|
||||||
print("context in dept ", context.DeptId())
|
print("context in dept ", context.DeptId())
|
||||||
return context
|
return context
|
||||||
raise ValueError("dep %s not found" % dept)
|
raise ValueError("dep %s not found" % dept)
|
||||||
|
@ -1132,6 +1132,9 @@ class NotesTable:
|
|||||||
|
|
||||||
def sem_has_decisions(self):
|
def sem_has_decisions(self):
|
||||||
"""True si au moins une decision de jury dans ce semestre"""
|
"""True si au moins une decision de jury dans ce semestre"""
|
||||||
|
if [x for x in self.decisions_jury_ues.values() if x]:
|
||||||
|
return True
|
||||||
|
|
||||||
return len([x for x in self.decisions_jury_ues.values() if x]) > 0
|
return len([x for x in self.decisions_jury_ues.values() if x]) > 0
|
||||||
|
|
||||||
def etud_has_decision(self, etudid):
|
def etud_has_decision(self, etudid):
|
||||||
|
@ -9,9 +9,10 @@
|
|||||||
# le département via l'interface web (Zope)
|
# le département via l'interface web (Zope)
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $0 [-r] dept [script...]"
|
echo "Usage: $0 [-h] [-r] [-x] dept [script...]"
|
||||||
echo "Lance un environnement interactif python/ScoDoc"
|
echo "Lance un environnement interactif python/ScoDoc"
|
||||||
echo " -r: supprime et recrée le département (attention: efface la base !)"
|
echo " -r: supprime et recrée le département (attention: efface la base !)"
|
||||||
|
echo " -x: exit après exécution des scripts, donc mode non interactif"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,24 +21,38 @@ cd /opt/scodoc/Products/ScoDoc || exit 2
|
|||||||
source config/config.sh
|
source config/config.sh
|
||||||
source config/utils.sh
|
source config/utils.sh
|
||||||
|
|
||||||
if [ $# -lt 1 ]
|
RECREATE_DEPT=0
|
||||||
then
|
PYTHON_INTERACTIVE="-i"
|
||||||
usage
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$1" = "-r" ]
|
while [ -n "$1" ]; do
|
||||||
then
|
PARAM="$1"
|
||||||
|
[ "${PARAM::1}" != "-" ] && break
|
||||||
|
case $PARAM in
|
||||||
|
-h | --help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-r)
|
||||||
|
RECREATE_DEPT=1
|
||||||
|
;;
|
||||||
|
-x)
|
||||||
|
PYTHON_INTERACTIVE=""
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "ERROR: unknown parameter \"$PARAM\""
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
shift
|
shift
|
||||||
recreate_dept=1
|
done
|
||||||
else
|
|
||||||
recreate_dept=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
DEPT="$1"
|
DEPT="$1"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
if [ "$recreate_dept" = 1 ]
|
if [ "$RECREATE_DEPT" = 1 ]
|
||||||
then
|
then
|
||||||
cfg_pathname="${SCODOC_VAR_DIR}/config/depts/$DEPT".cfg
|
cfg_pathname="${SCODOC_VAR_DIR}/config/depts/$DEPT".cfg
|
||||||
if [ -e "$cfg_pathname" ]
|
if [ -e "$cfg_pathname" ]
|
||||||
@ -48,13 +63,17 @@ then
|
|||||||
# systemctl start scodoc
|
# systemctl start scodoc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cmd="from __future__ import print_function;from Zope2 import configure;configure('/opt/scodoc/etc/zope.conf');import Zope2; app=Zope2.app();from debug import *;context = go_dept(app, '""$DEPT""');"
|
cmd="from __future__ import print_function;from Zope2 import configure;configure('/opt/scodoc/etc/zope.conf');import Zope2; app=Zope2.app();from debug import *;context = go_dept(app, '""$DEPT""', verbose=False);"
|
||||||
|
|
||||||
for f in "$@"
|
for f in "$@"
|
||||||
do
|
do
|
||||||
cmd="${cmd}exec(open(\"${f}\").read());"
|
cmd="${cmd}exec(open(\"${f}\").read());"
|
||||||
done
|
done
|
||||||
|
|
||||||
/opt/zope213/bin/python -i -c "$cmd"
|
if [ -z "$PYTHON_INTERACTIVE" ]
|
||||||
|
then
|
||||||
|
/opt/zope213/bin/python -c "$cmd"
|
||||||
|
else
|
||||||
|
/opt/zope213/bin/python "$PYTHON_INTERACTIVE" -c "$cmd"
|
||||||
|
fi
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ Utiliser comme:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
# La variable context est définie par le script de lancement
|
# La variable context est définie par le script de lancement
|
||||||
# l'affecte ainsi pour évietr les warnins pylint:
|
# l'affecte ainsi pour éviter les warnings pylint:
|
||||||
context = context # pylint: disable=undefined-variable
|
context = context # pylint: disable=undefined-variable
|
||||||
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
|
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
|
||||||
import sco_utils
|
import sco_utils
|
||||||
|
Loading…
Reference in New Issue
Block a user