Compare commits

..

28 Commits

Author SHA1 Message Date
b2e5fccec1 Ajouter 'toto' 2020-12-30 00:49:51 +01:00
1f4a32a485 Calcul formule dans modules sans note (pour malus) [contrib. JMP] 2020-12-29 23:16:40 +01:00
97f69ebc7d Bulletins: ajuste l affichage de la ligne module pour les modules malus (contrib. JMP) 2020-12-29 18:53:03 +01:00
d6bf8efdee TEST: set default sem resp. 2020-12-29 17:32:26 +01:00
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
dea24d0257 TESTS: scenario standard capitalisation 2020-12-28 21:49:53 +01:00
e7ccdee992 TESTS: scenario standard capitalisation 2020-12-28 21:42:22 +01:00
62a813494c Fix: bulletins 2020-12-28 14:43:12 +01:00
274d39a3ec Test basic: modules, sems, notes 2020-12-27 13:45:24 +01:00
0864917a5f Fix: moduleimpl_status ordre des partitions 2020-12-26 00:39:45 +01:00
ea388ea494 New testing tools 2020-12-26 00:11:55 +01:00
6af4c6a2fd Fix: Affichage moyenne promo par évaluation sur bulletin 2020-12-25 12:10:37 +01:00
2b5a470516 itre form saisie + pylint 2020-12-24 14:56:01 +01:00
7efe8cd194 Fix: partition par defaut sur tableau bord module 2020-12-24 11:47:13 +01:00
de6d0233ac Lien mail enseignants sur tableau bord semestre 2020-12-24 01:29:50 +01:00
fcbbc877bc Liste enseignants dans table description semestre (DS, Le Havre) 2020-12-24 01:00:41 +01:00
2f94c41821 documente debouche comme obsolete 2020-12-24 00:19:35 +01:00
d386f82146 pylint 2020-12-24 00:07:17 +01:00
ec006442c4 pylint 2020-12-23 23:49:11 +01:00
cf091d2c1a Fix: removed debug message raising an exception 2020-12-23 23:48:11 +01:00
d6e7bbc713 Merge branch 'master' of https://scodoc.org/git/viennet/ScoDoc 2020-12-23 22:28:26 +01:00
7794fff4a5 Fix: export excel des evaluations en attente 2020-12-23 22:27:21 +01:00
65575e3562 Merge branch 'master' of https://scodoc.org/git/viennet/ScoDoc 2020-12-23 17:22:14 +01:00
3b75dcfa13 Fix mode 2020-12-23 17:21:59 +01:00
9b5f766500 Fix: export Excel n'affiche pas certains DS 2020-12-23 17:19:22 +01:00
186 changed files with 1587 additions and 1091 deletions

View File

@ -93,7 +93,7 @@ ADMISSION_MODIFIABLE_FIELDS = (
def sco_import_format(with_codesemestre=True):
"returns tuples (Attribut, Type, Table, AllowNulls, Description)"
r = []
for l in open(SCO_SRC_DIR + "/" + FORMAT_FILE):
for l in open(SCO_SRCDIR + "/" + FORMAT_FILE):
l = l.strip()
if l and l[0] != "#":
fs = l.split(";")

View File

@ -1,7 +1,7 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
SCOVERSION = "8.00a"
SCOVERSION = "7.19a"
SCONAME = "ScoDoc"

View File

@ -45,17 +45,19 @@ L'API de plus bas niveau est en gros:
"""
import urllib
import datetime
import jaxml
# ---------------
from sco_zope import *
# ---------------
from notesdb import *
import sco_utils as scu
import notesdb
from notes_log import log
from scolog import logdb
from sco_utils import *
# import notes_users
from sco_permissions import ScoAbsAddBillet, ScoAbsChange, ScoView
from sco_exceptions import ScoValueError, ScoInvalidDateError
from TrivialFormulator import TrivialFormulator, TF
from gen_tables import GenTable
import scolars
@ -356,7 +358,7 @@ class ZAbsences(
estjust = _toboolean(estjust)
matin = _toboolean(matin)
cnx = self.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cursor.execute(
"insert into absences (etudid,jour,estabs,estjust,matin,description, moduleimpl_id) values (%(etudid)s, %(jour)s, TRUE, %(estjust)s, %(matin)s, %(description)s, %(moduleimpl_id)s )",
vars(),
@ -380,7 +382,7 @@ class ZAbsences(
raise ScoValueError("date justificatif trop loin dans le futur !")
matin = _toboolean(matin)
cnx = self.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cursor.execute(
"insert into absences (etudid,jour,estabs,estjust,matin, description) values (%(etudid)s,%(jour)s, FALSE, TRUE, %(matin)s, %(description)s )",
vars(),
@ -402,7 +404,7 @@ class ZAbsences(
# unpublished
matin = _toboolean(matin)
cnx = self.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
req = "delete from absences where jour=%(jour)s and matin=%(matin)s and etudid=%(etudid)s and estabs"
if moduleimpl_id:
req += " and moduleimpl_id=%(moduleimpl_id)s"
@ -423,7 +425,7 @@ class ZAbsences(
# unpublished
matin = _toboolean(matin)
cnx = self.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cursor.execute(
"delete from absences where jour=%(jour)s and matin=%(matin)s and etudid=%(etudid)s and ESTJUST AND NOT ESTABS",
vars(),
@ -450,7 +452,7 @@ class ZAbsences(
# """
# # unpublished
# cnx = self.GetDBConnexion()
# cursor = cnx.cursor(cursor_factory=ScoDocCursor)
# cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
# # supr les absences non justifiees
# cursor.execute("delete from absences where etudid=%(etudid)s and (not estjust) and moduleimpl_id=(moduleimpl_id)s and jour BETWEEN %(datedebut)s AND %(datefin)s",
# vars() )
@ -487,7 +489,7 @@ class ZAbsences(
self._AnnuleAbsence(etudid, jour, matin, moduleimpl_id, REQUEST)
return
cnx = self.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
# supr les absences non justifiees
for date in dates:
cursor.execute(
@ -534,7 +536,7 @@ class ZAbsences(
else:
modul = ""
cnx = self.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cursor.execute(
"""SELECT COUNT(*) AS NbAbs FROM (
SELECT DISTINCT A.JOUR, A.MATIN
@ -565,7 +567,7 @@ class ZAbsences(
else:
modul = ""
cnx = self.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cursor.execute(
"""SELECT COUNT(*) AS NbAbsJust FROM (
SELECT DISTINCT A.JOUR, A.MATIN
@ -588,7 +590,7 @@ class ZAbsences(
def _ListeAbsDate(self, etudid, beg_date, end_date):
# Liste des absences et justifs entre deux dates
cnx = self.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cursor.execute(
"""SELECT jour, matin, estabs, estjust, description FROM ABSENCES A
WHERE A.ETUDID = %(etudid)s
@ -598,7 +600,6 @@ class ZAbsences(
vars(),
)
Abs = cursor.dictfetchall()
# log('ListeAbsDate: abs=%s' % Abs)
# remove duplicates
A = {} # { (jour, matin) : abs }
for a in Abs:
@ -625,7 +626,6 @@ class ZAbsences(
# sort
R = A.values()
R.sort(key=lambda x: (x["begin"]))
# log('R=%s' % R)
return R
security.declareProtected(ScoView, "ListeAbsJust")
@ -633,7 +633,7 @@ class ZAbsences(
def ListeAbsJust(self, etudid, datedebut):
"Liste des absences justifiees (par ordre chronologique)"
cnx = self.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cursor.execute(
"""SELECT DISTINCT A.ETUDID, A.JOUR, A.MATIN FROM ABSENCES A, ABSENCES B
WHERE A.ETUDID = %(etudid)s
@ -654,7 +654,7 @@ class ZAbsences(
def ListeAbsNonJust(self, etudid, datedebut):
"Liste des absences NON justifiees (par ordre chronologique)"
cnx = self.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cursor.execute(
"""SELECT ETUDID, JOUR, MATIN FROM ABSENCES A
WHERE A.ETUDID = %(etudid)s
@ -680,7 +680,7 @@ class ZAbsences(
Si only_no_abs: seulement les justificatifs correspondant aux jours sans absences relevées.
"""
cnx = self.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
req = """SELECT DISTINCT ETUDID, JOUR, MATIN FROM ABSENCES A
WHERE A.ETUDID = %(etudid)s
AND A.ESTJUST
@ -704,7 +704,7 @@ class ZAbsences(
"Description associee a l'absence"
if not cursor:
cnx = self.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
a = a.copy()
# a['jour'] = a['jour'].date()
if a["matin"]: # devrait etre booleen... :-(
@ -732,7 +732,6 @@ class ZAbsences(
if desc:
return "(%s) %s" % (desc, module)
return desc
if module:
return module
return ""
@ -745,7 +744,7 @@ class ZAbsences(
is_just: idem
"""
cnx = self.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
req = """SELECT DISTINCT etudid, jour, matin FROM ABSENCES A
WHERE A.jour = %(date)s
"""
@ -769,7 +768,7 @@ class ZAbsences(
def ListeAbsNonJustJour(self, date, am=True, pm=True):
"Liste des absences non justifiees ce jour"
cnx = self.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
reqa = ""
if not am:
reqa += " AND NOT matin "
@ -849,7 +848,7 @@ class ZAbsences(
def CalSelectWeek(self, year=None, REQUEST=None):
"display calendar allowing week selection"
if not year:
year = AnneeScolaire(REQUEST)
year = scu.AnneeScolaire(REQUEST)
sems = sco_formsemestre.do_formsemestre_list(self)
if not sems:
js = ""
@ -886,10 +885,9 @@ class ZAbsences(
security.declareProtected(ScoView, "ListMondays")
def ListMondays(self, year=None, REQUEST=None):
"""return list of mondays (ISO dates), from september to june
"""
"""return list of mondays (ISO dates), from september to june"""
if not year:
year = AnneeScolaire(REQUEST)
year = scu.AnneeScolaire(REQUEST)
d = ddmmyyyy("1/9/%d" % year, work_saturday=self.is_work_saturday())
while d.weekday != 0:
d = d.next()
@ -934,7 +932,7 @@ class ZAbsences(
):
"Saisie hebdomadaire des absences"
if not moduleimpl_id:
moduleimp_id = None
moduleimpl_id = None
groups_infos = sco_groups_view.DisplayedGroupsInfos(
self, group_ids, REQUEST=REQUEST
@ -963,10 +961,10 @@ class ZAbsences(
)[0]
# calcule dates jours de cette semaine
datessem = [DateDMYtoISO(datelundi)]
for jour in self.day_names()[1:]:
# liste de dates iso "yyyy-mm-dd"
datessem = [notesdb.DateDMYtoISO(datelundi)]
for _ in self.day_names()[1:]:
datessem.append(self.NextISODay(datessem[-1]))
#
if groups_infos.tous_les_etuds_du_sem:
gr_tit = "en"
@ -1044,9 +1042,7 @@ class ZAbsences(
% {"menu_module": menu_module, "url": base_url, "sel": sel}
)
H += self._gen_form_saisie_groupe(
etuds, self.day_names(), datessem, destination, None, moduleimpl_id
)
H += self._gen_form_saisie_groupe(etuds, datessem, destination, moduleimpl_id)
H.append(self.sco_footer(REQUEST))
return "\n".join(H)
@ -1063,8 +1059,7 @@ class ZAbsences(
moduleimpl_id=None,
REQUEST=None,
):
"""Saisie des absences sur une journée sur un semestre (ou intervalle de dates) entier
"""
"""Saisie des absences sur une journée sur un semestre (ou intervalle de dates) entier"""
# log('SignaleAbsenceGrSemestre: moduleimpl_id=%s destination=%s' % (moduleimpl_id, destination))
groups_infos = sco_groups_view.DisplayedGroupsInfos(
self, group_ids, REQUEST=REQUEST
@ -1083,16 +1078,13 @@ class ZAbsences(
]
if not moduleimpl_id:
moduleimp_id = None
base_url_noweeks = (
"SignaleAbsenceGrSemestre?datedebut=%s&datefin=%s&%s&destination=%s"
% (
moduleimpl_id = None
base_url_noweeks = "SignaleAbsenceGrSemestre?datedebut=%s&datefin=%s&%s&destination=%s" % (
datedebut,
datefin,
groups_infos.groups_query_args,
urllib.quote(destination),
)
)
base_url = (
base_url_noweeks + "&nbweeks=%s" % nbweeks
) # sans le moduleimpl_id
@ -1139,7 +1131,6 @@ class ZAbsences(
if moduleimpl_id:
url_link_semaines += "&moduleimpl_id=" + moduleimpl_id
#
colnames = [str(x) for x in dates]
dates = [x.ISO() for x in dates]
dayname = self.day_names()[jourdebut.weekday]
@ -1147,9 +1138,9 @@ class ZAbsences(
gr_tit = "en"
else:
if len(groups_infos.group_ids) > 1:
p = "des groupes"
p = "des groupes "
else:
p = "du groupe"
p = "du groupe "
gr_tit = (
p + '<span class="fontred">' + groups_infos.groups_titles + "</span>"
)
@ -1217,15 +1208,18 @@ class ZAbsences(
% {"menu_module": menu_module, "url": base_url, "sel": sel}
)
H += self._gen_form_saisie_groupe(
etuds, colnames, dates, destination, dayname, moduleimpl_id
)
H += self._gen_form_saisie_groupe(etuds, dates, destination, moduleimpl_id)
H.append(self.sco_footer(REQUEST))
return "\n".join(H)
def _gen_form_saisie_groupe(
self, etuds, colnames, dates, destination="", dayname="", moduleimpl_id=None
):
def _gen_form_saisie_groupe(self, etuds, dates, destination="", moduleimpl_id=None):
"""Formulaire saisie absences
Args:
etuds: liste des étudiants
dates: liste de dates iso, par exemple: [ '2020-12-24', ... ]
moduleimpl_id: optionnel, module concerné.
"""
H = [
"""
<script type="text/javascript">
@ -1252,25 +1246,29 @@ class ZAbsences(
"""
% len(etuds)
]
# Dates
odates = [datetime.date(*[int(x) for x in d.split("-")]) for d in dates]
# Titres colonnes
if dayname:
for jour in colnames:
H.append(
'<th colspan="2" width="100px" style="padding-left: 5px; padding-right: 5px;">'
+ dayname
+ "</th>"
)
H.append("</tr><tr><td>&nbsp;</td>")
for jour in colnames:
noms_jours = [] # eg [ "Lundi", "mardi", "Samedi", ... ]
jn = self.day_names()
for d in odates:
idx_jour = d.weekday()
noms_jours.append(jn[idx_jour])
for jour in noms_jours:
H.append(
'<th colspan="2" width="100px" style="padding-left: 5px; padding-right: 5px;">'
+ jour
+ "</th>"
)
H.append("</tr><tr><td>&nbsp;</td>")
H.append("<th>AM</th><th>PM</th>" * len(colnames))
for d in odates:
H.append(
'<th colspan="2" width="100px" style="padding-left: 5px; padding-right: 5px;">'
+ d.strftime("%d/%m/%Y")
+ "</th>"
)
H.append("</tr><tr><td>&nbsp;</td>")
H.append("<th>AM</th><th>PM</th>" * len(dates))
H.append("</tr>")
#
if not etuds:
@ -1373,14 +1371,13 @@ class ZAbsences(
absjust_only=0,
REQUEST=None,
):
"""Tables des absences justifiees et non justifiees d'un étudiant sur l'année en cours
"""
"""Tables des absences justifiees et non justifiees d'un étudiant sur l'année en cours"""
absjust = self.ListeAbsJust(etudid=etudid, datedebut=datedebut)
absnonjust = self.ListeAbsNonJust(etudid=etudid, datedebut=datedebut)
# examens ces jours là ?
if with_evals:
cnx = self.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
for a in absnonjust + absjust:
cursor.execute(
"""select eval.*
@ -1499,10 +1496,9 @@ class ZAbsences(
format="html",
REQUEST=None,
):
"""Liste les absences de groupes
"""
datedebut = DateDMYtoISO(debut)
datefin = DateDMYtoISO(fin)
"""Liste les absences de groupes"""
datedebut = notesdb.DateDMYtoISO(debut)
datefin = notesdb.DateDMYtoISO(fin)
# Informations sur les groupes à afficher:
groups_infos = sco_groups_view.DisplayedGroupsInfos(
self, group_ids, REQUEST=REQUEST
@ -1603,7 +1599,7 @@ class ZAbsences(
base_url="%s&amp;formsemestre_id=%s&amp;debut=%s&amp;fin=%s"
% (groups_infos.base_url, formsemestre_id, debut, fin),
filename="etat_abs_"
+ make_filename(
+ scu.make_filename(
"%s de %s" % (groups_infos.groups_filename, sem["titreannee"])
),
caption=title,
@ -1632,26 +1628,20 @@ ou entrez une date pour visualiser les absents un jour donné&nbsp;:
def EtatAbsencesDate(
self, group_ids=[], date=None, REQUEST=None # list of groups to display
):
"""Etat des absences pour un groupe à une date donnée
"""
"""Etat des absences pour un groupe à une date donnée"""
# Informations sur les groupes à afficher:
groups_infos = sco_groups_view.DisplayedGroupsInfos(
self, group_ids, REQUEST=REQUEST
)
formsemestre_id = groups_infos.formsemestre_id
sem = sco_formsemestre.do_formsemestre_list(
self, {"formsemestre_id": formsemestre_id}
)[0]
H = [self.sco_header(page_title="Etat des absences", REQUEST=REQUEST)]
if date:
dateiso = DateDMYtoISO(date)
dateiso = notesdb.DateDMYtoISO(date)
nbetud = 0
t_nbabsjustam = 0
t_nbabsam = 0
t_nbabsjustpm = 0
t_nbabspm = 0
etuds = self.getEtudInfoGroupes(groups_infos.group_ids)
H.append("<h2>Etat des absences le %s</h2>" % date)
H.append("<h2>État des absences le %s</h2>" % date)
H.append(
"""<table border="0" cellspacing="4" cellpadding="0">
<tr><th>&nbsp;</th>
@ -1738,7 +1728,7 @@ ou entrez une date pour visualiser les absents un jour donné&nbsp;:
etudid=etudid, code_nip=code_nip, REQUEST=REQUEST, filled=True
)
if not etuds:
return log_unknown_etud(self, REQUEST=REQUEST)
return scu.log_unknown_etud(self, REQUEST=REQUEST)
etud = etuds[0]
# check dates
begin_date = ParseDateTimeUTC(begin) # may raises ValueError
@ -1763,7 +1753,7 @@ ou entrez une date pour visualiser les absents un jour donné&nbsp;:
if xml_reply:
# Renvoie le nouveau billet en XML
if REQUEST:
REQUEST.RESPONSE.setHeader("content-type", XML_MIMETYPE)
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
billets = billet_absence_list(cnx, {"billet_id": billet_id})
tab = self._tableBillets(billets, etud=etud)
@ -1884,11 +1874,10 @@ ou entrez une date pour visualiser les absents un jour donné&nbsp;:
security.declareProtected(ScoView, "listeBilletsEtud")
def listeBilletsEtud(self, etudid=False, REQUEST=None, format="html"):
"""Liste billets pour un etudiant
"""
"""Liste billets pour un etudiant"""
etuds = self.getEtudInfo(etudid=etudid, filled=1, REQUEST=REQUEST)
if not etuds:
return log_unknown_etud(self, format=format, REQUEST=REQUEST)
return scu.log_unknown_etud(self, format=format, REQUEST=REQUEST)
etud = etuds[0]
cnx = self.GetDBConnexion()
@ -1899,8 +1888,7 @@ ou entrez une date pour visualiser les absents un jour donné&nbsp;:
security.declareProtected(ScoView, "XMLgetBilletsEtud")
def XMLgetBilletsEtud(self, etudid=False, REQUEST=None):
"""Liste billets pour un etudiant
"""
"""Liste billets pour un etudiant"""
if not self.get_preference("handle_billets_abs"):
return ""
t0 = time.time()
@ -1937,8 +1925,7 @@ ou entrez une date pour visualiser les absents un jour donné&nbsp;:
security.declareProtected(ScoAbsChange, "deleteBilletAbsence")
def deleteBilletAbsence(self, billet_id, REQUEST=None, dialog_confirmed=False):
"""Supprime un billet.
"""
"""Supprime un billet."""
cnx = self.GetDBConnexion()
billets = billet_absence_list(cnx, {"billet_id": billet_id})
if not billets:
@ -2107,8 +2094,8 @@ ou entrez une date pour visualiser les absents un jour donné&nbsp;:
Abs = self._ListeAbsDate(etud["etudid"], beg_date, end_date)
REQUEST.RESPONSE.setHeader("content-type", XML_MIMETYPE)
doc = jaxml.XML_document(encoding=SCO_ENCODING)
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
doc = jaxml.XML_document(encoding=scu.SCO_ENCODING)
doc.absences(etudid=etud["etudid"], beg_date=beg_date, end_date=end_date)
doc._push()
for a in Abs:
@ -2126,7 +2113,7 @@ ou entrez une date pour visualiser les absents un jour donné&nbsp;:
return repr(doc)
_billet_absenceEditor = EditableTable(
_billet_absenceEditor = notesdb.EditableTable(
"billet_absence",
"billet_id",
(
@ -2210,7 +2197,6 @@ def MonthTableTail():
def MonthTableBody(
month, year, events=[], halfday=0, trattributes="", work_saturday=False, pad_width=8
):
# log('XXX events=%s' % events)
firstday, nbdays = calendar.monthrange(year, month)
localtime = time.localtime()
current_weeknum = time.strftime("%U", localtime)
@ -2443,8 +2429,8 @@ class CAbsSemEtud:
self.sem = sco_formsemestre.get_formsemestre(
self.context, self.sem["formsemestre_id"]
)
debut_sem = DateDMYtoISO(self.sem["date_debut"])
fin_sem = DateDMYtoISO(self.sem["date_fin"])
debut_sem = notesdb.DateDMYtoISO(self.sem["date_debut"])
fin_sem = notesdb.DateDMYtoISO(self.sem["date_fin"])
self._CountAbs = self.context.Absences.CountAbs(
etudid=self.etudid, debut=debut_sem, fin=fin_sem

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

@ -33,7 +33,6 @@
import time, string, glob, re, inspect
import urllib, urllib2, cgi, xml
import datetime
try:
from cStringIO import StringIO
@ -43,22 +42,13 @@ from zipfile import ZipFile
import os.path, glob
import traceback
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
from email.mime.base import MIMEBase
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email.Header import Header
from email import Encoders
from sco_zope import (
ObjectManager,
PropertyManager,
RoleManager,
Item,
Persistent,
Implicit,
ClassSecurityInfo,
DTMLFile,
Globals,
)
from sco_zope import *
#
try:
@ -66,21 +56,7 @@ try:
except:
import ZPsycopgDA.DA as ZopeDA # interp.py
import sco_utils
from sco_utils import (
SCO_DEFAULT_SQL_USERS_CNX,
SCO_ENCODING,
CUSTOM_HTML_HEADER_CNX,
SCO_USERS_LIST,
SCO_WEBSITE,
SCO_EXC_MAIL,
SCO_DEV_MAIL,
scodoc_html2txt,
VERSION,
SCODOC_CFG_DIR,
)
from sco_permissions import ScoView, ScoSuperAdmin
from sco_exceptions import AccessDenied
from sco_utils import *
from notes_log import log
import sco_find_etud
from ZScoUsers import pwdFascistCheck
@ -135,7 +111,7 @@ class ZScoDoc(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Imp
def _check_users_folder(self, REQUEST=None):
"""Vérifie UserFolder et le crée s'il le faut"""
try:
self.UsersDB
udb = self.UsersDB
return "<!-- uf ok -->"
except:
e = self._check_admin_perm(REQUEST)
@ -188,11 +164,11 @@ class ZScoDoc(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Imp
pass
# add missing getAuthFailedMessage (bug in exUserFolder ?)
try:
self.getAuthFailedMessage
x = self.getAuthFailedMessage
except:
log("adding getAuthFailedMessage to Zope install")
parent = self.aq_parent
from OFS.DTMLMethod import addDTMLMethod # pylint: disable=import-error
from OFS.DTMLMethod import addDTMLMethod
addDTMLMethod(parent, "getAuthFailedMessage", file="Identification")
@ -288,7 +264,7 @@ class ZScoDoc(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Imp
r = []
for folder in folders:
try:
_ = folder.Scolarite
s = folder.Scolarite
r.append(folder)
except:
pass
@ -308,6 +284,7 @@ class ZScoDoc(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Imp
raise ValueError("nom de departement invalide")
if not pass2:
# 1- Creation de repertoire Dept
log("creating Zope folder " + DeptId)
add_method = self.manage_addProduct["OFSP"].manage_addFolder
add_method(DeptId, title="Site dept. " + DeptId)
@ -315,10 +292,12 @@ class ZScoDoc(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Imp
if not pass2:
# 2- Creation du repertoire Fotos
log("creating Zope folder %s/Fotos" % DeptId)
add_method = DeptFolder.manage_addProduct["OFSP"].manage_addFolder
add_method("Fotos", title="Photos identites " + DeptId)
# 3- Creation instance ScoDoc
log("creating Zope ZScolar instance")
add_method = DeptFolder.manage_addProduct["ScoDoc"].manage_addZScolarForm
return add_method(DeptId, REQUEST=REQUEST)
@ -670,8 +649,8 @@ Problème de connexion (identifiant, mot de passe): <em>contacter votre responsa
**kv
):
"Recuperation des exceptions Zope"
sco_exc_mail = SCO_EXC_MAIL # pylint: disable=unused-variable
sco_dev_mail = SCO_DEV_MAIL # pylint: disable=unused-variable
sco_exc_mail = SCO_EXC_MAIL
sco_dev_mail = SCO_DEV_MAIL
# neat (or should I say dirty ?) hack to get REQUEST
# in fact, our caller (probably SimpleItem.py) has the REQUEST variable
# that we'd like to use for our logs, but does not pass it as an argument.
@ -738,7 +717,6 @@ Problème de connexion (identifiant, mot de passe): <em>contacter votre responsa
)
# display error traceback (? may open a security risk via xss attack ?)
# log('exc B')
# pylint: disable=unused-variable
txt_html = self._report_request(REQUEST, fmt="html")
H.append(
"""<h4 class="scodoc">Zope Traceback (à envoyer par mail à <a href="mailto:%(sco_dev_mail)s">%(sco_dev_mail)s</a>)</h4><div style="background-color: rgb(153,153,204); border: 1px;">
@ -759,7 +737,6 @@ Problème de connexion (identifiant, mot de passe): <em>contacter votre responsa
pass
# --- Mail:
# pylint: disable=unused-variable
error_traceback_txt = scodoc_html2txt(error_tb)
txt = (
"""
@ -778,7 +755,6 @@ ErrorType: %(error_type)s
def _report_request(self, REQUEST, fmt="txt"):
"""string describing current request for bug reports"""
# pylint: disable=unused-variable
AUTHENTICATED_USER = REQUEST.get("AUTHENTICATED_USER", "")
dt = time.asctime()
URL = REQUEST.get("URL", "")
@ -795,7 +771,8 @@ ErrorType: %(error_type)s
HTTP_USER_AGENT = "na"
form = REQUEST.get("form", "")
HTTP_X_FORWARDED_FOR = REQUEST.get("HTTP_X_FORWARDED_FOR", "")
SCOVERSION = sco_utils.get_scodoc_version() or VERSION.SCOVERSION
svn_version = get_svn_version(self.file_path)
SCOVERSION = VERSION.SCOVERSION
txt = (
"""
@ -809,6 +786,8 @@ REFERER: %(REFERER)s
Form: %(form)s
Origin: %(HTTP_X_FORWARDED_FOR)s
Agent: %(HTTP_USER_AGENT)s
subversion: %(svn_version)s
"""
% vars()
)
@ -911,7 +890,7 @@ Agent: %(HTTP_USER_AGENT)s
"""Liste de id de departements definis par create_dept.sh
(fichiers depts/*.cfg)
"""
filenames = glob.glob(SCODOC_CFG_DIR + "/config/depts/*.cfg")
filenames = glob.glob(SCODOC_VAR_DIR + "/config/depts/*.cfg")
ids = [os.path.split(os.path.splitext(f)[0])[1] for f in filenames]
return ids

View File

@ -52,7 +52,7 @@ log("restarting...")
log("ZScolar home=%s" % file_path)
import sco_utils
from sco_utils import *
import notesdb
from notesdb import *
@ -405,9 +405,9 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
H = [
"""<h2>Système de gestion scolarité</h2>
<p>&copy; Emmanuel Viennet 1997-2020</p>
<p>Version %s</p>
<p>Version %s (subversion %s)</p>
"""
% (sco_utils.get_scodoc_version())
% (SCOVERSION, get_svn_version(file_path))
]
H.append(
'<p>Logiciel libre écrit en <a href="http://www.python.org">Python</a>.</p><p>Utilise <a href="http://www.reportlab.org/">ReportLab</a> pour générer les documents PDF, et <a href="http://sourceforge.net/projects/pyexcelerator">pyExcelerator</a> pour le traitement des documents Excel.</p>'
@ -2037,49 +2037,8 @@ function tweakmenu( gname ) {
)
if not edit:
# creation d'un etudiant
etudid = scolars.etudident_create(
cnx, tf[2], context=self, REQUEST=REQUEST
)
# crée une adresse vide (chaque etudiant doit etre dans la table "adresse" !)
adresse_id = scolars.adresse_create(
cnx,
{
"etudid": etudid,
"typeadresse": "domicile",
"description": "(creation individuelle)",
},
)
# event
scolars.scolar_events_create(
cnx,
args={
"etudid": etudid,
"event_date": time.strftime("%d/%m/%Y"),
"formsemestre_id": None,
"event_type": "CREATION",
},
)
# log
logdb(
REQUEST,
cnx,
method="etudident_edit_form",
etudid=etudid,
msg="creation initiale",
)
etud = scolars.etudident_list(cnx, {"etudid": etudid})[0]
self.fillEtudsInfo([etud])
etud["url"] = "ficheEtud?etudid=%(etudid)s" % etud
sco_news.add(
self,
REQUEST,
typ=NEWS_INSCR,
object=None, # pas d'object pour ne montrer qu'un etudiant
text='Nouvel étudiant <a href="%(url)s">%(nomprenom)s</a>' % etud,
url=etud["url"],
)
etud = scolars.create_etud(self, cnx, args=tf[2], REQUEST=REQUEST)
etudid = etud["etudid"]
else:
# modif d'un etudiant
scolars.etudident_edit(cnx, tf[2], context=self, REQUEST=REQUEST)

View File

@ -1,4 +1,4 @@
#!/bin/bash
# Version majeure de Debian (..., 9, 10)
debian_version=$(cat /etc/debian_version)
debian_version=${debian_version%%.*}
@ -24,28 +24,28 @@ export POSTGRES_SUPERUSER=postgres
export POSTGRES_USER=www-data
# psql command: if various versions installed, force the one we want:
if [ "${debian_version}" = "10" ]
if [ ${debian_version} = "10" ]
then
PSQL=/usr/lib/postgresql/11/bin/psql
elif [ "${debian_version}" = "9" ]
elif [ ${debian_version} = "9" ]
then
PSQL=/usr/lib/postgresql/9.6/bin/psql
elif [ "${debian_version}" = "8" ]
elif [ ${debian_version} = "8" ]
then
PSQL=/usr/lib/postgresql/9.4/bin/psql
elif [ "${debian_version}" = "7" ]
elif [ ${debian_version} = "7" ]
then
PSQL=/usr/lib/postgresql/9.1/bin/psql
elif [ "${debian_version}" = "5" ]
elif [ ${debian_version} = "5" ]
then
PSQL=/usr/lib/postgresql/8.3/bin/psql
elif [ "${debian_version}" = "6" ]
elif [ ${debian_version} = "6" ]
then
PSQL=/usr/lib/postgresql/8.4/bin/psql
else
PSQL=/usr/lib/postgresql/8.1/bin/psql
fi
export PSQL
# tcp port for SQL server (under Debian 4, 5432 or 5433 for 8.1 if 7.4 also installed !)
# Important note: if changed, you should probably also change it in
@ -53,7 +53,7 @@ export PSQL
export POSTGRES_PORT=5432
# Utilise par le script de reset du mot de passe:
if [ "${debian_version}" -ge "7" ]
if [ ${debian_version} -ge "7" ]
then
export ZOPE_VERSION=2.13
else

View File

@ -5,10 +5,10 @@
source config.sh
source utils.sh
check_uid_root "$0"
check_uid_root $0
echo 'Installation du demarrage automatique de ScoDoc (systemd)'
cp "$SCODOC_DIR"/config/etc/scodoc.service /etc/systemd/system
cp $SCODOC_DIR/config/etc/scodoc.service /etc/systemd/system
systemctl enable scodoc.service
echo "A partir de maintenant, utiliser"

View File

@ -11,6 +11,6 @@ source utils.sh
echo 'Creating postgresql database'
# ---
echo 'Creating postgresql database ' "$db_name"
createdb -E UTF-8 -p "$POSTGRES_PORT" -O "$POSTGRES_USER" "$db_name"
echo 'Creating postgresql database ' $db_name
createdb -E UTF-8 -p $POSTGRES_PORT -O $POSTGRES_USER $db_name

View File

@ -15,19 +15,37 @@ source utils.sh
check_uid_root "$0"
usage() {
echo "$0 [-n DEPT]"
echo "(default to interactive mode)"
exit 1
}
[ $# = 0 ] || [ $# = 2 ] || usage
echo -n "Nom du departement (un mot sans ponctuation, exemple \"Info\"): "
read -r DEPT
if [ "$1" = "-n" ]
then
interactive=0
if [ $# -lt 2 ]
then
usage
fi
DEPT=$2
else
interactive=1
echo -n "Nom du departement (un mot sans ponctuation, exemple \"Info\"): "
read -r DEPT
fi
if [[ ! "$DEPT" =~ ^[A-Za-z0-9]+$ ]]
then
echo 'Nom de departement invalide !'
exit 1
exit 2
fi
export DEPT
export db_name=SCO$(to_upper "$DEPT")
db_name=SCO$(to_upper "$DEPT")
export db_name
cfg_pathname="${SCODOC_VAR_DIR}/config/depts/$DEPT".cfg
@ -41,29 +59,39 @@ fi
init_postgres_user
# ----------------------- Create database
su -c ./create_database.sh $POSTGRES_SUPERUSER
su -c ./create_database.sh "$POSTGRES_SUPERUSER"
# ----------------------- Create tables
# POSTGRES_USER == regular unix user (www-data)
su -c ./initialize_database.sh $POSTGRES_USER
# ----------------------- Enregistre fichier config
echo "dbname=$db_name" > "$cfg_pathname"
# ----------------------- Force mise à jour
echo -n "Voulez vous mettre a jour ScoDoc (tres recommande) ? (y/n) [y] "
read -r ans
if [ "$(norm_ans "$ans")" != 'N' ]
if [ "$interactive" = 1 ]
then
(cd "$SCODOC_DIR/config"; ./upgrade.sh)
su -c ./initialize_database.sh "$POSTGRES_USER"
else
su -c ./initialize_database.sh "$POSTGRES_USER" > /dev/null 2>&1
fi
# -----------------------
echo
echo " Departement $DEPT cree"
echo
echo " Attention: la base de donnees n'a pas de copies de sauvegarde"
echo
echo " Maintenant, vous pouvez ajouter le departement via l'application web"
echo " en suivant le lien \"Administration de ScoDoc\" sur la page d'accueil."
echo
# ----------------------- Enregistre fichier config
echo "dbname=${db_name}" > "$cfg_pathname"
if [ "$interactive" = 1 ]
then
# ----------------------- Force mise à jour
echo -n "Voulez vous mettre a jour ScoDoc (tres recommande) ? (y/n) [y] "
read -r ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
(cd "$SCODOC_DIR/config" || terminate "no config directory"; ./upgrade.sh)
fi
# -----------------------
echo
echo " Departement $DEPT cree"
echo
echo " Attention: la base de donnees n'a pas de copies de sauvegarde"
echo
echo " Maintenant, vous pouvez ajouter le departement via l'application web"
echo " en suivant le lien \"Administration de ScoDoc\" sur la page d'accueil."
echo
fi

View File

@ -12,7 +12,7 @@
source config.sh
source utils.sh
check_uid_root "$0"
check_uid_root $0
# --- Ensure postgres user www-data exists
init_postgres_user
@ -21,8 +21,8 @@ db_name=SCOUSERS
echo 'Creating postgresql database ' $db_name
su -c "createdb -E UTF-8 -O $POSTGRES_USER -p $POSTGRES_PORT $db_name" "$POSTGRES_SUPERUSER"
su -c "createdb -E UTF-8 -O $POSTGRES_USER -p $POSTGRES_PORT $db_name" $POSTGRES_SUPERUSER
echo 'Initializing tables in database ' "$db_name"
echo su -c "$PSQL -U $POSTGRES_USER -p $POSTGRES_PORT $db_name < $SCODOC_DIR/misc/create_user_table.sql" "$POSTGRES_USER"
su -c "$PSQL -U $POSTGRES_USER -p $POSTGRES_PORT $db_name < $SCODOC_DIR/misc/create_user_table.sql" "$POSTGRES_USER"
echo 'Initializing tables in database ' $db_name
echo su -c "$PSQL -U $POSTGRES_USER -p $POSTGRES_PORT $db_name < $SCODOC_DIR/misc/create_user_table.sql" $POSTGRES_USER
su -c "$PSQL -U $POSTGRES_USER -p $POSTGRES_PORT $db_name < $SCODOC_DIR/misc/create_user_table.sql" $POSTGRES_USER

View File

@ -17,23 +17,38 @@
source config.sh
source utils.sh
check_uid_root "$0"
echo
echo "Ce script supprime la base de donnees ScoDoc d'un departement"
echo
echo "Attention: le departement doit au prealable avoir ete supprime via l'interface web !"
echo "faites le AVANT d'executer ce script !!!"
echo
echo -n "Nom du departement a supprimer (un mot sans ponctuation, exemple \"Info\"): "
read -r DEPT
check_uid_root $0
usage() {
echo "$0 [-n DEPT]"
echo "(default to interactive mode)"
exit 1
}
[ $# = 0 ] || [ $# = 2 ] || usage
if [ "$1" = "-n" ]
then
interactive=0
if [ $# -lt 2 ]
then
usage
fi
DEPT=$2
else
interactive=1
echo
echo "Ce script supprime la base de donnees ScoDoc d'un departement"
echo
echo "Attention: le departement doit au prealable avoir ete supprime via l'interface web !"
echo "faites le AVANT d'executer ce script !!!"
echo
echo -n "Nom du departement a supprimer (un mot sans ponctuation, exemple \"Info\"): "
read -r DEPT
fi
if [[ ! "$DEPT" =~ ^[A-Za-z0-9]+$ ]]
then
echo "Nom de departement invalide !"
exit 1
fi
export DEPT
cfg_pathname="${SCODOC_VAR_DIR}/config/depts/$DEPT".cfg
@ -44,18 +59,21 @@ then
scodocctl stop
# suppression de la base postgres
db_name=$(sed '/^dbname=*/!d; s///;q' < "$cfg_pathname")
db_name=$(cat "$cfg_pathname" | sed '/^dbname=*/!d; s///;q')
echo "suppression de la base postgres $db_name"
su -c "dropdb $db_name" "$POSTGRES_SUPERUSER" || terminate "ne peux supprimer base de donnees $db_name"
# suppression du fichier de config
/bin/rm -f "$cfg_pathname" || terminate "ne peux supprimer $cfg_pathname"
# relance ScoDoc
if [ "$interactive" = 1 ]
then
echo -n "Demarrer le serveur ScoDoc ? (y/n) [n]"
read -r ans
if [ "$(norm_ans "$ans")" = 'Y' ]
then
scodocctl start
fi
fi
exit 0
else
echo 'Erreur: pas de configuration trouvee pour "'"$DEPT"'"'

View File

@ -6,7 +6,7 @@
# Avec option:
# -a : sauve aussi les bases de données
#
DEST_ADDRESS=emmanuel.viennet@gmail.com
DEST_ADDRESS=emmanuel.viennet@univ-paris13.fr
INSTANCE_DIR=/opt/scodoc
@ -36,7 +36,7 @@ while getopts ":d:aunh" opt; do
SEND_BY_MAIL=0
;;
d)
DEPTS_TO_SAVE=$( join_by ' ' "$DEPTS_TO_SAVE" "$OPTARG" )
DEPTS_TO_SAVE=$( join_by ' ' $DEPTS_TO_SAVE $OPTARG )
;;
h)
echo "Diagnostic installation ScoDoc"
@ -71,7 +71,7 @@ then
apt-get install sharutils
fi
mkdir "$TMP"
mkdir $TMP
# Files to copy:
FILES="/etc/hosts /etc/debian_version /etc/apt /etc/apache2"
@ -91,33 +91,33 @@ echo "left in ${TMP}"
# -------------------------------------
copy_log() {
if [ -e "$1" ]
if [ -e $1 ]
then
cp "$1" "$TMP"/scodoc_logs/
cp $1 $TMP/scodoc_logs/
fi
}
mkdir "$TMP"/scodoc_logs/
copy_log /opt/scodoc/log/event.log
copy_log /opt/scodoc/log/event.log.1
copy_log /opt/scodoc/log/notes.log
copy_log /opt/scodoc/log/notes.log.1
mkdir $TMP/scodoc_logs/
copy_log /opt/scodoc/instance/log/event.log
copy_log /opt/scodoc/instance/log/event.log.1
copy_log /opt/scodoc/instance/log/notes.log
copy_log /opt/scodoc/instance/log/notes.log.1
# -------------------------------------
# Linux System Configuration
# -------------------------------------
iptables -L > "$TMP"/iptables.out
ip a > "$TMP"/ifconfig.out
ps auxww > "$TMP"/ps.out
df -h > "$TMP"/df.out
dpkg -l > "$TMP"/dpkg.lst
iptables -L > $TMP/iptables.out
ip a > $TMP/ifconfig.out
ps auxww > $TMP/ps.out
df -h > $TMP/df.out
dpkg -l > $TMP/dpkg.lst
(cd /opt/scodoc/Products/ScoDoc; svn status > "$TMP"/svn.status)
(cd /opt/scodoc/Products/ScoDoc; svn diff > "$TMP"/svn.diff)
(cd /opt/scodoc/instance/Products/ScoDoc; svn status > $TMP/svn.status)
(cd /opt/scodoc/instance/Products/ScoDoc; svn diff > $TMP/svn.diff)
(cd /opt/scodoc/Products/ScoDoc; svnversion > "$TMP"/svn.version)
ls -laR /opt/scodoc/Products/ScoDoc > "$TMP"/ls-laR
(cd /opt/scodoc/instance/Products/ScoDoc; svnversion > $TMP/svn.version)
ls -laR /opt/scodoc/instance/Products/ScoDoc > $TMP/ls-laR
# -------------------------------------
@ -126,7 +126,7 @@ ls -laR /opt/scodoc/Products/ScoDoc > "$TMP"/ls-laR
(su postgres -c "psql -l") > "${TMP}/psql-l.out"
for dept in "${INSTANCE_DIR}"/var/scodoc/config/depts/*.cfg
do
cnx=$(cat "$dept")
cnx=$(cat $dept)
(su postgres -c "echo '\dt' | psql -d $cnx") > "${TMP}/psql-$(basename ${dept%%.*}).out"
done
@ -137,14 +137,14 @@ done
# copy files:
for f in $FILES
do
cp -R "$f" "$TMP"
cp -R $f $TMP
done
# -------------------------------------
# Optionally save dept(s) database(s)
# -------------------------------------
DEPTS_TO_SAVE=$(echo "${DEPTS_TO_SAVE}" | tr ' ' '\n' | sort | uniq)
DEPTS_TO_SAVE=$(echo ${DEPTS_TO_SAVE} | tr ' ' '\n' | sort | uniq)
# Dump database of a dept (eg "RT")
function dump_dept_db {
@ -176,10 +176,10 @@ fi
# Archive all stuff to /tmp
# -------------------------------------
tar cfz "$TMP".tgz "$TMP"
tar cfz $TMP.tgz $TMP
echo
echo "Fichier de diagnostic: "$TMP".tgz"
echo "Fichier de diagnostic: $TMP.tgz"
echo
# If no mail, stop here
@ -197,9 +197,9 @@ fi
#requires: basename,date,md5sum,sed,sendmail,uuencode
function fappend {
echo "$2">>"$1";
echo "$2">>$1;
}
YYYYMMDD=$(date +%Y%m%d)
YYYYMMDD=`date +%Y%m%d`
# CHANGE THESE
TOEMAIL=$DEST_ADDRESS
@ -212,45 +212,45 @@ MIMETYPE="application/gnutar" #if not sure, use http://www.webmaster-toolkit.com
# DON'T CHANGE ANYTHING BELOW
TMP="/tmp/tmpfil_123"$RANDOM;
BOUNDARY=$(date +%s|md5sum)
BOUNDARY=`date +%s|md5sum`
BOUNDARY=${BOUNDARY:0:32}
FILENAME=$(basename "$ATTACHMENT")
FILENAME=`basename $ATTACHMENT`
rm -rf "$TMP"
uuencode --base64 "$FILENAME" < "$ATTACHMENT" >"$TMP"
sed -i -e '1,1d' -e '$d' "$TMP"; #removes first & last lines from "$TMP"
DATA=$(cat "$TMP")
rm -rf $TMP;
cat $ATTACHMENT|uuencode --base64 $FILENAME>$TMP;
sed -i -e '1,1d' -e '$d' $TMP;#removes first & last lines from $TMP
DATA=`cat $TMP`
rm -rf "$TMP";
fappend "$TMP" "From: $FREMAIL";
fappend "$TMP" "To: $TOEMAIL";
fappend "$TMP" "Reply-To: $FREMAIL";
fappend "$TMP" "Subject: $SUBJECT";
fappend "$TMP" "Content-Type: multipart/mixed; boundary=\""$BOUNDARY"\"";
fappend "$TMP" "";
fappend "$TMP" "This is a MIME formatted message. If you see this text it means that your";
fappend "$TMP" "email software does not support MIME formatted messages.";
fappend "$TMP" "";
fappend "$TMP" "--$BOUNDARY";
fappend "$TMP" "Content-Type: text/plain; charset=ISO-8859-1; format=flowed";
fappend "$TMP" "Content-Transfer-Encoding: 7bit";
fappend "$TMP" "Content-Disposition: inline";
fappend "$TMP" "";
fappend "$TMP" "$MSGBODY";
fappend "$TMP" "";
fappend "$TMP" "";
fappend "$TMP" "--$BOUNDARY";
fappend "$TMP" "Content-Type: $MIMETYPE; name=\"$FILENAME\"";
fappend "$TMP" "Content-Transfer-Encoding: base64";
fappend "$TMP" "Content-Disposition: attachment; filename=\"$FILENAME\";";
fappend "$TMP" "";
fappend "$TMP" "$DATA";
fappend "$TMP" "";
fappend "$TMP" "";
fappend "$TMP" "--$BOUNDARY--";
fappend "$TMP" "";
fappend "$TMP" "";
#cat "$TMP">out.txt
cat "$TMP"|sendmail -t -f none@example.com;
rm "$TMP";
rm -rf $TMP;
fappend $TMP "From: $FREMAIL";
fappend $TMP "To: $TOEMAIL";
fappend $TMP "Reply-To: $FREMAIL";
fappend $TMP "Subject: $SUBJECT";
fappend $TMP "Content-Type: multipart/mixed; boundary=\""$BOUNDARY"\"";
fappend $TMP "";
fappend $TMP "This is a MIME formatted message. If you see this text it means that your";
fappend $TMP "email software does not support MIME formatted messages.";
fappend $TMP "";
fappend $TMP "--$BOUNDARY";
fappend $TMP "Content-Type: text/plain; charset=ISO-8859-1; format=flowed";
fappend $TMP "Content-Transfer-Encoding: 7bit";
fappend $TMP "Content-Disposition: inline";
fappend $TMP "";
fappend $TMP "$MSGBODY";
fappend $TMP "";
fappend $TMP "";
fappend $TMP "--$BOUNDARY";
fappend $TMP "Content-Type: $MIMETYPE; name=\"$FILENAME\"";
fappend $TMP "Content-Transfer-Encoding: base64";
fappend $TMP "Content-Disposition: attachment; filename=\"$FILENAME\";";
fappend $TMP "";
fappend $TMP "$DATA";
fappend $TMP "";
fappend $TMP "";
fappend $TMP "--$BOUNDARY--";
fappend $TMP "";
fappend $TMP "";
#cat $TMP>out.txt
cat $TMP|sendmail -t -f none@example.com;
rm $TMP;

View File

@ -15,15 +15,15 @@ then
fi
echo "Changing to directory " "$SCODOC_DIR"/config
cd "$SCODOC_DIR"/config || { echo "directory does not exist"; exit 1; }
echo "Changing to directory " $SCODOC_DIR/config
cd $SCODOC_DIR/config
echo "Stopping ScoDoc..."
scodocctl stop
# DROITS
echo -n "Verification des droits: proprietaire www-data ? (y/n) [y] "
read -r ans
read ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
echo 'changing owner to www-data'
@ -31,7 +31,7 @@ then
fi
echo -n 'Suppression des backups des sources (*~) ? (y/n) [y] '
read -r ans
read ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
/bin/rm -f ../*~ ../*/*~
@ -40,7 +40,7 @@ fi
# SVN
echo -n "svn update ? (y/n) [y] "
read -r ans
read ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
echo 'Updating from SVN...'
@ -50,7 +50,7 @@ fi
# DEPARTEMENTS (maintenant inutile car dans /var)
echo -n "Supprimer les (anciennes) configs de departements ? (y/n) [y] "
read -r ans
read ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
echo "moving " depts/*.cfg "to /tmp"
@ -59,7 +59,7 @@ fi
# .../var/
echo -n "Supprimer et recréer .../var (archives, photos, configs, ...) ? (y/n) [y] "
read -r ans
read ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
echo "moving ../../../var/scodoc to /tmp"
@ -73,7 +73,7 @@ fi
# LOGS ZOPE
echo -n "Effacer les logs de Zope et ScoDoc ? (y/n) [y] "
read -r ans
read ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
(cd ../../../log/; ./purge)
@ -81,7 +81,7 @@ fi
# IMAGE Data.fs
echo -n "Recopier le Data.fs original ? (y/n) [y] "
read -r ans
read ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
echo "moving Data.fs to /tmp"

View File

@ -1,50 +0,0 @@
#!/bin/bash
# Get version information
# Use VERSION.py, last commit, diff, and last upstream commit date
source config.sh
source utils.sh
# Source code version:
x=$(grep SCOVERSION ../VERSION.py) || terminate "can't access VERSION.py" 1
x=${x#*\"}
src_version=${x%\"*}
# last commit
git_last_commit_hash=$(git log -1 --format=%h)
git_last_commit_date=$(git log -1 --format=%ci)
git_up_commit_hash=$(git log -1 --format=%h origin/ScoDoc8)
git_up_commit_date=$(git log -1 --format=%ci origin/ScoDoc8)
# Check if git has local changes
nchanges=$(git status --porcelain | grep -c -v '^??')
if [ "$nchanges" -gt 0 ]
then
has_local_changes="yes"
else
has_local_changes="no"
fi
# Synthetic one-line version:
sco_version="$src_version ($git_up_commit_hash) $git_up_commit_date"
if [ "$has_local_changes" = "yes" ]
then
sco_version="$sco_version (modified)"
fi
#
if [ "$1" = "-s" ]
then
echo "$sco_version"
else
echo src_version: "$src_version"
echo git_last_commit_hash: "$git_last_commit_hash"
echo git_last_commit_date: "$git_last_commit_date"
echo git_up_commit_hash: "$git_up_commit_hash"
echo git_up_commit_date: "$git_up_commit_date"
echo has_local_diffs: "$has_local_changes"
echo sco_version: "$sco_version"
fi

View File

@ -8,16 +8,15 @@
source config.sh
source utils.sh
if [ "$(id -nu)" != "$POSTGRES_USER" ]
if [ $(id -nu) != $POSTGRES_USER ]
then
echo "$0: script must be runned as user $POSTGRES_USER"
exit 1
fi
# shellcheck disable=SC2154
echo 'Initializing tables in database ' "$db_name"
$PSQL -U "$POSTGRES_USER" -p "$POSTGRES_PORT" "$db_name" -f "$SCODOC_DIR"/misc/createtables.sql
echo 'Initializing tables in database ' $db_name
$PSQL -U $POSTGRES_USER -p $POSTGRES_PORT $db_name -f $SCODOC_DIR/misc/createtables.sql
# Set DeptName in preferences:
echo "insert into sco_prefs (name, value) values ('DeptName', '"${DEPT}\'\) | $PSQL -U "$POSTGRES_USER" -p "$POSTGRES_PORT" "$db_name"
echo "insert into sco_prefs (name, value) values ('DeptName', '"${DEPT}\'\) | $PSQL -U $POSTGRES_USER -p $POSTGRES_PORT $db_name

View File

@ -2,10 +2,9 @@
#
# ScoDoc: install third-party software necessary for our installation
# starting for a minimal Debian (Buster, 10.0) install.
# starting for a minimal Debian (Stretch, 9.0) install.
#
# E. Viennet, Jun 2008, Apr 2009, Sept 2011, Sept 2013, Nov 2013, Mar 2017, Jul 2017,
# Jun 2019, Oct 2019, Dec 2020
# E. Viennet, Jun 2008, Apr 2009, Sept 2011, Sept 2013, Nov 2013, Mar 2017, Jul 2017, Jun 2019, Oct 2019
#
source config.sh
@ -13,14 +12,16 @@ source utils.sh
check_uid_root $0
PYTHON=/opt/zope213/bin/python
# ------------ Safety checks
if [ "${debian_version}" != "10" ]
if [ ${debian_version} != "10" ]
then
echo "Version du systeme Linux Debian incompatible"
exit 1
fi
if [ "$(arch)" != "x86_64" ]
if [ $(arch) != "x86_64" ]
then
echo "Version du systeme Linux Debian incompatible (pas X86 64 bits)"
exit 1
@ -28,8 +29,8 @@ fi
# ------------ Permissions & directories
# source dir should be writable by scodoc to write bytecode files
chgrp www-data "$SCODOC_DIR" "$SCODOC_DIR"/ZopeProducts/*
chmod g+w "$SCODOC_DIR" "$SCODOC_DIR"/ZopeProducts/*
chgrp www-data $SCODOC_DIR $SCODOC_DIR/ZopeProducts/*
chmod g+w $SCODOC_DIR $SCODOC_DIR/ZopeProducts/*
chgrp -R www-data "${SCODOC_VAR_DIR}"/photos
chmod -R g+w "${SCODOC_VAR_DIR}"/photos
@ -52,8 +53,8 @@ fi
for locname in en_US.UTF-8 en_US.ISO-8859-15 en_US.ISO-8859-1
do
outname=$(echo ${locname//-/} | tr 'A-Z' 'a-z')
if [ "$(locale -a | grep -E -i ^${outname}$ | wc -l)" -lt 1 ]
outname=$(echo ${locname//-/} | tr '[A-Z]' '[a-z]')
if [ $(locale -a | egrep -i ^${outname}$ | wc -l) -lt 1 ]
then
echo adding $locname
echo "$locname ${locname##*.}" >> /etc/locale.gen
@ -85,7 +86,7 @@ apt-get -y install postgresql
apt-get -y install graphviz
# ------------ INSTALL DES EXTENSIONS PYTHON (2.7)
# XXX to fix: pip in our env
apt-get -y install python-docutils
apt-get -y install python-jaxml
apt-get -y install python-psycopg2
@ -95,21 +96,20 @@ apt-get -y install python-cracklib # was python-crack
apt-get -y install python-icalendar
apt-get -y install python-requests
# XXX to fix: mx not needed anymore !
apt-get -y install python-egenix-mxtools python-egenix-mxdatetime
# ------------
SVNVERSION=$(cd ..; svnversion)
SVERSION=$(curl --silent http://scodoc.iutv.univ-paris13.fr/scodoc-installmgr/version?mode=install\&svn="$SVNVERSION")
echo "$SVERSION" > "${SCODOC_VERSION_DIR}/scodoc.sn"
SVERSION=$(curl --silent http://scodoc.iutv.univ-paris13.fr/scodoc-installmgr/version?mode=install\&svn=$SVNVERSION)
echo $SVERSION > "${SCODOC_VERSION_DIR}/scodoc.sn"
# ------------ POSTFIX
echo
echo "ScoDoc a besoin de pouvoir envoyer des messages par mail."
echo -n "Voulez vous configurer la messagerie (tres recommande) ? (y/n) [y] "
read -r ans
read ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
apt-get -y install postfix
@ -119,7 +119,7 @@ fi
echo
echo "Le firewall aide a proteger votre serveur d'intrusions indesirables."
echo -n "Voulez vous configurer un firewall minimal (ufw) ? (y/n) [n] "
read -r ans
read ans
if [ "$(norm_ans "$ans")" = 'Y' ]
then
echo 'Installation du firewall IP ufw (voir documentation Debian)'
@ -144,16 +144,16 @@ a2enmod rewrite
echo
echo "La configuration du serveur web va modifier votre installation Apache pour supporter ScoDoc."
echo -n "Voulez vous configurer le serveur web Apache maintenant (tres conseille) ? (y/n) [y] "
read -r ans
read ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
echo "Configuration d'Apache"
server_name=""
while [ -z "$server_name" ]
while [ -z $server_name ]
do
echo "Le nom de votre serveur doit normalement etre connu dans le DNS."
echo -n "Nom complet de votre serveur (exemple: notes.univ.fr): "
read -r server_name
read server_name
done
# --- CERTIFICATS AUTO-SIGNES
echo
@ -161,7 +161,7 @@ then
echo "auto-signes, qui ne seront pas reconnus comme de confiance"
echo "par les navigateurs, mais offrent une certaine securite."
echo -n 'Voulez vous generer des certificats ssl auto-signes ? (y/n) [y] '
read -r ans
read ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
# attention: utilise dans scodoc-site-ssl.orig
@ -177,7 +177,7 @@ then
fi
# ---
echo 'generation de /etc/apache2/sites-available/scodoc-site-ssl'
cat "$SCODOC_DIR"/config/etc/scodoc-site-ssl-apache2.4.orig | sed -e "s:YOUR\.FULL\.HOST\.NAME:$server_name:g" > /etc/apache2/sites-available/scodoc-site-ssl.conf
cat $SCODOC_DIR/config/etc/scodoc-site-ssl-apache2.4.orig | sed -e "s:YOUR\.FULL\.HOST\.NAME:$server_name:g" > /etc/apache2/sites-available/scodoc-site-ssl.conf
echo 'activation du site...'
a2ensite scodoc-site-ssl
@ -187,7 +187,7 @@ then
then
mv $fn $fn.bak
fi
cp "$SCODOC_DIR"/config/etc/scodoc-site.orig $fn
cp $SCODOC_DIR/config/etc/scodoc-site.orig $fn
if [ -z "$(grep Listen /etc/apache2/ports.conf | grep 443)" ]
then
@ -221,7 +221,7 @@ if [ "$(norm_ans "$ans")" != 'N' ]
then
# ScoDoc 7.19+ uses systemd
echo 'Installation du demarrage automatique de ScoDoc (systemd)'
cp "$SCODOC_DIR"/config/etc/scodoc.service /etc/systemd/system
cp $SCODOC_DIR/config/etc/scodoc.service /etc/systemd/system
systemctl enable scodoc.service
fi
@ -232,8 +232,8 @@ echo -n "Mises a jour hebdomadaires (tres recommande) ? (y/n) [y] "
read ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
cp "$SCODOC_DIR"/config/etc/scodoc-updater.service /etc/systemd/system
cp "$SCODOC_DIR"/config/etc/scodoc-updater.timer /etc/systemd/system
cp $SCODOC_DIR/config/etc/scodoc-updater.service /etc/systemd/system
cp $SCODOC_DIR/config/etc/scodoc-updater.timer /etc/systemd/system
systemctl enable scodoc-updater.timer
systemctl start scodoc-updater.timer
fi

0
config/migre-7-a-8.sh Executable file → Normal file
View File

View File

@ -8,7 +8,7 @@ PG_DUMPFILE=$1
# Check locale of installation. If invalid, reinitialize all system
is_latin1=$(psql -l | grep postgres | grep iso88591 | wc -l)
if [ "$is_latin1" -gt 1 ]
if [ $is_latin1 -gt 1 ]
then
echo "Recreating postgres cluster using UTF-8"
@ -20,8 +20,8 @@ fi
# Drop all current ScoDoc databases, if any:
for f in $(psql -l --no-align --field-separator . | grep SCO | cut -f 1 -d.); do
echo dropping "$f"
dropdb "$f"
echo dropping $f
dropdb $f
done
echo "Restoring postgres data..."
psql -f "$PG_DUMPFILE" postgres

View File

@ -57,7 +57,7 @@ then
echo "Opening tgz archive..."
tmp=$(mktemp -d)
chmod a+rx "$tmp"
cd "$tmp" || { echo "Fatal error: directory not available"; exit 1; }
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 || { echo "Fatal error: invalid directory"; exit 2; }
cd ${SCODOC_DIR:?}/config || terminate "no config directory"
./upgrade.sh
#

View File

@ -10,8 +10,6 @@
#
source utils.sh
check_uid_root "$0"
# Destination directory
if [ ! $# -eq 1 ]
then
@ -36,6 +34,9 @@ fi
INSTANCE_DIR=/opt/scodoc
SCODOC_DIR="$INSTANCE_DIR/Products/ScoDoc"
source utils.sh
check_uid_root "$0"
echo "Stopping ScoDoc..."
scodocctl stop
@ -43,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
printf "Error dumping postgresql database\nPlease check that SQL server is running\nAborting.\n"
printf "Error dumping postgresql database\nPlease check that SQL server is running\nAborting."
exit 1
fi
chown root "$DEST"
@ -85,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

@ -1,128 +0,0 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
#
# Configuration globale de ScoDoc (version juin 2009)
# Ce fichier est copié dans /opt/scodoc/var/scodoc/config
# par les scripts d'installation/mise à jour.
# La plupart des réglages sont stoqués en base de donnée et accessibles via le web
# (pages de paramètres ou préférences).
# Les valeurs indiquées ici sont les valeurs initiales que prendront
# les paramètres lors de la création d'un nouveau département,
# elles ne sont plus utilisées ensuite.
# Nota: il y a aussi des réglages dans sco_utils.py, mais ils nécessitent
# souvent de comprendre le code qui les utilise pour ne pas faire d'erreur: attention.
class CFG:
pass
CONFIG = CFG()
# set to 1 if you want to require INE:
# CONFIG.always_require_ine = 0
# The base URL, use only if you are behind a proxy
# eg "https://scodoc.example.net/ScoDoc"
# CONFIG.ABSOLUTE_URL = ""
# -----------------------------------------------------
# -------------- Documents PDF
# -----------------------------------------------------
# Taille du l'image logo: largeur/hauteur (ne pas oublier le . !!!)
# W/H XXX provisoire: utilisera PIL pour connaitre la taille de l'image
# CONFIG.LOGO_FOOTER_ASPECT = 326 / 96.0
# Taille dans le document en millimetres
# CONFIG.LOGO_FOOTER_HEIGHT = 10
# Proportions logo (donné ici pour IUTV)
# CONFIG.LOGO_HEADER_ASPECT = 549 / 346.0
# Taille verticale dans le document en millimetres
# CONFIG.LOGO_HEADER_HEIGHT = 28
# Pied de page PDF : un format Python, %(xxx)s est remplacé par la variable xxx.
# Les variables définies sont:
# day : Day of the month as a decimal number [01,31]
# month : Month as a decimal number [01,12].
# year : Year without century as a decimal number [00,99].
# Year : Year with century as a decimal number.
# hour : Hour (24-hour clock) as a decimal number [00,23].
# minute: Minute as a decimal number [00,59].
#
# server_url: URL du serveur ScoDoc
# scodoc_name: le nom du logiciel (ScoDoc actuellement, voir VERSION.py)
# CONFIG.DEFAULT_PDF_FOOTER_TEMPLATE = "Edité par %(scodoc_name)s le %(day)s/%(month)s/%(year)s à %(hour)sh%(minute)s sur %(server_url)s"
#
# ------------- Calcul bonus modules optionnels (sport, culture...) -------------
#
# CONFIG.compute_bonus = bonus_sport.bonus_iutv
# Mettre "bonus_demo" pour logguer des informations utiles au developpement...
#
# ------------- Capitalisation des UEs -------------
# Deux écoles:
# - règle "DUT": capitalisation des UE obtenues avec moyenne UE >= 10 ET de toutes les UE
# des semestres validés (ADM, ADC, AJ). (conforme à l'arrêté d'août 2005)
#
# - règle "LMD": capitalisation uniquement des UE avec moy. > 10
# Si vrai, capitalise toutes les UE des semestres validés (règle "DUT").
# CONFIG.CAPITALIZE_ALL_UES = True
#
# -----------------------------------------------------
#
# -------------- Personnalisation des pages
#
# -----------------------------------------------------
# Nom (chemin complet) d'un fichier .html à inclure juste après le <body>
# le <body> des pages ScoDoc
# CONFIG.CUSTOM_HTML_HEADER = ""
# Fichier html a inclure en fin des pages (juste avant le </body>)
# CONFIG.CUSTOM_HTML_FOOTER = ""
# Fichier .html à inclure dans la pages connexion/déconnexion (accueil)
# si on veut que ce soit différent (par défaut la même chose)
# CONFIG.CUSTOM_HTML_HEADER_CNX = CONFIG.CUSTOM_HTML_HEADER
# CONFIG.CUSTOM_HTML_FOOTER_CNX = CONFIG.CUSTOM_HTML_FOOTER
# -----------------------------------------------------
# -------------- Noms de Lycées
# -----------------------------------------------------
# Fichier de correspondance codelycee -> noms
# (chemin relatif au repertoire d'install des sources)
# CONFIG.ETABL_FILENAME = "config/etablissements.csv"
# ----------------------------------------------------
# -------------- Divers:
# ----------------------------------------------------
# True for UCAC (étudiants camerounais sans prénoms)
# CONFIG.ALLOW_NULL_PRENOM = False
# Taille max des fichiers archive etudiants (en octets)
# CONFIG.ETUD_MAX_FILE_SIZE = 10 * 1024 * 1024
# Si pas de photo et portail, publie l'url (était vrai jusqu'en oct 2016)
# CONFIG.PUBLISH_PORTAL_PHOTO_URL = False
# Si > 0: longueur minimale requise des nouveaux mots de passe
# (le test cracklib.FascistCheck s'appliquera dans tous les cas)
# CONFIG.MIN_PASSWORD_LENGTH = 0
# Ce dictionnaire est fusionné à celui de sco_codes_parcours
# pour définir les codes jury et explications associées
# CONFIG.CODES_EXPL = {
# # AJ : 'Ajourné (échec)',
# }

View File

@ -4,7 +4,7 @@
# ScoDoc: reglage du mot de passe admin Zope
# (in Zope terminology, an emergency user)
#
# Doit <EFBFBD>tre lanc<6E> par l'utilisateur unix root dans le repertoire .../config
# Doit être lancé par l'utilisateur unix root dans le repertoire .../config
# ^^^^^^^^^^^^^^^^^^^^^
# E. Viennet, Juin 2008, Jul 2019
#
@ -22,14 +22,14 @@ fi
echo "Creation d'un utilisateur d'urgence pour ScoDoc"
echo "(utile en cas de perte de votre mot de passe admin)"
if [ "${debian_version}" != "10" ]
if [ ${debian_version} != "10" ]
then
mdir=/opt/zope213/lib/python2.7/site-packages/Zope2-2.13.21-py2.7.egg/Zope2/utilities
else
mdir=/opt/zope213/lib/python2.7/site-packages/Zope2/utilities
fi
python $mdir/zpasswd.py "$SCODOC_DIR"/../../access
python $mdir/zpasswd.py $SCODOC_DIR/../../access
echo
echo "redemarrer scodoc pour prendre en compte le mot de passe"

View File

@ -1,20 +1,20 @@
#!/bin/bash
# Upgrade ScoDoc installation using GIT
# GIT must be properly configured and have read access to ScoDoc repository
# Upgrade ScoDoc installation using SVN
# SVN must be properly configured and have read access to ScoDoc repository
# This script STOP and RESTART ScoDoc and should be runned as root
#
# Upgrade also the Linux system using apt.
#
# Script for ScoDoc 8 (10)
# Script for ScoDoc 7 (Debian 7, 8, 9, 10)
#
# E. Viennet, sep 2013, mar 2017, jun 2019, aug 2020, dec 2020
# E. Viennet, sep 2013, mar 2017, jun 2019, aug 2020
cd /opt/scodoc/Products/ScoDoc/config || { echo "Invalid directory"; exit 1; }
cd /opt/scodoc/Products/ScoDoc/config
source config.sh
source utils.sh
check_uid_root "$0"
check_uid_root $0
if [ -z "$SCODOC_UPGRADE_RUNNING" ]
then
@ -31,8 +31,8 @@ fi
scodocctl stop
echo
echo "Using git to update $SCODOC_DIR..."
(cd "$SCODOC_DIR"; git checkout ScoDoc8; git pull origin master)
echo "Using SVN to update $SCODOC_DIR..."
(cd "$SCODOC_DIR"; svn update)
SVNVERSION=$(cd ..; svnversion)
@ -72,13 +72,13 @@ fi
# Check that no Zope "access" file has been forgotten in the way:
if [ -e "$SCODOC_DIR"/../../access ]
if [ -e $SCODOC_DIR/../../access ]
then
mv "$SCODOC_DIR"/../../access "$SCODOC_DIR"/../../access.bak
mv $SCODOC_DIR/../../access $SCODOC_DIR/../../access.bak
fi
# Fix some permissions which may have been altered in the way:
chsh -s /bin/sh "$POSTGRES_USER" # www-data, nologin in Debian 9
chsh -s /bin/sh $POSTGRES_USER # www-data, nologin in Debian 9
chown root.www-data "$SCODOC_DIR" # important to create .pyc
chmod 775 "${SCODOC_DIR}"
chmod a+r "$SCODOC_DIR"/*.py
@ -118,19 +118,6 @@ if [ $? -ne 0 ]
then
/opt/zope213/bin/pip install requests
fi
/opt/zope213/bin/python -c "import attrdict" >& /dev/null
if [ $? -ne 0 ]
then
/opt/zope213/bin/pip install attrdict
fi
# Check that local configuration file is installed
LOCAL_CONFIG_FILENAME="/opt/scodoc/var/scodoc/config/scodoc_local.py"
if [ ! -e "$LOCAL_CONFIG_FILENAME" ]
then
cp "$SCODOC_DIR"/config/scodoc_config_tmpl.py "$LOCAL_CONFIG_FILENAME"
chmod 600 "$LOCAL_CONFIG_FILENAME"
fi
# Ensure www-data can duplicate databases (for dumps)
su -c $'psql -c \'alter role "www-data" with CREATEDB;\'' "$POSTGRES_SUPERUSER"
@ -141,7 +128,7 @@ echo "Executing post-upgrade script..."
"$SCODOC_DIR"/config/postupgrade.py
echo "Executing post-upgrade database script..."
su -c "$SCODOC_DIR/config/postupgrade-db.py" "$POSTGRES_USER"
su -c "$SCODOC_DIR/config/postupgrade-db.py" $POSTGRES_USER
#
echo

View File

@ -1,17 +1,17 @@
#!/bin/bash
# Misc utilities for ScoDoc install shell scripts
to_lower() {
echo "$1" | tr "[:upper:]" "[:lower:]"
echo $1 | tr "[:upper:]" "[:lower:]"
}
to_upper() {
echo "$1" | tr "[:lower:]" "[:upper:]"
echo $1 | tr "[:lower:]" "[:upper:]"
}
norm_ans() {
x=$(to_upper "$1" | tr O Y)
echo "${x:0:1}"
x=$(to_upper $1 | tr O Y)
echo ${x:0:1}
}
check_uid_root() {
@ -23,11 +23,10 @@ check_uid_root() {
}
terminate() {
status=${2:-1} # default: exit 1
echo
echo "Erreur: $1"
echo
exit $status
exit 1
}
# Start/stop scodoc, using sysv or systemd
@ -45,7 +44,7 @@ scodocctl() {
systemctl $1 scodoc
else
echo "(using legacy SystemV)"
/etc/init.d/scodoc "$1"
/etc/init.d/scodoc $1
fi
}
@ -55,7 +54,7 @@ init_postgres_user() { # run as root
then
# add database user
echo "Creating postgresql user $POSTGRES_USER"
su -c "createuser -p $POSTGRES_PORT --no-superuser --no-createdb --no-adduser --no-createrole ${POSTGRES_USER}" "$POSTGRES_SUPERUSER"
su -c "createuser -p $POSTGRES_PORT --no-superuser --no-createdb --no-adduser --no-createrole ${POSTGRES_USER}" $POSTGRES_SUPERUSER
fi
}
@ -70,8 +69,8 @@ gen_passwd() {
password=""
while [ "$n" -le "$PASSWORD_LENGTH" ]
do
password="$password${ALLOWABLE_ASCII:$((RANDOM%${#ALLOWABLE_ASCII})):1}"
password="$password${ALLOWABLE_ASCII:$(($RANDOM%${#ALLOWABLE_ASCII})):1}"
n=$((n+1))
done
echo "$password"
echo $password
}

View File

@ -31,6 +31,8 @@ nt = context.Notes._getNotesCache().get_NotesTable(context.Notes, formsemestre_i
"""
import pdb
from notesdb import *
from notes_log import log
from sco_utils import *
@ -78,6 +80,9 @@ class FakeUser:
def has_permission(self, op, context):
return True
def has_role(self, role):
return True
class DummyResponse:
"""Emulation vide de Reponse http Zope"""
@ -104,6 +109,7 @@ class DummyRequest:
self.URL1 = self.URL
self.URL0 = self.URL
self.BASE0 = "localhost"
self.REMOTE_HOST = "localhost"
self.REMOTE_ADDR = "127.0.0.1"
self.HTTP_REFERER = ""
self.REQUEST_METHOD = "get"

View File

@ -394,7 +394,7 @@ CREATE TABLE notes_formsemestre (
elt_annee_apo text -- code element annee Apogee, eg VRT1A ou V2INLA,V2INCA
) WITH OIDS;
-- id des utilsateurs responsables (aka directeurs des etudes) du semestre:
-- id des utilisateurs responsables (aka directeurs des etudes) du semestre:
CREATE TABLE notes_formsemestre_responsables (
formsemestre_id text REFERENCES notes_formsemestre(formsemestre_id) ON DELETE CASCADE,
responsable_id text NOT NULL,

View File

@ -51,5 +51,5 @@ telephone; text; adresse; 1; num. telephone (fixe)
telephonemobile; text; adresse; 1; num. telephone (mobile)
#
# Pas tout à fait admission:
debouche;text; admissions;1;situation APRES être passé par chez nous;
debouche;text; admissions;1;(OBSOLETE, ne plus utiliser) situation APRES être passé par chez nous;

View File

@ -2,11 +2,10 @@
# -*- coding: utf-8 -*-
import pdb, os, sys, time, re, inspect
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.Header import Header
import traceback
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email.header import Header
# Simple & stupid file logguer, used only to debug
# (logging to SQL is done in scolog)
@ -35,7 +34,7 @@ class _logguer:
if LOG_FILENAME:
path = os.path.join(self.directory, LOG_FILENAME)
self.file = open(path, "a")
self("new _logguer")
self("new _logguer (%s)" % path)
else:
self.file = None # logging disabled
@ -89,7 +88,7 @@ def retreive_dept():
return ""
try:
url = REQUEST.URL
m = re.match(r"^.*ScoDoc/(\w+).*$", url)
m = re.match("^.*ScoDoc/(\w+).*$", url)
return m.group(1)
except:
return ""

View File

@ -248,8 +248,7 @@ def DBDelete(cnx, table, colid, val, commit=False):
class EditableTable:
""" --- generic class: SQL table with create/edit/list/delete
"""
"""--- generic class: SQL table with create/edit/list/delete"""
def __init__(
self,
@ -377,7 +376,11 @@ class EditableTable:
# format value
for title in vals.keys():
if self.input_formators.has_key(title):
try:
vals[title] = self.input_formators[title](vals[title])
except:
log("exception while converting %s=%s" % (title, vals[title]))
raise
DBUpdateArgs(
cnx,
self.table_name,

View File

@ -460,11 +460,11 @@ def get_templates_from_distrib(template="avis"):
if template in ["avis", "footer"]:
# pas de preference pour le template: utilise fichier du serveur
p = os.path.join(SCO_SRC_DIR, pe_local_tmpl)
p = os.path.join(SCO_SRCDIR, pe_local_tmpl)
if os.path.exists(p):
template_latex = get_code_latex_from_modele(p)
else:
p = os.path.join(SCO_SRC_DIR, pe_default_tmpl)
p = os.path.join(SCO_SRCDIR, pe_default_tmpl)
if os.path.exists(p):
template_latex = get_code_latex_from_modele(p)
else:
@ -474,7 +474,8 @@ def get_templates_from_distrib(template="avis"):
# ----------------------------------------------------------------------------------------
def table_syntheseAnnotationPE(context, syntheseJury, tag_annotation_pe):
"""Génère un fichier excel synthétisant les annotations PE telles qu'inscrites dans les fiches de chaque étudiant"""
"""Génère un fichier excel synthétisant les annotations PE telles qu'inscrites dans les fiches de chaque étudiant
"""
sT = SeqGenTable() # le fichier excel à générer
# Les etudids des étudiants à afficher, triés par ordre alphabétiques de nom+prénom

View File

@ -122,7 +122,8 @@ def remove_accents(input_unicode_str):
def escape_for_latex(s):
"""Protège les caractères pour inclusion dans du source LaTeX"""
"""Protège les caractères pour inclusion dans du source LaTeX
"""
if not s:
return ""
conv = {
@ -161,7 +162,8 @@ def list_directory_filenames(path):
def add_local_file_to_zip(zipfile, ziproot, pathname, path_in_zip):
"""Read pathname server file and add content to zip under path_in_zip"""
"""Read pathname server file and add content to zip under path_in_zip
"""
rooted_path_in_zip = os.path.join(ziproot, path_in_zip)
data = open(pathname).read()
zipfile.writestr(rooted_path_in_zip, data)
@ -175,7 +177,7 @@ def add_pe_stuff_to_zip(context, zipfile, ziproot):
Also copy logos
"""
PE_AUX_DIR = os.path.join(SCO_SRC_DIR, "config/doc_poursuites_etudes")
PE_AUX_DIR = os.path.join(SCO_SRCDIR, "config/doc_poursuites_etudes")
distrib_dir = os.path.join(PE_AUX_DIR, "distrib")
distrib_pathnames = list_directory_filenames(
distrib_dir

View File

@ -32,9 +32,10 @@
Il suffit d'appeler abs_notify() après chaque ajout d'absence.
"""
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.Header import Header
from email import Encoders
from notesdb import *
from sco_utils import *
@ -63,7 +64,8 @@ def abs_notify(context, etudid, date):
def do_abs_notify(context, sem, etudid, date, nbabs, nbabsjust):
"""Given new counts of absences, check if notifications are requested and send them."""
"""Given new counts of absences, check if notifications are requested and send them.
"""
# prefs fallback to global pref if sem is None:
if sem:
formsemestre_id = sem["formsemestre_id"]
@ -129,7 +131,8 @@ def abs_notify_send(
def abs_notify_get_destinations(context, sem, prefs, etudid, date, nbabs, nbabsjust):
"""Returns set of destination emails to be notified"""
"""Returns set of destination emails to be notified
"""
formsemestre_id = sem["formsemestre_id"]
destinations = [] # list of email address to notify
@ -279,7 +282,8 @@ def retreive_current_formsemestre(context, etudid, cur_date):
def mod_with_evals_at_date(context, date_abs, etudid):
"""Liste des moduleimpls avec des evaluations a la date indiquée"""
"""Liste des moduleimpls avec des evaluations a la date indiquée
"""
req = """SELECT m.* FROM notes_moduleimpl m, notes_evaluation e, notes_moduleimpl_inscription i
WHERE m.moduleimpl_id = e.moduleimpl_id AND e.moduleimpl_id = i.moduleimpl_id
AND i.etudid = %(etudid)s AND e.jour = %(date_abs)s"""

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

@ -28,11 +28,11 @@
"""Génération des bulletins de notes
"""
import email
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email.header import Header
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email.Header import Header
from email import Encoders
import htmlutils, time
from reportlab.lib.colors import Color
@ -331,7 +331,7 @@ def formsemestre_bulletinetud_dict(
context, ue_status["formsemestre_id"]
) # > toutes notes
u["modules_capitalized"], _ = _ue_mod_bulletin(
u["modules_capitalized"], junk = _ue_mod_bulletin(
context,
etudid,
formsemestre_id,
@ -435,8 +435,15 @@ def _ue_mod_bulletin(context, etudid, formsemestre_id, ue_id, modimpls, nt, vers
if mod["mod_moy_txt"][:2] == "NA":
mod["mod_moy_txt"] = "-"
if is_malus:
mod["mod_moy_txt"] = ""
mod["mod_coef_txt"] = ""
if mod_moy > 0:
mod["mod_moy_txt"] = fmt_note(mod_moy)
mod["mod_coef_txt"] = "Malus"
elif mod_moy < 0:
mod["mod_moy_txt"] = fmt_note(-mod_moy)
mod["mod_coef_txt"] = "Bonus"
else:
mod["mod_moy_txt"] = "-"
mod["mod_coef_txt"] = "-"
else:
mod["mod_coef_txt"] = fmt_coef(modimpl["module"]["coefficient"])
if mod["mod_moy_txt"] != "NI": # ne montre pas les modules 'non inscrit'
@ -990,7 +997,7 @@ def mail_bulletin(context, formsemestre_id, I, pdfdata, filename, recipient_addr
att = MIMEBase("application", "pdf")
att.add_header("Content-Disposition", "attachment", filename=filename)
att.set_payload(pdfdata)
email.encoders.encode_base64(att)
Encoders.encode_base64(att)
msg.attach(att)
log("mail bulletin a %s" % msg["To"])
context.sendEmail(msg)

View File

@ -48,10 +48,22 @@ Balises img: actuellement interdites.
"""
import traceback, re
import sco_utils as scu
import sco_formsemestre
from sco_pdf import *
import sco_pdf
from sco_pdf import Color, Paragraph, Spacer, Table
from sco_pdf import blue, cm, mm
from sco_pdf import SU
import sco_preferences
from notes_log import log
from sco_permissions import ScoEtudInscrit
from sco_codes_parcours import (
UE_COLORS,
UE_DEFAULT_COLOR,
UE_ELECTIVE,
UE_SPORT,
UE_STANDARD,
)
import sco_bulletins_generator
import sco_bulletins_pdf
import sco_groups
@ -271,7 +283,6 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
context = self.context
P = [] # elems pour générer table avec gen_table (liste de dicts)
formsemestre_id = I["formsemestre_id"]
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
prefs = context.get_preferences(formsemestre_id)
# Colonnes à afficher:
@ -328,8 +339,8 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
linktmpl = (
'<span onclick="toggle_vis_ue(this);" class="toggle_ue">%s</span>&nbsp;'
)
minuslink = linktmpl % icontag("minus_img", border="0", alt="-")
pluslink = linktmpl % icontag("plus_img", border="0", alt="+")
minuslink = linktmpl % scu.icontag("minus_img", border="0", alt="-")
pluslink = linktmpl % scu.icontag("plus_img", border="0", alt="+")
# 1er ligne titres
t = {
@ -384,9 +395,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
P.append(t)
# Rangs dans les partitions:
partitions, partitions_etud_groups = sco_groups.get_formsemestre_groups(
context, formsemestre_id
)
partitions, _ = sco_groups.get_formsemestre_groups(context, formsemestre_id)
for partition in partitions:
if partition["bul_show_rank"]:
partition_id = partition["partition_id"]
@ -486,10 +495,10 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
t["_css_row_class"] += " notes_bulletin_row_ue_cur"
t["_titre_help"] = "(en cours, non prise en compte)"
if prefs["bul_show_minmax"]:
t["min"] = fmt_note(ue["min"])
t["max"] = fmt_note(ue["max"])
t["min"] = scu.fmt_note(ue["min"])
t["max"] = scu.fmt_note(ue["max"])
if prefs["bul_show_moypromo"]:
t["moy"] = fmt_note(ue["moy"]).replace("NA", "-")
t["moy"] = scu.fmt_note(ue["moy"]).replace("NA", "-")
# Cas particulier des UE sport (bonus)
if ue["type"] == UE_SPORT and not ue_descr:
del t["module"]
@ -544,8 +553,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
rowstyle="",
hidden=False,
):
"""Liste dans la table les descriptions des modules et, si version != short, des évaluations.
"""
"""Liste dans la table les descriptions des modules et, si version != short, des évaluations."""
if ue_type == "cur": # UE courante non prise en compte (car capitalisee)
pdf_style_bg = [("BACKGROUND", (0, 0), (-1, 0), self.PDF_UE_CUR_BG)]
else:
@ -596,10 +604,10 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
"_pdf_style": pdf_style,
}
if prefs["bul_show_minmax_mod"]:
t["min"] = fmt_note(mod["stats"]["min"])
t["max"] = fmt_note(mod["stats"]["max"])
t["min"] = scu.fmt_note(mod["stats"]["min"])
t["max"] = scu.fmt_note(mod["stats"]["max"])
if prefs["bul_show_moypromo"]:
t["moy"] = fmt_note(mod["stats"]["moy"]).replace("NA", "-")
t["moy"] = scu.fmt_note(mod["stats"]["moy"]).replace("NA", "-")
P.append(t)
if self.version != "short":
@ -660,12 +668,15 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
t["note"] = "<i>" + e["note_txt"] + "</i>"
else:
t["_module_colspan"] = 2
if prefs["bul_show_minmax_eval"]:
if prefs["bul_show_minmax_eval"] or prefs["bul_show_moypromo"]:
etat = sco_evaluations.do_evaluation_etat(
self.context, e["evaluation_id"]
)
t["min"] = fmt_note(etat["mini"])
t["max"] = fmt_note(etat["maxi"])
if prefs["bul_show_minmax_eval"]:
t["min"] = scu.fmt_note(etat["mini"])
t["max"] = scu.fmt_note(etat["maxi"])
if prefs["bul_show_moypromo"]:
t["moy"] = scu.fmt_note(etat["moy"])
P.append(t)
nbeval += 1
return nbeval

View File

@ -116,8 +116,7 @@ CODES_EXPL = {
RAT: "En attente d'un rattrapage",
DEF: "Défaillant",
}
# Nota: ces explications sont personnalisables via le fichier
# de config locale /opt/scodoc/var/scodoc/config/scodoc_local.py
# Nota: ces explications sont personnalisables via le fichier de config scodoc_config.py
# variable: CONFIG.CODES_EXP
CODES_SEM_VALIDES = {ADM: True, ADC: True, ADJ: True} # semestre validé

View File

@ -315,7 +315,7 @@ def do_moduleimpl_moyennes(context, nt, mod):
notes.append(0.0)
coefs.append(0.0)
coefs_mask.append(0)
if nb_notes > 0:
if nb_notes > 0 or formula_use_abs:
user_moy = compute_user_formula(
context,
sem,

View File

@ -1,109 +0,0 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
"""Configuration de ScoDoc (version 2020)
NE PAS MODIFIER localement ce fichier !
mais éditer /opt/scodoc/var/scodoc/config/scodoc_local.py
"""
from attrdict import AttrDict
import bonus_sport
CONFIG = AttrDict()
# set to 1 if you want to require INE:
CONFIG.always_require_ine = 0
# The base URL, use only if you are behind a proxy
# eg "https://scodoc.example.net/ScoDoc"
CONFIG.ABSOLUTE_URL = ""
# -----------------------------------------------------
# -------------- Documents PDF
# -----------------------------------------------------
# Taille du l'image logo: largeur/hauteur (ne pas oublier le . !!!)
# W/H XXX provisoire: utilisera PIL pour connaitre la taille de l'image
CONFIG.LOGO_FOOTER_ASPECT = 326 / 96.0
# Taille dans le document en millimetres
CONFIG.LOGO_FOOTER_HEIGHT = 10
# Proportions logo (donné ici pour IUTV)
CONFIG.LOGO_HEADER_ASPECT = 549 / 346.0
# Taille verticale dans le document en millimetres
CONFIG.LOGO_HEADER_HEIGHT = 28
# Pied de page PDF : un format Python, %(xxx)s est remplacé par la variable xxx.
# Les variables définies sont:
# day : Day of the month as a decimal number [01,31]
# month : Month as a decimal number [01,12].
# year : Year without century as a decimal number [00,99].
# Year : Year with century as a decimal number.
# hour : Hour (24-hour clock) as a decimal number [00,23].
# minute: Minute as a decimal number [00,59].
#
# server_url: URL du serveur ScoDoc
# scodoc_name: le nom du logiciel (ScoDoc actuellement, voir VERSION.py)
CONFIG.DEFAULT_PDF_FOOTER_TEMPLATE = "Edité par %(scodoc_name)s le %(day)s/%(month)s/%(year)s à %(hour)sh%(minute)s sur %(server_url)s"
#
# ------------- Calcul bonus modules optionnels (sport, culture...) -------------
#
CONFIG.compute_bonus = bonus_sport.bonus_iutv
# Mettre "bonus_demo" pour logguer des informations utiles au developpement...
# ------------- Capitalisation des UEs -------------
# Deux écoles:
# - règle "DUT": capitalisation des UE obtenues avec moyenne UE >= 10 ET de toutes les UE
# des semestres validés (ADM, ADC, AJ). (conforme à l'arrêté d'août 2005)
#
# - règle "LMD": capitalisation uniquement des UE avec moy. > 10
# Si vrai, capitalise toutes les UE des semestres validés (règle "DUT").
# CONFIG.CAPITALIZE_ALL_UES = True
# -----------------------------------------------------
# -------------- Personnalisation des pages
# -----------------------------------------------------
# Nom (chemin complet) d'un fichier .html à inclure juste après le <body>
# le <body> des pages ScoDoc
CONFIG.CUSTOM_HTML_HEADER = ""
# Fichier html a inclure en fin des pages (juste avant le </body>)
CONFIG.CUSTOM_HTML_FOOTER = ""
# Fichier .html à inclure dans la pages connexion/déconnexion (accueil)
# si on veut que ce soit différent (par défaut la même chose)
CONFIG.CUSTOM_HTML_HEADER_CNX = CONFIG.CUSTOM_HTML_HEADER
CONFIG.CUSTOM_HTML_FOOTER_CNX = CONFIG.CUSTOM_HTML_FOOTER
# -----------------------------------------------------
# -------------- Noms de Lycées
# -----------------------------------------------------
# Fichier de correspondance codelycee -> noms
# (chemin relatif au repertoire d'install des sources)
CONFIG.ETABL_FILENAME = "config/etablissements.csv"
# ----------------------------------------------------
# -------------- Divers:
# ----------------------------------------------------
# True for UCAC (étudiants camerounais sans prénoms)
CONFIG.ALLOW_NULL_PRENOM = False
# Taille max des fichiers archive etudiants (en octets)
# CONFIG.ETUD_MAX_FILE_SIZE = 10 * 1024 * 1024
# Si pas de photo et portail, publie l'url (était vrai jusqu'en oct 2016)
CONFIG.PUBLISH_PORTAL_PHOTO_URL = False
# Si > 0: longueur minimale requise des nouveaux mots de passe
# (le test cracklib.FascistCheck s'appliquera dans tous les cas)
CONFIG.MIN_PASSWORD_LENGTH = 0
# Ce dictionnaire est fusionné à celui de sco_codes_parcours
# pour définir les codes jury et explications associées
CONFIG.CODES_EXPL = {
# AJ : 'Ajourné (échec)',
}

View File

@ -1,44 +0,0 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
"""Chargement de la configuration locale
"""
import os
import sys
import sco_utils
from sco_utils import log, SCODOC_CFG_DIR
import sco_config
# scodoc_local defines a CONFIG object
# here we check if there is a local config file
def load_local_configuration():
"""Load local configuration file (if exists)
and merge it with CONFIG.
"""
# this path should be synced with upgrade.sh
LOCAL_CONFIG_FILENAME = os.path.join(SCODOC_CFG_DIR, "scodoc_local.py")
LOCAL_CONFIG = None
if os.path.exists(LOCAL_CONFIG_FILENAME):
if not SCODOC_CFG_DIR in sys.path:
sys.path.insert(1, SCODOC_CFG_DIR)
try:
from scodoc_local import CONFIG as LOCAL_CONFIG
log("imported %s" % LOCAL_CONFIG_FILENAME)
except ImportError:
log("Error: can't import %s" % LOCAL_CONFIG_FILENAME)
del sys.path[1]
if LOCAL_CONFIG is None:
return
# Now merges local config in our CONFIG
for x in [x for x in dir(LOCAL_CONFIG) if x[0] != "_"]:
v = getattr(LOCAL_CONFIG, x)
if not v in sco_config.CONFIG:
log("Warning: local config setting unused parameter %s (skipped)" % x)
else:
if v != sco_config.CONFIG[x]:
log("Setting parameter %s from %s" % (x, LOCAL_CONFIG_FILENAME))
sco_config.CONFIG[x] = v

View File

@ -28,12 +28,14 @@
"""
Rapport (table) avec dernier semestre fréquenté et débouché de chaque étudiant
"""
from types import StringType
import safehtml
from notesdb import *
from sco_utils import *
import sco_utils as scu
import notesdb
from notes_log import log
import VERSION
from sco_exceptions import AccessDenied
from scolog import logdb
from gen_tables import GenTable
import sco_formsemestre
@ -42,8 +44,7 @@ import sco_tag_module
def report_debouche_date(context, start_year=None, format="html", REQUEST=None):
"""Rapport (table) pour les débouchés des étudiants sortis à partir de l'année indiquée.
"""
"""Rapport (table) pour les débouchés des étudiants sortis à partir de l'année indiquée."""
if not start_year:
return report_debouche_ask_date(context, REQUEST=REQUEST)
if format == "xls":
@ -54,8 +55,8 @@ def report_debouche_date(context, start_year=None, format="html", REQUEST=None):
etudids = get_etudids_with_debouche(context, start_year)
tab = table_debouche_etudids(context, etudids, keep_numeric=keep_numeric)
tab.filename = make_filename("debouche_scodoc_%s" % start_year)
tab.origin = "Généré par %s le " % VERSION.SCONAME + timedate_human_repr() + ""
tab.filename = scu.make_filename("debouche_scodoc_%s" % start_year)
tab.origin = "Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + ""
tab.caption = "Récapitulatif débouchés à partir du 1/1/%s." % start_year
tab.base_url = "%s?start_year=%s" % (REQUEST.URL0, start_year)
return tab.make_page(
@ -77,7 +78,7 @@ def get_etudids_with_debouche(context, start_year):
start_date = str(start_year) + "-01-01"
# Recupere tous les etudid avec un debouché renseigné et une inscription dans un semestre
# posterieur à la date de depart:
# r = SimpleDictFetch(context,
# r = notesdb.SimpleDictFetch(context,
# """SELECT DISTINCT i.etudid
# FROM notes_formsemestre_inscription i, admissions adm, notes_formsemestre s
# WHERE adm.debouche is not NULL
@ -86,7 +87,7 @@ def get_etudids_with_debouche(context, start_year):
# """,
# {'start_date' : start_date })
r = SimpleDictFetch(
r = notesdb.SimpleDictFetch(
context,
"""SELECT DISTINCT i.etudid
FROM notes_formsemestre_inscription i, notes_formsemestre s, itemsuivi it
@ -100,8 +101,7 @@ def get_etudids_with_debouche(context, start_year):
def table_debouche_etudids(context, etudids, keep_numeric=True):
"""Rapport pour ces etudiants
"""
"""Rapport pour ces etudiants"""
L = []
for etudid in etudids:
etud = context.getEtudInfo(filled=1, etudid=etudid)[0]
@ -122,7 +122,7 @@ def table_debouche_etudids(context, etudids, keep_numeric=True):
"_prenom_target": "ficheEtud?etudid=" + etud["etudid"],
"_nom_td_attrs": 'id="%s" class="etudinfo"' % (etud["etudid"]),
# 'debouche' : etud['debouche'],
"moy": fmt_note(nt.get_etud_moy_gen(etudid), keep_numeric=keep_numeric),
"moy": scu.fmt_note(nt.get_etud_moy_gen(etudid), keep_numeric=keep_numeric),
"rang": nt.get_etud_rang(etudid),
"effectif": len(nt.T),
"semestre_id": last_sem["semestre_id"],
@ -189,8 +189,7 @@ def table_debouche_etudids(context, etudids, keep_numeric=True):
def report_debouche_ask_date(context, REQUEST=None):
"""Formulaire demande date départ
"""
"""Formulaire demande date départ"""
return (
context.sco_header(REQUEST)
+ """<form method="GET">
@ -223,14 +222,17 @@ def report_debouche_ask_date(context, REQUEST=None):
# admission_edit(cnx, adm)
_itemsuiviEditor = EditableTable(
_itemsuiviEditor = notesdb.EditableTable(
"itemsuivi",
"itemsuivi_id",
("itemsuivi_id", "etudid", "item_date", "situation"),
sortkey="item_date desc",
convert_null_outputs_to_empty=True,
output_formators={"situation": safehtml.HTML2SafeHTML, "item_date": DateISOtoDMY},
input_formators={"item_date": DateDMYtoISO},
output_formators={
"situation": safehtml.HTML2SafeHTML,
"item_date": notesdb.DateISOtoDMY,
},
input_formators={"item_date": notesdb.DateDMYtoISO},
)
_itemsuivi_create = _itemsuiviEditor.create
@ -240,8 +242,7 @@ _itemsuivi_edit = _itemsuiviEditor.edit
class ItemSuiviTag(sco_tag_module.ScoTag):
"""Les tags sur les items
"""
"""Les tags sur les items"""
tag_table = "itemsuivi_tags" # table (tag_id, title)
assoc_table = "itemsuivi_tags_assoc" # table (tag_id, object_id)
@ -259,8 +260,7 @@ def itemsuivi_get(cnx, itemsuivi_id, ignore_errors=False):
def itemsuivi_suppress(context, itemsuivi_id, REQUEST=None):
"""Suppression d'un item
"""
"""Suppression d'un item"""
if not context.can_edit_suivi(REQUEST):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
cnx = context.GetDBConnexion()
@ -285,7 +285,7 @@ def itemsuivi_create(
log("created itemsuivi %s for %s" % (itemsuivi_id, etudid))
item = itemsuivi_get(cnx, itemsuivi_id)
if format == "json":
return sendJSON(REQUEST, item)
return scu.sendJSON(REQUEST, item)
return item
@ -313,7 +313,7 @@ def itemsuivi_set_situation(context, object, value, REQUEST=None):
item = itemsuivi_get(cnx, itemsuivi_id)
item["situation"] = situation
_itemsuivi_edit(cnx, item)
return situation or IT_SITUATION_MISSING_STR
return situation or scu.IT_SITUATION_MISSING_STR
def itemsuivi_list_etud(context, etudid, format=None, REQUEST=None):
@ -323,13 +323,13 @@ def itemsuivi_list_etud(context, etudid, format=None, REQUEST=None):
for it in items:
it["tags"] = ", ".join(itemsuivi_tag_list(context, it["itemsuivi_id"]))
if format == "json":
return sendJSON(REQUEST, items)
return scu.sendJSON(REQUEST, items)
return items
def itemsuivi_tag_list(context, itemsuivi_id):
"""les noms de tags associés à cet item"""
r = SimpleDictFetch(
r = notesdb.SimpleDictFetch(
context,
"""SELECT t.title
FROM itemsuivi_tags_assoc a, itemsuivi_tags t
@ -344,17 +344,17 @@ def itemsuivi_tag_list(context, itemsuivi_id):
def itemsuivi_tag_search(context, term, REQUEST=None):
"""List all used tag names (for auto-completion)"""
# restrict charset to avoid injections
if not ALPHANUM_EXP.match(term.decode(SCO_ENCODING)):
if not scu.ALPHANUM_EXP.match(term.decode(scu.SCO_ENCODING)):
data = []
else:
r = SimpleDictFetch(
r = notesdb.SimpleDictFetch(
context,
"SELECT title FROM itemsuivi_tags WHERE title LIKE %(term)s",
{"term": term + "%"},
)
data = [x["title"] for x in r]
return sendJSON(REQUEST, data)
return scu.sendJSON(REQUEST, data)
def itemsuivi_tag_set(context, itemsuivi_id="", taglist=[], REQUEST=None):
@ -372,7 +372,7 @@ def itemsuivi_tag_set(context, itemsuivi_id="", taglist=[], REQUEST=None):
# log('itemsuivi_tag_set: itemsuivi_id=%s taglist=%s' % (itemsuivi_id, taglist))
# Sanity check:
cnx = context.GetDBConnexion()
item = itemsuivi_get(cnx, itemsuivi_id)
_ = itemsuivi_get(cnx, itemsuivi_id)
newtags = set(taglist)
oldtags = set(itemsuivi_tag_list(context, itemsuivi_id))

View File

@ -50,13 +50,13 @@ pg_dump SCORT | psql ANORT
import fcntl
import subprocess
import requests
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email.header import Header
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email.Header import Header
from email import Encoders
from notesdb import *
import sco_utils
from sco_utils import *
from notes_log import log
@ -64,7 +64,8 @@ SCO_DUMP_LOCK = "/tmp/scodump.lock"
def sco_dump_and_send_db(context, REQUEST=None):
"""Dump base de données du département courant et l'envoie anonymisée pour debug"""
"""Dump base de données du département courant et l'envoie anonymisée pour debug
"""
H = [context.sco_header(REQUEST, page_title="Assistance technique")]
# get currect (dept) DB name:
cursor = SimpleQuery(context, "SELECT current_database()", {})
@ -149,8 +150,9 @@ def _duplicate_db(db_name, ano_db_name):
def _anonymize_db(ano_db_name):
"""Anonymize a departement database"""
cmd = os.path.join(SCO_TOOLS_DIR, "anonymize_db.py")
"""Anonymize a departement database
"""
cmd = os.path.join(SCO_CONFIG_DIR, "anonymize_db.py")
log("_anonymize_db: {}".format(cmd))
try:
out = subprocess.check_output([cmd, ano_db_name])
@ -169,7 +171,8 @@ def _get_scodoc_serial(context):
def _send_db(context, REQUEST, ano_db_name):
"""Dump this (anonymized) database and send it to tech support"""
"""Dump this (anonymized) database and send it to tech support
"""
log("dumping anonymized database {}".format(ano_db_name))
try:
data = subprocess.check_output("pg_dump {} | gzip".format(ano_db_name), shell=1)
@ -192,7 +195,7 @@ def _send_db(context, REQUEST, ano_db_name):
"nomcomplet"
],
"sco_version": SCOVERSION,
"sco_fullversion": sco_utils.get_scodoc_version(),
"sco_subversion": get_svn_version(SCO_CONFIG_DIR),
},
)
return r

View File

@ -27,15 +27,23 @@
"""Evaluations
"""
import time
import urllib
import operator
import datetime
from notes_log import log, logCallStack
from sco_utils import *
from notesdb import *
import sco_utils as scu
from notesdb import ScoDocCursor
from sco_exceptions import AccessDenied, ScoValueError
import VERSION
from gen_tables import GenTable
from TrivialFormulator import TrivialFormulator
import sco_news
import sco_formsemestre
import sco_groups
import ZAbsences
import sco_evaluations
# --------------------------------------------------------------------
#
@ -47,7 +55,7 @@ def notes_moyenne_median_mini_maxi(notes):
notes = [
x
for x in notes
if (x != None) and (x != NOTES_NEUTRALISE) and (x != NOTES_ATTENTE)
if (x != None) and (x != scu.NOTES_NEUTRALISE) and (x != scu.NOTES_ATTENTE)
]
n = len(notes)
if not n:
@ -136,8 +144,8 @@ def do_evaluation_etat(
NotesDB = context._notes_getall(evaluation_id) # { etudid : value }
notes = [x["value"] for x in NotesDB.values()]
nb_abs = len([x for x in notes if x is None])
nb_neutre = len([x for x in notes if x == NOTES_NEUTRALISE])
nb_att = len([x for x in notes if x == NOTES_ATTENTE])
nb_neutre = len([x for x in notes if x == scu.NOTES_NEUTRALISE])
nb_att = len([x for x in notes if x == scu.NOTES_ATTENTE])
moy_num, median_num, mini_num, maxi_num = notes_moyenne_median_mini_maxi(notes)
if moy_num is None:
median, moy = "", ""
@ -145,10 +153,10 @@ def do_evaluation_etat(
mini, maxi = "", ""
mini_num, maxi_num = None, None
else:
median = fmt_note(median_num)
moy = fmt_note(moy_num)
mini = fmt_note(mini_num)
maxi = fmt_note(maxi_num)
median = scu.fmt_note(median_num)
moy = scu.fmt_note(moy_num)
mini = scu.fmt_note(mini_num)
maxi = scu.fmt_note(maxi_num)
# cherche date derniere modif note
if len(NotesDB):
t = [x["date"] for x in NotesDB.values()]
@ -159,7 +167,7 @@ def do_evaluation_etat(
E = context.do_evaluation_list(args={"evaluation_id": evaluation_id})[0]
M = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
Mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
is_malus = Mod["module_type"] == MODULE_MALUS # True si module de malus
is_malus = Mod["module_type"] == scu.MODULE_MALUS # True si module de malus
formsemestre_id = M["formsemestre_id"]
# Si partition_id is None, prend 'all' ou bien la premiere:
if partition_id is None:
@ -186,8 +194,8 @@ def do_evaluation_etat(
# On considere une note "manquante" lorsqu'elle n'existe pas
# ou qu'elle est en attente (ATT)
GrNbMissing = DictDefault() # group_id : nb notes manquantes
GrNotes = DictDefault(defaultvalue=[]) # group_id: liste notes valides
GrNbMissing = scu.DictDefault() # group_id : nb notes manquantes
GrNotes = scu.DictDefault(defaultvalue=[]) # group_id: liste notes valides
TotalNbMissing = 0
TotalNbAtt = 0
groups = {} # group_id : group
@ -201,14 +209,14 @@ def do_evaluation_etat(
isMissing = False
if NotesDB.has_key(i["etudid"]):
val = NotesDB[i["etudid"]]["value"]
if val == NOTES_ATTENTE:
if val == scu.NOTES_ATTENTE:
isMissing = True
TotalNbAtt += 1
if group:
GrNotes[group["group_id"]].append(val)
else:
if group:
junk = GrNotes[group["group_id"]] # create group
_ = GrNotes[group["group_id"]] # create group
isMissing = True
if isMissing:
TotalNbMissing += 1
@ -219,7 +227,7 @@ def do_evaluation_etat(
gr_incomplets.sort()
if (
(TotalNbMissing > 0)
and (E["evaluation_type"] != EVALUATION_RATTRAPAGE)
and (E["evaluation_type"] != scu.EVALUATION_RATTRAPAGE)
and not is_malus
):
complete = False
@ -244,15 +252,15 @@ def do_evaluation_etat(
"group_id": group_id,
"group_name": groups[group_id]["group_name"],
"gr_moy_num": gr_moy,
"gr_moy": fmt_note(gr_moy),
"gr_moy": scu.fmt_note(gr_moy),
"gr_median_num": gr_median,
"gr_median": fmt_note(gr_median),
"gr_mini": fmt_note(gr_mini),
"gr_maxi": fmt_note(gr_maxi),
"gr_mini": gr_mini,
"gr_maxi": gr_maxi,
"gr_median": scu.fmt_note(gr_median),
"gr_mini": scu.fmt_note(gr_mini),
"gr_maxi": scu.fmt_note(gr_maxi),
"gr_mini_num": gr_mini,
"gr_maxi_num": gr_maxi,
"gr_nb_notes": len(notes),
"gr_nb_att": len([x for x in notes if x == NOTES_ATTENTE]),
"gr_nb_att": len([x for x in notes if x == scu.NOTES_ATTENTE]),
}
)
gr_moyennes.sort(key=operator.itemgetter("group_name"))
@ -337,7 +345,7 @@ def do_evaluation_list_in_sem(context, formsemestre_id):
'visibulletin': 1} ]
"""
req = "select E.* from notes_evaluation E, notes_moduleimpl MI where MI.formsemestre_id = %(formsemestre_id)s and MI.moduleimpl_id = E.moduleimpl_id"
req = "select E.* from notes_evaluation E, notes_moduleimpl MI where MI.formsemestre_id = %(formsemestre_id)s and MI.moduleimpl_id = E.moduleimpl_id order by moduleimpl_id, numero desc, jour desc, heure_debut desc"
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor.execute(req, {"formsemestre_id": formsemestre_id})
@ -380,7 +388,7 @@ def _eval_etat(evals):
nb_evals_en_cours += 1
dates.append(e["etat"]["last_modif"])
dates = sort_dates(dates)
dates = scu.sort_dates(dates)
if len(dates):
last_modif = dates[-1] # date de derniere modif d'une note dans un module
@ -511,18 +519,18 @@ def evaluation_date_first_completion(context, evaluation_id):
if not etat["evalcomplete"]:
return None
E = context.do_evaluation_list(args={"evaluation_id": evaluation_id})[0]
M = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
formsemestre_id = M["formsemestre_id"]
# XXX inachevé ou à revoir ?
# Il faut considerer les inscriptions au semestre
# (pour avoir l'etat et le groupe) et aussi les inscriptions
# au module (pour gerer les modules optionnels correctement)
insem = context.do_formsemestre_inscription_listinscrits(formsemestre_id)
insmod = context.do_moduleimpl_inscription_list(moduleimpl_id=E["moduleimpl_id"])
insmodset = set([x["etudid"] for x in insmod])
# E = context.do_evaluation_list(args={"evaluation_id": evaluation_id})[0]
# M = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
# formsemestre_id = M["formsemestre_id"]
# insem = context.do_formsemestre_inscription_listinscrits(formsemestre_id)
# insmod = context.do_moduleimpl_inscription_list(moduleimpl_id=E["moduleimpl_id"])
# insmodset = set([x["etudid"] for x in insmod])
# retire de insem ceux qui ne sont pas inscrits au module
ins = [i for i in insem if i["etudid"] in insmodset]
# ins = [i for i in insem if i["etudid"] in insmodset]
notes = context._notes_getall(evaluation_id, filter_suppressed=False).values()
notes_log = context._notes_getall(
@ -560,8 +568,8 @@ def formsemestre_evaluations_delai_correction(
for e in evals:
M = context.do_moduleimpl_list(moduleimpl_id=e["moduleimpl_id"])[0]
Mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
if (e["evaluation_type"] != EVALUATION_NORMALE) or (
Mod["module_type"] == MODULE_MALUS
if (e["evaluation_type"] != scu.EVALUATION_NORMALE) or (
Mod["module_type"] == scu.MODULE_MALUS
):
continue
e["date_first_complete"] = evaluation_date_first_completion(
@ -612,8 +620,8 @@ def formsemestre_evaluations_delai_correction(
caption="Correction des évaluations du semestre",
preferences=context.get_preferences(formsemestre_id),
base_url="%s?formsemestre_id=%s" % (REQUEST.URL0, formsemestre_id),
origin="Généré par %s le " % VERSION.SCONAME + timedate_human_repr() + "",
filename=make_filename("evaluations_delais_" + sem["titreannee"]),
origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "",
filename=scu.make_filename("evaluations_delais_" + sem["titreannee"]),
)
return tab.make_page(context, format=format, REQUEST=REQUEST)
@ -727,7 +735,6 @@ def evaluation_describe(context, evaluation_id="", edit_in_place=True, REQUEST=N
M = context.do_moduleimpl_list(moduleimpl_id=moduleimpl_id)[0]
Mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
formsemestre_id = M["formsemestre_id"]
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
u = context.Users.user_info(M["responsable_id"])
resp = u["prenomnom"]
nomcomplet = u["nomcomplet"]
@ -747,13 +754,13 @@ def evaluation_describe(context, evaluation_id="", edit_in_place=True, REQUEST=N
etit = E["description"] or ""
if etit:
etit = ' "' + etit + '"'
if Mod["module_type"] == MODULE_MALUS:
if Mod["module_type"] == scu.MODULE_MALUS:
etit += ' <span class="eval_malus">(points de malus)</span>'
H = [
'<span class="eval_title">Evaluation%s</span><p><b>Module : %s</b></p>'
% (etit, mod_descr)
]
if Mod["module_type"] == MODULE_MALUS:
if Mod["module_type"] == scu.MODULE_MALUS:
# Indique l'UE
ue = context.do_ue_list(args={"ue_id": Mod["ue_id"]})[0]
H.append("<p><b>UE : %(acronyme)s</b></p>" % ue)
@ -804,9 +811,9 @@ def evaluation_create_form(
moduleimpl_id = the_eval["moduleimpl_id"]
#
M = context.do_moduleimpl_withmodule_list(moduleimpl_id=moduleimpl_id)[0]
is_malus = M["module"]["module_type"] == MODULE_MALUS # True si module de malus
is_malus = M["module"]["module_type"] == scu.MODULE_MALUS # True si module de malus
formsemestre_id = M["formsemestre_id"]
min_note_max = NOTES_PRECISION # le plus petit bareme possible
min_note_max = scu.NOTES_PRECISION # le plus petit bareme possible
if not readonly:
try:
context._evaluation_check_write_access(REQUEST, moduleimpl_id=moduleimpl_id)
@ -853,17 +860,16 @@ def evaluation_create_form(
# Note maximale actuelle dans cette eval ?
etat = do_evaluation_etat(context, evaluation_id)
if etat["maxi_num"] is not None:
min_note_max = max(NOTES_PRECISION, etat["maxi_num"])
min_note_max = max(scu.NOTES_PRECISION, etat["maxi_num"])
else:
min_note_max = NOTES_PRECISION
min_note_max = scu.NOTES_PRECISION
#
if min_note_max > NOTES_PRECISION:
min_note_max_str = fmt_note(min_note_max)
if min_note_max > scu.NOTES_PRECISION:
min_note_max_str = scu.fmt_note(min_note_max)
else:
min_note_max_str = "0"
#
Mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
#
help = """<div class="help"><p class="help">
Le coefficient d'une évaluation n'est utilisé que pour pondérer les évaluations au sein d'un module.
@ -973,7 +979,7 @@ def evaluation_create_form(
"title": "Notes de 0 à",
"explanation": "barème (note max actuelle: %s)" % min_note_max_str,
"allow_null": False,
"max_value": NOTES_MAX,
"max_value": scu.NOTES_MAX,
"min_value": min_note_max,
},
),
@ -1008,7 +1014,7 @@ def evaluation_create_form(
{
"input_type": "menu",
"title": "Modalité",
"allowed_values": (EVALUATION_NORMALE, EVALUATION_RATTRAPAGE),
"allowed_values": (scu.EVALUATION_NORMALE, scu.EVALUATION_RATTRAPAGE),
"type": "int",
"labels": ("Normale", "Rattrapage"),
},

View File

@ -644,6 +644,12 @@ def formsemestre_description_table(
ModInscrits = context.do_moduleimpl_inscription_list(
moduleimpl_id=M["moduleimpl_id"]
)
enseignants = ", ".join(
[
context.Users.user_info(m["ens_id"], REQUEST)["nomprenom"]
for m in M["ens"]
]
)
l = {
"UE": M["ue"]["acronyme"],
"Code": M["module"]["code"],
@ -652,6 +658,8 @@ def formsemestre_description_table(
"Inscrits": len(ModInscrits),
"Responsable": context.Users.user_info(M["responsable_id"])["nomprenom"],
"_Responsable_class": "scotext",
"Enseignants": enseignants,
"_Enseignants_class": "scotext",
"Coef.": M["module"]["coefficient"],
# 'ECTS' : M['module']['ects'],
# Lien sur titre -> module
@ -689,7 +697,7 @@ def formsemestre_description_table(
columns_ids = ["UE", "Code", "Module", "Coef."]
if context.get_preference("bul_show_ects", formsemestre_id):
columns_ids += ["ects"]
columns_ids += ["Inscrits", "Responsable"]
columns_ids += ["Inscrits", "Responsable", "Enseignants"]
if with_evals:
columns_ids += [
"jour",
@ -899,6 +907,12 @@ def formsemestre_status(context, formsemestre_id=None, REQUEST=None):
<th class="resp">Responsable</th>
<th class="evals">Evaluations</th></tr>"""
)
mails_enseignants = set(
[
context.Users.user_info(ens_id, REQUEST)["email"]
for ens_id in sem["responsables"]
]
) # adr. mail des enseignants
for M in Mlist:
Mod = M["module"]
ModDescr = (
@ -915,6 +929,12 @@ def formsemestre_status(context, formsemestre_id=None, REQUEST=None):
ModInscrits = context.do_moduleimpl_inscription_list(
moduleimpl_id=M["moduleimpl_id"]
)
mails_enseignants.add(
context.Users.user_info(M["responsable_id"], REQUEST)["email"]
)
mails_enseignants |= set(
[context.Users.user_info(m["ens_id"], REQUEST)["email"] for m in M["ens"]]
)
ue = M["ue"]
if prev_ue_id != ue["ue_id"]:
prev_ue_id = ue["ue_id"]
@ -1039,5 +1059,11 @@ def formsemestre_status(context, formsemestre_id=None, REQUEST=None):
)
# --- LISTE DES ETUDIANTS
H += ['<div id="groupes">', context.make_listes_sem(sem, REQUEST), "</div>"]
# --- Lien mail enseignants:
adrlist = list(mails_enseignants - set([""]))
if adrlist:
H.append(
'<p><a class="stdlink" href="mailto:?cc=%s">Courrier aux %d enseignants du semestre</a></p>'
% (",".join(adrlist), len(adrlist))
)
return "".join(H) + context.sco_footer(REQUEST)

View File

@ -431,10 +431,10 @@ def groups_table(
format: csv, json, xml, xls, allxls, xlsappel, moodlecsv, pdf
Si with_codes, ajoute 4 colonnes avec les codes etudid, NIP, INE et etape
"""
log(
"enter groups_table %s: %s"
% (groups_infos.members[0]["nom"], groups_infos.members[0].get("etape", "-"))
)
# log(
# "enter groups_table %s: %s"
# % (groups_infos.members[0]["nom"], groups_infos.members[0].get("etape", "-"))
# )
authuser = REQUEST.AUTHENTICATED_USER
with_codes = int(with_codes)
@ -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

View File

@ -39,7 +39,8 @@ TITLES = ("user_name", "nom", "prenom", "email", "roles", "dept")
def generate_excel_sample():
"""generates an excel document suitable to import users"""
"""generates an excel document suitable to import users
"""
style = sco_excel.Excel_MakeStyle(bold=True)
titles = TITLES
titlesStyles = [style] * len(titles)
@ -163,11 +164,11 @@ def generate_password():
return "".join(RNG.sample(l, PASSLEN))
import email
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email.header import Header
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email.Header import Header
from email import Encoders
def mail_password(u, context=None, reset=False):

View File

@ -262,7 +262,11 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
H.append(
"""Afficher les groupes de&nbsp;<select name="partition_id" onchange="document.f.submit();">"""
)
been_selected = False
for partition in partitions:
if not partition_id and not been_selected:
selected = "selected"
been_selected = True
if partition["partition_id"] == partition_id:
selected = "selected"
else:
@ -337,12 +341,11 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
% etat["last_modif"].strftime("%d/%m/%Y à %Hh%M")
)
H.append('<span class="evalindex_cont">')
if has_expression:
if has_expression or True:
H.append(
"""<span class="evalindex" title="Indice dans les vecteurs (formules)">%02d</span>"""
"""<span class="evalindex" title="Indice dans les vecteurs (formules)">%2d</span>"""
% eval_index
)
# Fleches:
H.append('<span class="eval_arrows_chld">')
if eval_index != (len(ModEvals) - 1) and caneditevals:

View File

@ -33,9 +33,11 @@ from cStringIO import StringIO
import datetime, re
import time
from stripogram import html2text, html2safehtml
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.Header import Header
from email import Encoders
from notesdb import *
from notes_log import log
@ -250,7 +252,8 @@ def scolar_news_summary_rss(context, title, sco_url, n=5):
def _send_news_by_mail(context, n):
"""Notify by email"""
"""Notify by email
"""
infos = _get_formsemestre_infos_from_news(context, n)
formsemestre_id = infos.get("formsemestre_id", None)
prefs = context.get_preferences(formsemestre_id=formsemestre_id)

View File

@ -53,7 +53,7 @@ from PIL import Image as PILImage
from cStringIO import StringIO
import glob
from sco_utils import CONFIG, SCO_SRC_DIR
from sco_utils import CONFIG, SCO_SRCDIR
from notes_log import log
import scolars
@ -62,7 +62,7 @@ from scolog import logdb
# Full paths on server's filesystem. Something like "/opt/scodoc/var/scodoc/photos"
PHOTO_DIR = os.path.join(os.environ["INSTANCE_HOME"], "var", "scodoc", "photos")
ICONS_DIR = os.path.join(SCO_SRC_DIR, "static", "icons")
ICONS_DIR = os.path.join(SCO_SRCDIR, "static", "icons")
UNKNOWN_IMAGE_PATH = os.path.join(ICONS_DIR, "unknown.jpg")
UNKNOWN_IMAGE_URL = "get_photo_image?etudid=" # with empty etudid => unknown face image
IMAGE_EXT = ".jpg"

View File

@ -37,9 +37,9 @@ import datetime
import sco_utils
from sco_utils import ScoEtudInscrit, log, ScoValueError, DictDefault
from sco_utils import SCO_TMP_DIR, SCO_ENCODING
from sco_utils import SCO_TMPDIR, SCO_ENCODING
SCO_CACHE_ETAPE_FILENAME = os.path.join(SCO_TMP_DIR, "last_etapes.xml")
SCO_CACHE_ETAPE_FILENAME = os.path.join(SCO_TMPDIR, "last_etapes.xml")
def has_portal(context):

View File

@ -49,7 +49,7 @@ Chaque parametre est défini dans la base de données SQL par:
Au niveau du code interface, on défini pour chaque préférence:
- name (clé)
- title : titre en français
- initvalue : valeur initiale
- initvalue : valeur initiale, chargée depuis config/scodoc_config.py
- explanation: explication en français
- size: longueur du chap texte
- input_type: textarea,separator,... type de widget TrivialFormulator a utiliser
@ -90,6 +90,13 @@ sinon, elle ne concerne que le semestre indiqué.
- editer les preferences d'un semestre:
sem_preferences(context,formsemestre_id).edit()
* Valeurs par défaut:
On a deux valeurs par défaut possibles:
- via le fichier scodoc_config.py, qui peut être modifié localement.
- si rien dans scodoc_config.py, la valeur définie par
sco_preferences.py est utilisée (ne pas modifier ce fichier).
* Implémentation: sco_preferences.py
PREF_CATEGORIES : définition des catégories de préférences (pour

View File

@ -764,12 +764,17 @@ def _list_notes_evals(context, evals, etudid):
"""
L = []
for e in evals:
if e["etat"]["evalcomplete"]:
if (
e["etat"]["evalcomplete"]
or e["etat"]["evalattente"]
or e["publish_incomplete"]
):
NotesDB = context._notes_getall(e["evaluation_id"])
if NotesDB.has_key(etudid):
val = NotesDB[etudid]["value"]
else:
val = None
# Note manquante mais prise en compte immédiate: affiche ATT
val = NOTES_ATTENTE
val_fmt = fmt_note(val, keep_numeric=True)
L.append(val_fmt)
return L
@ -778,9 +783,15 @@ def _list_notes_evals(context, evals, etudid):
def _list_notes_evals_titles(context, codemodule, evals):
"""Liste des titres des evals completes"""
L = []
eval_index = len(evals) - 1
for e in evals:
if e["etat"]["evalcomplete"]:
L.append(codemodule + "-" + DateISOtoDMY(e["jour"]))
if (
e["etat"]["evalcomplete"]
or e["etat"]["evalattente"]
or e["publish_incomplete"]
):
L.append(codemodule + "-" + str(eval_index) + "-" + e["jour"].isoformat())
eval_index -= 1
return L
@ -788,7 +799,11 @@ def _list_notes_evals_stats(context, evals, key):
"""Liste des stats (moy, ou rien!) des evals completes"""
L = []
for e in evals:
if e["etat"]["evalcomplete"]:
if (
e["etat"]["evalcomplete"]
or e["etat"]["evalattente"]
or e["publish_incomplete"]
):
if key == "moy":
val = e["etat"]["moy_num"]
L.append(fmt_note(val, keep_numeric=True))

View File

@ -28,6 +28,8 @@
"""Synchronisation des listes d'étudiants avec liste portail (Apogée)
"""
import time
import pprint
from sco_utils import ScoEtudInscrit, annee_scolaire_debut, log, ScoValueError
from notesdb import ScoDocCursor
@ -42,8 +44,6 @@ import sco_formsemestre_inscriptions
import sco_formsemestre_status
from sco_news import NEWS_INSCR, NEWS_NOTE, NEWS_FORM, NEWS_SEM, NEWS_MISC
import time
# Clés utilisées pour la synchro
EKEY_APO = "nip"
EKEY_SCO = "code_nip"
@ -695,7 +695,7 @@ def do_import_etud_admission(
"codelycee": get_opt_str(etud, "lycee"),
"boursier": get_opt_str(etud, "bourse"),
}
log("do_import_etud_admission: etud=%s" % etud)
log("do_import_etud_admission: etud=%s" % pprint.pformat(etud))
al = scolars.admission_list(cnx, args={"etudid": etudid})
if not al:
scolars.admission_create(cnx, args) # -> adm_id

View File

@ -29,7 +29,7 @@
""" Verification version logiciel vs version "stable" sur serveur
N'effectue pas la mise à jour automatiquement, mais permet un affichage d'avertissement.
"""
import sco_utils
from sco_utils import *
# Appel renvoyant la subversion "stable"
@ -66,66 +66,65 @@ def is_up_to_date(context):
"""True if up_to_date
Returns status, message
"""
log("Warning: is_up_to_date not implemented for ScoDoc8")
return True, "unimplemented"
# global _LAST_UP_TO_DATE_REQUEST, _UP_TO_DATE, _UP_TO_DATE_MSG
# if _LAST_UP_TO_DATE_REQUEST and (
# datetime.datetime.now() - _LAST_UP_TO_DATE_REQUEST
# ) < datetime.timedelta(1):
# # requete deja effectuee aujourd'hui:
# return _UP_TO_DATE, _UP_TO_DATE_MSG
global _LAST_UP_TO_DATE_REQUEST, _UP_TO_DATE, _UP_TO_DATE_MSG
if _LAST_UP_TO_DATE_REQUEST and (
datetime.datetime.now() - _LAST_UP_TO_DATE_REQUEST
) < datetime.timedelta(1):
# requete deja effectuee aujourd'hui:
return _UP_TO_DATE, _UP_TO_DATE_MSG
# last_stable_ver = get_last_stable_version()
# cur_ver = sco_utils.get_scodoc_version()
# cur_ver2 = cur_ver
# cur_ver_num = -1
# # Convert versions to integers:
# try:
# # cur_ver can be "1234" or "1234M' or '1234:1245M'...
# fs = cur_ver.split(":", 1)
# if len(fs) > 1:
# cur_ver2 = fs[-1]
# m = re.match(r"([0-9]*)", cur_ver2)
# if not m:
# raise ValueError(
# "invalid svn version"
# ) # should never occur, regexp always (maybe empty) match
# cur_ver_num = int(m.group(1))
# except:
# log('Warning: no numeric subversion ! (cur_ver="%s")' % cur_ver)
# return _UP_TO_DATE, _UP_TO_DATE_MSG # silently ignore misconfiguration ?
# try:
# last_stable_ver_num = int(last_stable_ver)
# except:
# log("Warning: last_stable_version returned by server is invalid !")
# return (
# _UP_TO_DATE,
# _UP_TO_DATE_MSG,
# ) # should ignore this error (maybe server is unreachable)
# #
# if cur_ver_num < last_stable_ver_num:
# _UP_TO_DATE = False
# _UP_TO_DATE_MSG = "Version %s disponible (version %s installée)" % (
# last_stable_ver,
# cur_ver_num,
# )
# log(
# "Warning: ScoDoc installation is not up-to-date, should upgrade\n%s"
# % _UP_TO_DATE_MSG
# )
# else:
# _UP_TO_DATE = True
# _UP_TO_DATE_MSG = ""
# log(
# "ScoDoc is up-to-date (cur_ver: %s, using %s=%s)"
# % (cur_ver, cur_ver2, cur_ver_num)
# )
last_stable_ver = get_last_stable_version()
cur_ver = get_svn_version(context.file_path) # in sco_utils
cur_ver2 = cur_ver
cur_ver_num = -1
# Convert versions to integers:
try:
# cur_ver can be "1234" or "1234M' or '1234:1245M'...
fs = cur_ver.split(":", 1)
if len(fs) > 1:
cur_ver2 = fs[-1]
m = re.match(r"([0-9]*)", cur_ver2)
if not m:
raise ValueError(
"invalid svn version"
) # should never occur, regexp always (maybe empty) match
cur_ver_num = int(m.group(1))
except:
log('Warning: no numeric subversion ! (cur_ver="%s")' % cur_ver)
return _UP_TO_DATE, _UP_TO_DATE_MSG # silently ignore misconfiguration ?
try:
last_stable_ver_num = int(last_stable_ver)
except:
log("Warning: last_stable_version returned by server is invalid !")
return (
_UP_TO_DATE,
_UP_TO_DATE_MSG,
) # should ignore this error (maybe server is unreachable)
#
if cur_ver_num < last_stable_ver_num:
_UP_TO_DATE = False
_UP_TO_DATE_MSG = "Version %s disponible (version %s installée)" % (
last_stable_ver,
cur_ver_num,
)
log(
"Warning: ScoDoc installation is not up-to-date, should upgrade\n%s"
% _UP_TO_DATE_MSG
)
else:
_UP_TO_DATE = True
_UP_TO_DATE_MSG = ""
log(
"ScoDoc is up-to-date (cur_ver: %s, using %s=%s)"
% (cur_ver, cur_ver2, cur_ver_num)
)
# return _UP_TO_DATE, _UP_TO_DATE_MSG
return _UP_TO_DATE, _UP_TO_DATE_MSG
def html_up_to_date_box(context):
""""""
"""
"""
status, msg = is_up_to_date(context)
if status:
return ""

View File

@ -186,84 +186,53 @@ def get_mention(moy):
return NOTES_MENTIONS_LABS[bisect.bisect_right(NOTES_MENTIONS_TH, moy)]
class DictDefault(dict): # obsolete, use collections.defaultdict
"""A dictionnary with default value for all keys
Each time a non existent key is requested, it is added to the dict.
(used in python 2.4, can't use new __missing__ method)
"""
defaultvalue = 0
def __init__(self, defaultvalue=0, kv_dict={}):
dict.__init__(self)
self.defaultvalue = defaultvalue
self.update(kv_dict)
def __getitem__(self, k):
if self.has_key(k):
return self.get(k)
value = copy.copy(self.defaultvalue)
self[k] = value
return value
class WrapDict:
"""Wrap a dict so that getitem returns '' when values are None"""
def __init__(self, adict, NoneValue=""):
self.dict = adict
self.NoneValue = NoneValue
def __getitem__(self, key):
value = self.dict[key]
if value is None:
return self.NoneValue
else:
return value
def group_by_key(d, key):
g = DictDefault(defaultvalue=[])
for e in d:
g[e[key]].append(e)
return g
# ----- Global lock for critical sections (except notes_tables caches)
GSL = thread.allocate_lock() # Global ScoDoc Lock
if "INSTANCE_HOME" in os.environ:
# ----- Repertoire "var" (local)
SCODOC_VAR_DIR = os.path.join(os.environ["INSTANCE_HOME"], "var", "scodoc")
# ----- Repertoire "config" modifiable
# /opt/scodoc/var/scodoc/config
SCODOC_CFG_DIR = os.path.join(SCODOC_VAR_DIR, "config")
# ----- Version information
SCODOC_VERSION_DIR = os.path.join(SCODOC_CFG_DIR, "version")
SCODOC_VERSION_DIR = os.path.join(SCODOC_VAR_DIR, "config", "version")
# ----- Repertoire tmp
SCO_TMP_DIR = os.path.join(SCODOC_VAR_DIR, "tmp")
if not os.path.exists(SCO_TMP_DIR):
os.mkdir(SCO_TMP_DIR, 0o755)
SCO_TMPDIR = os.path.join(SCODOC_VAR_DIR, "tmp")
if not os.path.exists(SCO_TMPDIR):
os.mkdir(SCO_TMPDIR, 0o755)
# ----- Les logos: /opt/scodoc/var/scodoc/config/logos
SCODOC_LOGOS_DIR = os.path.join(SCODOC_CFG_DIR, "logos")
SCODOC_LOGOS_DIR = os.path.join(SCODOC_VAR_DIR, "config", "logos")
# Dans les sources:
SCO_SRC_DIR = os.path.join(os.environ["INSTANCE_HOME"], "Products", "ScoDoc")
# - Les outils distribués
SCO_TOOLS_DIR = os.path.join(SCO_SRC_DIR, "config")
# ----- Repertoire "config" (devrait s'appeler "tools"...)
SCO_CONFIG_DIR = os.path.join(
os.environ["INSTANCE_HOME"], "Products", "ScoDoc", "config"
)
# ----- Lecture du fichier de configuration
import sco_config
import sco_config_load
SCO_SRCDIR = os.path.split(VERSION.__file__)[0]
if SCO_SRCDIR:
SCO_SRCDIR += "/"
else:
SCO_SRCDIR = "/opt/scodoc/Products/ScoDoc/" # debug mode
CONFIG = None
try:
_config_filename = SCO_SRCDIR + "config/scodoc_config.py"
_config_text = open(_config_filename).read()
except:
sys.stderr.write("sco_utils: cannot open configuration file %s" % _config_filename)
raise
try:
exec(_config_text)
except:
sys.stderr.write("sco_utils: error in configuration file %s" % _config_filename)
raise
sco_config_load.load_local_configuration()
CONFIG = sco_config.CONFIG
if hasattr(CONFIG, "CODES_EXPL"):
CODES_EXPL.update(
CONFIG.CODES_EXPL
) # permet de customiser les explications de codes
if CONFIG.CUSTOM_HTML_HEADER:
CUSTOM_HTML_HEADER = open(CONFIG.CUSTOM_HTML_HEADER).read()
else:
@ -328,6 +297,50 @@ JSON_MIMETYPE = "application/json"
LOGOS_IMAGES_ALLOWED_TYPES = ("jpg", "png") # remind that PIL does not read pdf
class DictDefault(dict): # obsolete, use collections.defaultdict
"""A dictionnary with default value for all keys
Each time a non existent key is requested, it is added to the dict.
(used in python 2.4, can't use new __missing__ method)
"""
defaultvalue = 0
def __init__(self, defaultvalue=0, kv_dict={}):
dict.__init__(self)
self.defaultvalue = defaultvalue
self.update(kv_dict)
def __getitem__(self, k):
if self.has_key(k):
return self.get(k)
value = copy.copy(self.defaultvalue)
self[k] = value
return value
class WrapDict:
"""Wrap a dict so that getitem returns '' when values are None"""
def __init__(self, adict, NoneValue=""):
self.dict = adict
self.NoneValue = NoneValue
def __getitem__(self, key):
value = self.dict[key]
if value is None:
return self.NoneValue
else:
return value
def group_by_key(d, key):
g = DictDefault(defaultvalue=[])
for e in d:
g[e[key]].append(e)
return g
# Admissions des étudiants
# Différents types de voies d'admission:
# (stocké en texte libre dans la base, mais saisie par menus pour harmoniser)
@ -597,9 +610,15 @@ def sendResult(REQUEST, data, name=None, format=None, force_outer_xml_tag=True):
raise ValueError("invalid format: %s" % format)
def get_scodoc_version():
"return a string identifying ScoDoc version"
return os.popen("cd %s; ./get_scodoc_version.sh -s" % SCO_TOOLS_DIR).read().strip()
# Get SVN version
def get_svn_version(path):
if os.path.exists("/usr/bin/svnversion"):
try:
return os.popen("svnversion " + path).read().strip()
except:
return "non disponible (erreur de lecture)"
else:
return "non disponible"
# Simple string manipulations
@ -772,7 +791,7 @@ def icontag(name, file_format="png", **attrs):
"""
if ("width" not in attrs) or ("height" not in attrs):
if name not in ICONSIZES:
img_file = SCO_SRC_DIR + "/static/icons/%s.%s" % (name, file_format)
img_file = SCO_SRCDIR + "/static/icons/%s.%s" % (name, file_format)
im = PILImage.open(img_file)
width, height = im.size[0], im.size[1]
ICONSIZES[name] = (width, height) # cache

View File

@ -28,8 +28,6 @@
"""Imports et configuration des composants Zope
"""
# Allows code linting on platforms without Zope:
# pylint: disable=import-error
from OFS.SimpleItem import Item # Basic zope object
from OFS.PropertyManager import PropertyManager # provide the 'Properties' tab with the

View File

@ -25,7 +25,7 @@
#
##############################################################################
""" Acces donnees etudiants
""" Accès donnees etudiants
"""
from sco_utils import *
@ -35,17 +35,18 @@ from TrivialFormulator import TrivialFormulator
import safehtml
from scolog import logdb
from notes_table import *
import sco_news
# XXXXXXXXX HACK: zope 2.7.7 bug turaround ?
import locale
locale.setlocale(locale.LC_ALL, ("en_US", SCO_ENCODING))
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
from email.mime.base import MIMEBase
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email.Header import Header
from email import Encoders
abbrvmonthsnames = [
"Jan ",
@ -617,6 +618,59 @@ def make_etud_args(etudid=None, code_nip=None, REQUEST=None, raise_exc=True):
return args
def create_etud(context, cnx, args={}, REQUEST=None):
"""Creation d'un étudiant. génère aussi évenement et "news".
Args:
args: dict avec les attributs de l'étudiant
Returns:
etud, l'étudiant créé.
"""
# creation d'un etudiant
etudid = etudident_create(cnx, args, context=context, REQUEST=REQUEST)
# crée une adresse vide (chaque etudiant doit etre dans la table "adresse" !)
_ = adresse_create(
cnx,
{
"etudid": etudid,
"typeadresse": "domicile",
"description": "(creation individuelle)",
},
)
# event
scolar_events_create(
cnx,
args={
"etudid": etudid,
"event_date": time.strftime("%d/%m/%Y"),
"formsemestre_id": None,
"event_type": "CREATION",
},
)
# log
logdb(
REQUEST,
cnx,
method="etudident_edit_form",
etudid=etudid,
msg="creation initiale",
)
etud = scolars.etudident_list(cnx, {"etudid": etudid})[0]
context.fillEtudsInfo([etud])
etud["url"] = "ficheEtud?etudid=%(etudid)s" % etud
sco_news.add(
context,
REQUEST,
typ=sco_news.NEWS_INSCR,
object=None, # pas d'object pour ne montrer qu'un etudiant
text='Nouvel étudiant <a href="%(url)s">%(nomprenom)s</a>' % etud,
url=etud["url"],
)
return etud
# ---------- "EVENTS"
_scolar_eventsEditor = EditableTable(
"scolar_events",
@ -712,7 +766,7 @@ appreciations_edit = _appreciationsEditor.edit
# -------- Noms des Lycées à partir du code
def read_etablissements():
filename = SCO_SRC_DIR + "/" + CONFIG.ETABL_FILENAME
filename = SCO_SRCDIR + "/" + CONFIG.ETABL_FILENAME
log("reading %s" % filename)
f = open(filename)
L = [x[:-1].split(";") for x in f]

1
scotests/__init__.py Normal file
View File

@ -0,0 +1 @@
#

View File

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

View File

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Some files were not shown because too many files have changed in this diff Show More