Commit e81d8ba4 authored by Raphael-david Lasseri's avatar Raphael-david Lasseri

[stats_cableurs2.py] Derniere modif

parent befff024
......@@ -31,7 +31,7 @@ from lc_ldap import shortcuts
import lc_ldap.crans_utils as crans_utils
import gestion.config as config
import gestion.affichage as affichage
from config import ann_scol
### Appels à LDAP et tri initial sur l'année en cours
db = shortcuts.lc_ldap_readonly()
adherents = db.search(u'(&(debutAdhesion>=%s)(aid=*))' % (crans_utils.toGeneralizedTimeFormat(config.debut_periode_transitoire)), sizelimit=2000)
......@@ -44,10 +44,10 @@ encoding = sys.stdout.encoding or "UTF-8"
def parse_historique(ligne):
"""Parse une ligne d'historique et renvoie [ligne parsée],action
du cableur, date de l'action"""
champ = ligne.value.replace(',','').replace(':','').split(' ')
champ = ligne.value.replace(',','').replace(':','').split(' ',3)
sdate = champ[0].split('/')
date = datetime.date(int(sdate[2]),int(sdate[1]),int(sdate[0]))
champ_action=champ[4]
champ_action=champ[3]
return champ,champ_action,date
def actions_cableurs():
......@@ -59,7 +59,7 @@ def actions_cableurs():
champ=parse_historique(histo[j])[0]
champ_action=parse_historique(histo[j])[1]
date=parse_historique(histo[j])[2]
if ((champ_action == u'inscription' or u"debutAdhesion+" in champ_action) or len(champ) > 5 and (u"debutAdhesion+" in champ[5] or champ[5] == u'inscription')) and date > datetime.date(config.ann_scol, 8, 16) :
if ((u' inscription' in champ_action or u'Adhesion+' in champ_action) and date > datetime.date(ann_scol,8,1)):
historique.append(champ)
return historique
......@@ -74,10 +74,10 @@ def score_cableurs():
uid = cableur.get(u'uid',None)[0].value
for l in range (0,len(historique)):
histo_uid = historique[l][2]
histo_action = historique[l][4]
if histo_uid == uid and histo_action == u'inscription':
histo_action = historique[l][3]
if histo_uid == uid and histo_action == u' inscription':
inscriptions = inscriptions+1
if histo_uid == uid and (u"debutAdhesion+" in histo_action or (len(historique[l])>5 and (u'debutAdhesion+' in historique[l][5]))):
if histo_uid == uid and (u"debutAdhesion+" in histo_action):
reinscriptions = reinscriptions+1
score = 2*inscriptions + reinscriptions
scores.append(["%s %s" % (prenom, nom), score, inscriptions, reinscriptions])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment