Extract clubs mailing list

This commit is contained in:
Yohann D'ANELLO 2020-04-22 20:02:30 +02:00
parent 135cca18cc
commit 05fa27ac57
1 changed files with 7 additions and 2 deletions

View File

@ -6,7 +6,7 @@ from datetime import date
from django.core.management import BaseCommand
from django.db.models import Q
from member.models import Membership
from member.models import Membership, Club
from ...models import WEIClub
@ -16,7 +16,7 @@ class Command(BaseCommand):
"You can write this into a file with a pipe, then paste the document into your mail manager."
def add_arguments(self, parser):
parser.add_argument('--type', '-t', choices=["members", "events", "art", "sport"], default="members",
parser.add_argument('--type', '-t', choices=["members", "clubs", "events", "art", "sport"], default="members",
help='Select the type of the mailing list (default members)')
parser.add_argument('--year', '-y', type=int, default=None,
help='Select the year of the concerned WEI. Default: last year')
@ -31,6 +31,11 @@ class Command(BaseCommand):
self.stdout.write(membership.user.email)
return
if options["type"] == "clubs":
for club in Club.objects.all():
self.stdout.write(club.email)
return
if options["year"] is None:
wei = WEIClub.objects.order_by('-year').first()
else: