1 # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
4 from django.core.management.base import BaseCommand
7 class Command(BaseCommand):
8 help = 'Sends relevant funding notifications.'
10 def add_arguments(self, parser):
12 '-q', '--quiet', action='store_false', dest='verbose',
13 default=True, help='Suppress output')
15 def handle(self, **options):
17 from datetime import date, timedelta
18 from funding.models import Offer
19 from funding import app_settings
20 from django.core.cache import caches
21 from django.conf import settings
23 verbose = options['verbose']
25 for offer in Offer.past().filter(notified_end=None):
27 print('Notify end:', offer)
28 # The 'WL fund' list needs to be updated.
29 caches[settings.CACHE_MIDDLEWARE_ALIAS].clear()
33 current = Offer.current()
34 if (current is not None and
35 current.end <= date.today() + timedelta(app_settings.DAYS_NEAR - 1) and
36 not current.notified_near):
38 print('Notify near:', current)