Liste aussi les contrôles.
This commit is contained in:
parent
4ee1ea55d1
commit
fe9f69d19a
1 changed files with 40 additions and 21 deletions
|
@ -53,13 +53,23 @@ def adherents(regen=False):
|
|||
adherents.data = DB.search(u'(&(debutAdhesion>=%s)(aid=*))' % (crans_utils.to_generalized_time_format(config.debut_periode_transitoire)), sizelimit=2000)
|
||||
return list(adherents.data)
|
||||
|
||||
@static_var(("data", []))
|
||||
def factures(regen=False):
|
||||
"""Fonction évaluée paresseusement pour retourner la liste des câbleurs"""
|
||||
|
||||
if regen or not factures.data:
|
||||
factures.data = DB.search(u'(&(|(debutAdhesion>=%(now)s)(debutConnexion>=%(now)s))(fid=*))' % {
|
||||
'now': crans_utils.to_generalized_time_format(config.debut_periode_transitoire),
|
||||
}, sizelimit=4000)
|
||||
return list(factures.data)
|
||||
|
||||
@static_var(("data", []))
|
||||
def cableurs(regen=False):
|
||||
"""Fonction évaluée paresseusement pour retourner la liste des
|
||||
câbleurs"""
|
||||
|
||||
if regen or not cableurs.data:
|
||||
cableurs.data = DB.search(u'(|(droits=cableur)(droits=nounou))')
|
||||
cableurs.data = DB.search(u'(|(droits=cableur)(droits=nounou)(droits=bureau))')
|
||||
return list(cableurs.data)
|
||||
|
||||
#### On prends les historiques de tout les adhérents
|
||||
|
@ -76,12 +86,21 @@ def actions_cableurs():
|
|||
"""Renvoie l'historique de tous les adherents et tri en fonction
|
||||
des actions éffectuées."""
|
||||
for adherent in adherents():
|
||||
histo = adherent.get('historique', None)
|
||||
for j in range (0, len(histo)):
|
||||
champ = parse_historique(histo[j])[0]
|
||||
champ_action = parse_historique(histo[j])[1]
|
||||
date = parse_historique(histo[j])[2]
|
||||
if ((u' inscription' in champ_action or u'Adhesion+' in champ_action) and date > datetime.date(ann_scol, 8, 1)):
|
||||
histo = adherent.get('historique', [])
|
||||
for histo_line in histo:
|
||||
champ = parse_historique(histo_line)[0]
|
||||
champ_action = parse_historique(histo_line)[1]
|
||||
date = parse_historique(histo_line)[2]
|
||||
if (u' inscription' in champ_action or u'Adhesion+' in champ_action) and date > datetime.date(ann_scol, 8, 1):
|
||||
HISTORIQUE.append(champ)
|
||||
|
||||
for facture in factures():
|
||||
histo = facture.get('historique', [])
|
||||
for histo_line in histo:
|
||||
champ = parse_historique(histo_line)[0]
|
||||
champ_action = parse_historique(histo_line)[1]
|
||||
date = parse_historique(histo_line)[2]
|
||||
if u'controle' in champ_action and date > datetime.date(ann_scol, 8, 1):
|
||||
HISTORIQUE.append(champ)
|
||||
return HISTORIQUE
|
||||
|
||||
|
@ -90,19 +109,21 @@ def score_cableurs():
|
|||
"""Calcul le score de tout les câbleurs en fonction des actions
|
||||
effectuées """
|
||||
for cableur in cableurs():
|
||||
inscriptions = reinscriptions = 0
|
||||
inscriptions = reinscriptions = controles = 0
|
||||
nom = cableur.get(u'nom', None)[0].value
|
||||
prenom = cableur.get(u'prenom', None)[0].value
|
||||
uid = cableur.get(u'uid', None)[0].value
|
||||
for index in range (0, len(HISTORIQUE)):
|
||||
histo_uid = HISTORIQUE[index][2]
|
||||
histo_action = HISTORIQUE[index][3]
|
||||
if histo_uid == uid and histo_action == u' inscription':
|
||||
inscriptions = inscriptions + 1
|
||||
if histo_uid == uid and histo_action == u' inscription':
|
||||
inscriptions += 1
|
||||
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])
|
||||
reinscriptions += 1
|
||||
if histo_uid == uid and (u"controle" in histo_action):
|
||||
controles += 1
|
||||
score = 2*inscriptions + reinscriptions + controles
|
||||
SCORES.append(["%s %s" % (prenom, nom), score, inscriptions, reinscriptions, controles])
|
||||
return SCORES
|
||||
|
||||
### Tri par score
|
||||
|
@ -126,16 +147,14 @@ def cableurs_utiles():
|
|||
#### Affichage ou x est le nombre de câbleurs à afficher
|
||||
def show_all(limit, swap):
|
||||
"""Tableau fait main pour un effet plus visuel"""
|
||||
titre = [u"Câbleur", u"Score", u"Inscriptions", u"Réinscriptions"]
|
||||
largeur = [25, 8, 16, 16]
|
||||
alignement = ["c", "c", "c", "c"]
|
||||
titre = [u"Câbleur", u"Score", u"Inscriptions", u"Réinscriptions", u"Contrôles"]
|
||||
largeur = [25, 8, 16, 16, 16]
|
||||
alignement = ["c", "c", "c", "c", "c"]
|
||||
data = [[elem for elem in SCORES[index]] for index in xrange(limit)]
|
||||
total = ['Total',0,0,0]
|
||||
total = [0]*4
|
||||
for elem in SCORES:
|
||||
total[1]+=elem[1]
|
||||
total[2]+=elem[2]
|
||||
total[3]+=elem[3]
|
||||
total = [total]
|
||||
total = [total[i] + elem[i+1] for i in xrange(len(total))]
|
||||
total = [["Total"] + total]
|
||||
print affichage.tableau(data, titre=titre, largeur=largeur, alignement=alignement, swap=swap).encode(ENCODING)
|
||||
print affichage.tableau(total, titre=titre, largeur=largeur, alignement=alignement, swap=swap).encode(ENCODING)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue