forked from ScoDoc/ScoDoc
removed old mxDateTime
This commit is contained in:
parent
66be2a41c9
commit
6d17f030e2
17
ZAbsences.py
17
ZAbsences.py
@ -44,17 +44,16 @@ L'API de plus bas niveau est en gros:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import urllib
|
|
||||||
import datetime
|
|
||||||
import jaxml
|
|
||||||
import cgi
|
|
||||||
import string
|
import string
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
import datetime
|
||||||
|
import dateutil
|
||||||
|
import dateutil.parser
|
||||||
import calendar
|
import calendar
|
||||||
|
import urllib
|
||||||
from mx.DateTime import DateTime as mxDateTime
|
import cgi
|
||||||
from mx.DateTime.ISO import ParseDateTimeUTC
|
import jaxml
|
||||||
|
|
||||||
# ---------------
|
# ---------------
|
||||||
from sco_zope import *
|
from sco_zope import *
|
||||||
@ -1542,8 +1541,8 @@ ou entrez une date pour visualiser les absents un jour donné :
|
|||||||
return scu.log_unknown_etud(self, REQUEST=REQUEST)
|
return scu.log_unknown_etud(self, REQUEST=REQUEST)
|
||||||
etud = etuds[0]
|
etud = etuds[0]
|
||||||
# check dates
|
# check dates
|
||||||
begin_date = ParseDateTimeUTC(begin) # may raises ValueError
|
begin_date = dateutil.parser.isoparse(begin) # may raises ValueError
|
||||||
end_date = ParseDateTimeUTC(end)
|
end_date = dateutil.parser.isoparse(end)
|
||||||
if begin_date > end_date:
|
if begin_date > end_date:
|
||||||
raise ValueError("invalid dates")
|
raise ValueError("invalid dates")
|
||||||
#
|
#
|
||||||
|
@ -96,8 +96,6 @@ apt-get -y install python-cracklib # was python-crack
|
|||||||
apt-get -y install python-icalendar
|
apt-get -y install python-icalendar
|
||||||
apt-get -y install python-requests
|
apt-get -y install python-requests
|
||||||
|
|
||||||
apt-get -y install python-egenix-mxtools python-egenix-mxdatetime
|
|
||||||
|
|
||||||
|
|
||||||
# ------------
|
# ------------
|
||||||
SVNVERSION=$(cd ..; svnversion)
|
SVNVERSION=$(cd ..; svnversion)
|
||||||
|
@ -226,10 +226,8 @@ def user_nbdays_since_last_notif(context, email_addr, etudid):
|
|||||||
)
|
)
|
||||||
res = cursor.dictfetchone()
|
res = cursor.dictfetchone()
|
||||||
if res:
|
if res:
|
||||||
mxd = res["notification_date"] # mx.DateTime instance
|
now = datetime.datetime.now(res["notification_date"].tzinfo)
|
||||||
lastdate = datetime.datetime(mxd.year, mxd.month, mxd.day)
|
return (now - res["notification_date"]).days
|
||||||
now = datetime.datetime.now()
|
|
||||||
return (now - lastdate).days
|
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -47,8 +47,7 @@
|
|||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
from mx.DateTime import DateTime as mxDateTime
|
import datetime
|
||||||
import mx.DateTime
|
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import glob
|
import glob
|
||||||
@ -140,7 +139,7 @@ class BaseArchiver:
|
|||||||
def get_archive_date(self, archive_id):
|
def get_archive_date(self, archive_id):
|
||||||
"""Returns date (as a DateTime object) of an archive"""
|
"""Returns date (as a DateTime object) of an archive"""
|
||||||
dt = [int(x) for x in os.path.split(archive_id)[1].split("-")]
|
dt = [int(x) for x in os.path.split(archive_id)[1].split("-")]
|
||||||
return mxDateTime(*dt)
|
return datetime.datetime(*dt)
|
||||||
|
|
||||||
def list_archive(self, archive_id):
|
def list_archive(self, archive_id):
|
||||||
"""Return list of filenames (without path) in archive"""
|
"""Return list of filenames (without path) in archive"""
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Rewritten from ancient DTML code
|
# Rewritten from ancient DTML code
|
||||||
from mx.DateTime import DateTime as mxDateTime
|
|
||||||
|
|
||||||
from notes_log import log
|
from notes_log import log
|
||||||
import sco_utils as scu
|
import sco_utils as scu
|
||||||
|
@ -601,13 +601,13 @@ def _add_eval_columns(
|
|||||||
|
|
||||||
coefs[evaluation_id] = "coef. %s" % e["coefficient"]
|
coefs[evaluation_id] = "coef. %s" % e["coefficient"]
|
||||||
if note_sur_20:
|
if note_sur_20:
|
||||||
nmx = 20.0
|
nmax = 20.0
|
||||||
else:
|
else:
|
||||||
nmx = e["note_max"]
|
nmax = e["note_max"]
|
||||||
if keep_numeric:
|
if keep_numeric:
|
||||||
note_max[evaluation_id] = nmx
|
note_max[evaluation_id] = nmax
|
||||||
else:
|
else:
|
||||||
note_max[evaluation_id] = "/ %s" % nmx
|
note_max[evaluation_id] = "/ %s" % nmax
|
||||||
|
|
||||||
if nb_notes > 0:
|
if nb_notes > 0:
|
||||||
moys[evaluation_id] = "%.3g" % (sum_notes / nb_notes)
|
moys[evaluation_id] = "%.3g" % (sum_notes / nb_notes)
|
||||||
|
@ -34,9 +34,7 @@ import tempfile
|
|||||||
import urllib
|
import urllib
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import mx
|
import datetime
|
||||||
import mx.DateTime
|
|
||||||
from mx.DateTime import DateTime as mxDateTime
|
|
||||||
|
|
||||||
import sco_utils as scu
|
import sco_utils as scu
|
||||||
import VERSION
|
import VERSION
|
||||||
@ -435,8 +433,8 @@ def table_suivi_cohorte(
|
|||||||
# tri les semestres par date de debut
|
# tri les semestres par date de debut
|
||||||
for s in sems:
|
for s in sems:
|
||||||
d, m, y = [int(x) for x in s["date_debut"].split("/")]
|
d, m, y = [int(x) for x in s["date_debut"].split("/")]
|
||||||
s["date_debut_mx"] = mxDateTime(y, m, d) # pylint: disable=not-callable
|
s["date_debut_dt"] = datetime.datetime(y, m, d)
|
||||||
sems.sort(lambda x, y: cmp(x["date_debut_mx"], y["date_debut_mx"]))
|
sems.sort(lambda x, y: cmp(x["date_debut_dt"], y["date_debut_dt"]))
|
||||||
|
|
||||||
# 2-- Pour chaque semestre, trouve l'ensemble des etudiants venant de sem
|
# 2-- Pour chaque semestre, trouve l'ensemble des etudiants venant de sem
|
||||||
logt("B: etuds sets")
|
logt("B: etuds sets")
|
||||||
@ -467,21 +465,21 @@ def table_suivi_cohorte(
|
|||||||
# semestre de depart:
|
# semestre de depart:
|
||||||
porigin = periodsem()
|
porigin = periodsem()
|
||||||
d, m, y = [int(x) for x in sem["date_debut"].split("/")]
|
d, m, y = [int(x) for x in sem["date_debut"].split("/")]
|
||||||
porigin.datedebut = mxDateTime(y, m, d) # pylint: disable=not-callable
|
porigin.datedebut = datetime.datetime(y, m, d)
|
||||||
porigin.sems = [sem]
|
porigin.sems = [sem]
|
||||||
|
|
||||||
#
|
#
|
||||||
tolerance = mx.DateTime.DateTimeDelta(45) # 45 days
|
tolerance = datetime.timedelta(days=45)
|
||||||
for s in sems:
|
for s in sems:
|
||||||
merged = False
|
merged = False
|
||||||
for p in P:
|
for p in P:
|
||||||
if abs(s["date_debut_mx"] - p.datedebut) < tolerance:
|
if abs(s["date_debut_dt"] - p.datedebut) < tolerance:
|
||||||
p.sems.append(s)
|
p.sems.append(s)
|
||||||
merged = True
|
merged = True
|
||||||
break
|
break
|
||||||
if not merged:
|
if not merged:
|
||||||
p = periodsem()
|
p = periodsem()
|
||||||
p.datedebut = s["date_debut_mx"]
|
p.datedebut = s["date_debut_dt"]
|
||||||
p.sems = [s]
|
p.sems = [s]
|
||||||
P.append(p)
|
P.append(p)
|
||||||
|
|
||||||
|
@ -543,15 +543,15 @@ class ScoDocJSONEncoder(json.JSONEncoder):
|
|||||||
def default(self, o): # pylint: disable=E0202
|
def default(self, o): # pylint: disable=E0202
|
||||||
import sco_formsemestre
|
import sco_formsemestre
|
||||||
|
|
||||||
# horrible hack pour encoder les dates mx
|
# ScoDoc 7.22 n'utilise plus mx:
|
||||||
if str(type(o)) == "<type 'mx.DateTime.DateTime'>":
|
if str(type(o)) == "<type 'mx.DateTime.DateTime'>":
|
||||||
|
log("Warning: mx.DateTime object detected !")
|
||||||
return o.strftime("%Y-%m-%dT%H:%M:%S")
|
return o.strftime("%Y-%m-%dT%H:%M:%S")
|
||||||
if isinstance(o, (datetime.date, datetime.datetime)):
|
if isinstance(o, (datetime.date, datetime.datetime)):
|
||||||
return o.isoformat()
|
return o.isoformat()
|
||||||
elif isinstance(o, sco_formsemestre.ApoEtapeVDI):
|
elif isinstance(o, sco_formsemestre.ApoEtapeVDI):
|
||||||
return str(o)
|
return str(o)
|
||||||
else:
|
else:
|
||||||
log("not mx: %s" % type(o))
|
|
||||||
return json.JSONEncoder.default(self, o)
|
return json.JSONEncoder.default(self, o)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user