fin_connexion: mail calendrier mois courant
This commit is contained in:
parent
9faaf0d6b6
commit
342a3b5ffd
7 changed files with 48 additions and 8 deletions
|
@ -128,7 +128,7 @@ def prev_calendar(c, date):
|
||||||
first = datetime.datetime(day=1, month=month, year=year, tzinfo=pytz.UTC)
|
first = datetime.datetime(day=1, month=month, year=year, tzinfo=pytz.UTC)
|
||||||
last = first.replace(month=1+month%12, year=year+int(month==12))
|
last = first.replace(month=1+month%12, year=year+int(month==12))
|
||||||
|
|
||||||
disconnect = brief(c, first, last)
|
disconnect = select(c, first, last)
|
||||||
by_day = {x: 0 for x in xrange(1,32)}
|
by_day = {x: 0 for x in xrange(1,32)}
|
||||||
for adh in disconnect:
|
for adh in disconnect:
|
||||||
date = compute_fin_connexion(adh)
|
date = compute_fin_connexion(adh)
|
||||||
|
@ -150,6 +150,7 @@ def prev_calendar(c, date):
|
||||||
|
|
||||||
|
|
||||||
def ascii_calendar(calendar):
|
def ascii_calendar(calendar):
|
||||||
|
"""Affiche le calendrier en ascii"""
|
||||||
spaces = 3
|
spaces = 3
|
||||||
def pretty_day(x):
|
def pretty_day(x):
|
||||||
if x is None:
|
if x is None:
|
||||||
|
@ -169,6 +170,18 @@ def batch_warn(liste):
|
||||||
for adh in liste:
|
for adh in liste:
|
||||||
warn(mail_conn, adh)
|
warn(mail_conn, adh)
|
||||||
|
|
||||||
|
def prev_mail(calendar):
|
||||||
|
"""Envoi d'un mail récapitulatif pour ``calendar``"""
|
||||||
|
data = {
|
||||||
|
'calendar': list(calendar),
|
||||||
|
}
|
||||||
|
From = 'respbats@crans.org'
|
||||||
|
To = From
|
||||||
|
data.update({'To': To, 'From': From})
|
||||||
|
mailtxt = mail_module.generate('fin_connexion_stats', data)
|
||||||
|
with mail_module.ServerConnection() as mail_conn:
|
||||||
|
mail_conn.sendmail(From, [To], mailtxt.as_string())
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
db = lc_ldap_readonly()
|
db = lc_ldap_readonly()
|
||||||
|
|
||||||
|
@ -178,7 +191,7 @@ if __name__ == '__main__':
|
||||||
for arg in args:
|
for arg in args:
|
||||||
# Applique un delta, si spécifié
|
# Applique un delta, si spécifié
|
||||||
if arg.startswith('+'):
|
if arg.startswith('+'):
|
||||||
now += int(arg[1:])*DAY
|
today += int(arg[1:])*DAY
|
||||||
print "Nous serons le %s" % today
|
print "Nous serons le %s" % today
|
||||||
|
|
||||||
if '--preventif' in args:
|
if '--preventif' in args:
|
||||||
|
@ -198,11 +211,7 @@ if __name__ == '__main__':
|
||||||
batch_warn(liste)
|
batch_warn(liste)
|
||||||
if '--prev' in args:
|
if '--prev' in args:
|
||||||
ascii_calendar(prev_calendar(db, today))
|
ascii_calendar(prev_calendar(db, today))
|
||||||
|
if '--prev-mail' in args:
|
||||||
# TODO
|
prev_mail(prev_calendar(db, today))
|
||||||
# * Mensuel: avertit les cableurs des connexions à expiration dans le mois
|
|
||||||
# prochain
|
|
||||||
# select(c, first_day, last_day+DAY)
|
|
||||||
# prev(c, today+28*DAY)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
1
gestion/mail/template/fin_connexion_stats/From/fr
Normal file
1
gestion/mail/template/fin_connexion_stats/From/fr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Script d'avertissement <cableurs@crans.org>
|
1
gestion/mail/template/fin_connexion_stats/README
Normal file
1
gestion/mail/template/fin_connexion_stats/README
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Mail envoyé au début du mois pour résumer les effectifs nécessaires
|
1
gestion/mail/template/fin_connexion_stats/Subject/fr
Normal file
1
gestion/mail/template/fin_connexion_stats/Subject/fr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Prévision des prochaines fins de connexion
|
1
gestion/mail/template/fin_connexion_stats/To/fr
Normal file
1
gestion/mail/template/fin_connexion_stats/To/fr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{{To}}
|
1
gestion/mail/template/fin_connexion_stats/X-Mailer/fr
Normal file
1
gestion/mail/template/fin_connexion_stats/X-Mailer/fr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{{ mailer }}
|
26
gestion/mail/template/fin_connexion_stats/body/fr.md
Normal file
26
gestion/mail/template/fin_connexion_stats/body/fr.md
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
Calendrier des déconnexions ce mois-ci:
|
||||||
|
|
||||||
|
<table>
|
||||||
|
{%- for line in calendar %}
|
||||||
|
<tr style="height: 3em;">
|
||||||
|
{%- for item in line %}
|
||||||
|
{%- if item == none %}
|
||||||
|
<td style="background-color: grey;">
|
||||||
|
{%- elif item is not number %}
|
||||||
|
<td style="background-color: #DDD; width: 3em;">
|
||||||
|
{{ item }}
|
||||||
|
{%- elif item == 0 %}
|
||||||
|
<td>
|
||||||
|
{%- else %}
|
||||||
|
<td style="background-color: yellow;">
|
||||||
|
{{ item }}
|
||||||
|
{%- endif %}
|
||||||
|
</td>
|
||||||
|
{%- endfor %}
|
||||||
|
</tr>
|
||||||
|
{%- endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
--
|
||||||
|
|
||||||
|
Les membres actifs de l'association
|
Loading…
Add table
Add a link
Reference in a new issue