Commit 953f3e88 authored by Nicolas Joyard's avatar Nicolas Joyard

Ajout commande listing ML

parent d2b26af2
......@@ -15,7 +15,8 @@ from .irfm import app
from .models import db
from .tools.files import generer_demandes as generer_demandes_
from .tools.mails import envoyer_emails as envoyer_emails_
from .tools.mails import (envoyer_emails as envoyer_emails_,
mailing_lists as mailing_lists_)
from .tools.procedure import fix_procedure as fix_procedure_
from .tools.text import hash_password
......@@ -58,6 +59,14 @@ def envoyer_emails(envoyer=False):
print('Aucun parlementaire sans adresse mail :)')
@manager.command
def mailing_lists():
"""Affiche les abonnés aux mailing lists"""
app.config.update(SQLALCHEMY_ECHO=False)
for nom, emails in mailing_lists_().items():
print('%s :\n\t%s' % (nom, '\n\t'.join(emails)))
@manager.command
def fix_procedure():
"""Génère les étapes manquantes pour tous les parlementaires"""
......
......@@ -7,12 +7,25 @@ from flask import render_template
from flask_mail import Mail, Message
from ..models import Parlementaire, db
from ..models import User, Parlementaire, db
from ..models.constants import ETAPE_NA
from ..tools.files import generer_demande
def mailing_lists():
filters = {
'Liste Membres': User.abo_membres == True, # noqa
'Liste IRFM': User.abo_irfm == True, # noqa
'Newsletter': User.abo_rc == True, # noqa
}
return {
k: [u.email for u in User.query.filter(f).all()]
for k, f in filters.items()
}
def envoyer_alerte(app, etape, parl, commentaire):
mail = Mail(app)
......
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