Compare commits

...

4 Commits

Author SHA1 Message Date
8bf2255d82 typo 2020-12-28 23:47:36 +01:00
4847a2d12b black 2020-12-28 22:59:59 +01:00
978d4e64af ajout bouton "saisie à la semaine" dans le tab "Absences et feuilles" 2020-12-28 22:59:02 +01:00
7ad2a10894 shellcheck 2020-12-28 22:09:20 +01:00
5 changed files with 81 additions and 41 deletions

View File

@ -1617,7 +1617,7 @@ class ZNotes(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Impl
security.declareProtected(ScoView, "view_module_abs")
def view_module_abs(self, REQUEST, moduleimpl_id, format="html"):
"""Visulalisation des absences a un module"""
"""Visualisation des absences a un module"""
M = self.do_moduleimpl_withmodule_list(moduleimpl_id=moduleimpl_id)[0]
sem = sco_formsemestre.get_formsemestre(self, M["formsemestre_id"])
debut_sem = DateDMYtoISO(sem["date_debut"])

View File

@ -15,7 +15,7 @@ SCODOC_DIR="${INSTANCE_DIR}/Products/ScoDoc"
SCODOC_VAR_DIR="${INSTANCE_DIR}/var/scodoc"
source utils.sh
check_uid_root $0
check_uid_root "$0"
# Safety check
echo "Ce script va remplacer les donnees de votre installation ScoDoc par celles"
@ -28,7 +28,7 @@ echo
echo "TOUTES LES BASES POSTGRESQL SERONT EFFACEES !!!"
echo
echo -n "Voulez vous poursuivre cette operation ? (y/n) [n]"
read ans
read -r ans
if [ ! "$(norm_ans "$ans")" = 'Y' ]
then
echo "Annulation"
@ -57,7 +57,7 @@ then
echo "Opening tgz archive..."
tmp=$(mktemp -d)
chmod a+rx "$tmp"
cd "$tmp"
cd "$tmp" || terminate "directory error"
tar xfz "$SRC"
SRC=$(ls -1d "$tmp"/*)
IS_TMP=1
@ -83,18 +83,18 @@ su -c "$SCODOC_DIR/config/psql_restore_databases.sh $PG_DUMPFILE" postgres
#
echo Copying data files...
rm -rf "$INSTANCE_DIR/var"
rm -rf "${INSTANCE_DIR:?}/var"
$COPY "$SRC/var" "$INSTANCE_DIR"
if [ ! -e "${SCODOC_VAR_DIR}/config/" ]
if [ ! -e "${SCODOC_VAR_DIR:?}/config/" ]
then
mkdir "${SCODOC_VAR_DIR}/config/"
chown www-data.www-data "${SCODOC_VAR_DIR}/config/"
chmod 775 "${SCODOC_VAR_DIR}/config/"
mkdir "${SCODOC_VAR_DIR:?}/config/"
chown www-data.www-data "${SCODOC_VAR_DIR:?}/config/"
chmod 775 "${SCODOC_VAR_DIR:?}/config/"
fi
rm -rf "$SCODOC_DIR/config/depts"
if [ -e "$SRC/depts" ]
rm -rf "${SCODOC_DIR:?}/config/depts"
if [ -e "${SRC:?}/depts" ]
then
# legacy depts => move them to var
$COPY "$SRC/depts" "${SCODOC_VAR_DIR}/config/"
@ -107,7 +107,7 @@ then
$COPY "$SRC/photos" "${SCODOC_VAR_DIR}/"
fi
rm -rf "$SCODOC_DIR/logos"
rm -rf "${SCODOC_DIR:?}/logos"
$COPY "$SRC/logos" "$SCODOC_DIR/"
mv "$SCODOC_DIR/config/scodoc_config.py" "$SCODOC_DIR/config/scodoc_config.py.$(date +%Y%m%d-%H%M%S)"
@ -119,7 +119,7 @@ then
iconv -f iso8859-15 -t utf-8 "$SCODOC_DIR/config/scodoc_config.py.orig" > "$SCODOC_DIR/config/scodoc_config.py"
fi
rm -rf "$INSTANCE_DIR/log"
rm -rf "${INSTANCE_DIR:?}/log"
$COPY "$SRC/log" "$INSTANCE_DIR/"
# Fix file ownership and access rights
@ -130,13 +130,13 @@ chown -R www-data.root "$SCODOC_DIR"
chmod -R 775 "$SCODOC_DIR"
# Remove tmp directory
if [ $IS_TMP = "1" ]
if [ "$IS_TMP" = "1" ]
then
rm -rf $tmp
rm -rf "${tmp}"
fi
# Mise a jour BD ScoDoc
cd $SCODOC_DIR/config
cd ${SCODOC_DIR:?}/config || terminate "no config directory"
./upgrade.sh
#

View File

@ -35,7 +35,7 @@ INSTANCE_DIR=/opt/scodoc
SCODOC_DIR="$INSTANCE_DIR/Products/ScoDoc"
source utils.sh
check_uid_root $0
check_uid_root "$0"
echo "Stopping ScoDoc..."
scodocctl stop
@ -44,9 +44,9 @@ scodocctl stop
echo "Dumping SQL database..."
chown postgres "$DEST"
su -c "pg_dumpall > \"$DEST\"/scodoc.dump.txt" postgres
if [ ! $? -eq 0 ]
if [ ! "$?" -eq 0 ]
then
echo "Error dumping postgresql database\nPlease check that SQL server is running\nAborting."
printf "Error dumping postgresql database\nPlease check that SQL server is running\nAborting."
exit 1
fi
chown root "$DEST"
@ -57,7 +57,7 @@ cp -rp "$INSTANCE_DIR/var" "$DEST"
# Depts db config (now in .../var)
shopt -s nullglob
if [ ! -z "$(echo ${SCODOC_DIR}/config/depts/*.cfg)" ]
if [ -n "$(echo ${SCODOC_DIR}/config/depts/*.cfg)" ]
then
echo "Copying legacy depts configs..."
cp -rp "$SCODOC_DIR/config/depts" "$DEST"
@ -86,6 +86,6 @@ cp -rp "$INSTANCE_DIR/log" "$DEST"
echo
echo "Archiving backup files in a $DEST.tgz..."
base=$(basename "$DEST")
(cd "$DEST"/..; tar cfz "$DEST".tgz "$base")
(cd "$DEST"/.. || terminate "directory error"; tar cfz "$DEST".tgz "$base")
echo "Done (you can copy " "$DEST"".tgz to destination machine)."

View File

@ -53,8 +53,7 @@ def doSignaleAbsence(
description=None,
REQUEST=None,
): # etudid implied
"""Signalement d'une absence
"""
"""Signalement d'une absence"""
etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
@ -124,8 +123,7 @@ def doSignaleAbsence(
def SignaleAbsenceEtud(context, REQUEST=None): # etudid implied
"""Formulaire individuel simple de signalement d'une absence
"""
"""Formulaire individuel simple de signalement d'une absence"""
# brute-force portage from very old dtml code ...
etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
@ -162,7 +160,10 @@ def SignaleAbsenceEtud(context, REQUEST=None): # etudid implied
% etud,
"""<a href="%s/ficheEtud?etudid=%s">""" % (context.ScoURL(), etud["etudid"]),
sco_photos.etud_photo_html(
context, etudid=etudid, title="fiche de " + etud["nomprenom"], REQUEST=REQUEST
context,
etudid=etudid,
title="fiche de " + etud["nomprenom"],
REQUEST=REQUEST,
),
"""</a></td></tr></table>""",
"""
@ -207,8 +208,7 @@ Raison: <input type="text" name="description" size="42"/> (optionnel)
def doJustifAbsence(
context, datedebut, datefin, demijournee, description=None, REQUEST=None
): # etudid implied
"""Justification d'une absence
"""
"""Justification d'une absence"""
etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
description_abs = description
@ -274,8 +274,7 @@ def doJustifAbsence(
def JustifAbsenceEtud(context, REQUEST=None): # etudid implied
"""Formulaire individuel simple de justification d'une absence
"""
"""Formulaire individuel simple de justification d'une absence"""
# brute-force portage from very old dtml code ...
etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
@ -290,7 +289,10 @@ def JustifAbsenceEtud(context, REQUEST=None): # etudid implied
% etud,
"""<a href="%s/ficheEtud?etudid=%s">""" % (context.ScoURL(), etud["etudid"]),
sco_photos.etud_photo_html(
context, etudid=etudid, title="fiche de " + etud["nomprenom"], REQUEST=REQUEST
context,
etudid=etudid,
title="fiche de " + etud["nomprenom"],
REQUEST=REQUEST,
),
"""</a></td></tr></table>""",
"""
@ -329,8 +331,7 @@ Raison: <input type="text" name="description" size="42"/> (optionnel)
def doAnnuleAbsence(
context, datedebut, datefin, demijournee, REQUEST=None
): # etudid implied
"""Annulation des absences pour une demi journée
"""
"""Annulation des absences pour une demi journée"""
etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
@ -378,8 +379,7 @@ autre absence pour <b>%(nomprenom)s</b></a></li>
def AnnuleAbsenceEtud(context, REQUEST=None): # etudid implied
"""Formulaire individuel simple d'annulation d'une absence
"""
"""Formulaire individuel simple d'annulation d'une absence"""
# brute-force portage from very old dtml code ...
etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
@ -395,7 +395,10 @@ def AnnuleAbsenceEtud(context, REQUEST=None): # etudid implied
% etud, # "
"""<a href="%s/ficheEtud?etudid=%s">""" % (context.ScoURL(), etud["etudid"]),
sco_photos.etud_photo_html(
context, etudid=etudid, title="fiche de " + etud["nomprenom"], REQUEST=REQUEST
context,
etudid=etudid,
title="fiche de " + etud["nomprenom"],
REQUEST=REQUEST,
),
"""</a></td></tr></table>""",
"""<p>A n'utiliser que suite à une erreur de saisie ou lorsqu'il s'avère que l'étudiant était en fait présent. </p>
@ -464,8 +467,7 @@ def AnnuleAbsenceEtud(context, REQUEST=None): # etudid implied
def doAnnuleJustif(
context, datedebut0, datefin0, demijournee, REQUEST=None
): # etudid implied
"""Annulation d'une justification
"""
"""Annulation d'une justification"""
etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
dates = context.DateRangeISO(datedebut0, datefin0)
@ -569,8 +571,7 @@ def formChoixSemestreGroupe(context, all=False):
def CalAbs(context, REQUEST=None): # etud implied
"""Calendrier des absences d un etudiant
"""
"""Calendrier des absences d un etudiant"""
# crude portage from 1999 DTML
etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
@ -621,7 +622,10 @@ def CalAbs(context, REQUEST=None): # etud implied
context.ScoURL(),
etudid,
sco_photos.etud_photo_html(
context, etudid=etudid, title="fiche de " + etud["nomprenom"], REQUEST=REQUEST
context,
etudid=etudid,
title="fiche de " + etud["nomprenom"],
REQUEST=REQUEST,
),
),
CalHTML,

View File

@ -798,6 +798,11 @@ def tab_absences_html(context, groups_infos, etat=None, REQUEST=None):
"<h3>Absences</h3>",
'<ul class="ul_abs">',
"<li>",
form_choix_saisie_semaine(
context, groups_infos, REQUEST=REQUEST
), # Ajout Le Havre
"</li>",
"<li>",
form_choix_jour_saisie_hebdo(context, groups_infos, REQUEST=REQUEST),
"</li>",
"""<li><a class="stdlink" href="Absences/EtatAbsencesGr?%s&amp;debut=%s&amp;fin=%s">Etat des absences du groupe</a></li>"""
@ -888,6 +893,37 @@ def form_choix_jour_saisie_hebdo(context, groups_infos, REQUEST=None):
return "\n".join(FA)
# Ajout Le Havre
# Formulaire saisie absences semaine
def form_choix_saisie_semaine(context, groups_infos, REQUEST=None):
authuser = REQUEST.AUTHENTICATED_USER
if not authuser.has_permission(ScoAbsChange, context):
return ""
sem = groups_infos.formsemestre
# construit l'URL "destination"
# (a laquelle on revient apres saisie absences)
query_args = cgi.parse_qs(REQUEST.QUERY_STRING)
moduleimpl_id = query_args.get("moduleimpl_id", [""])[0]
if "head_message" in query_args:
del query_args["head_message"]
destination = "%s?%s" % (REQUEST.URL, urllib.urlencode(query_args, True))
destination = destination.replace(
"%", "%%"
) # car ici utilisee dans un format string !
DateJour = time.strftime("%d/%m/%Y")
datelundi = ZAbsences.ddmmyyyy(DateJour).prev_monday()
FA = [] # formulaire avec menu saisi hebdo des absences
FA.append('<form action="Absences/SignaleAbsenceGrHebdo" method="get">')
FA.append('<input type="hidden" name="datelundi" value="%s"/>' % datelundi)
FA.append('<input type="hidden" name="moduleimpl_id" value="%s"/>' % moduleimpl_id)
FA.append('<input type="hidden" name="destination" value="%s"/>' % destination)
FA.append(groups_infos.get_form_elem())
FA.append('<input type="submit" class="button" value="Saisie à la semaine" />')
FA.append("</form>")
return "\n".join(FA)
def export_groups_as_moodle_csv(context, formsemestre_id=None, REQUEST=None):
"""Export all students/groups, in a CSV format suitable for Moodle
Each (student,group) will be listed on a separate line