2018-11-08 19:45:21 +00:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
|
from peeringdb_server.models import Sponsorship
|
|
|
|
|
import datetime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
|
help = "Looks for expired sponsorships and sends a notification to sponsorship admin for recently expired sponsorships"
|
|
|
|
|
|
|
|
|
|
def log(self, msg):
|
|
|
|
|
print(msg)
|
|
|
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
|
|
|
|
|
|
now = datetime.datetime.now()
|
|
|
|
|
for sponsorship in Sponsorship.objects.filter(end_date__lt=now):
|
2019-12-05 16:57:52 +00:00
|
|
|
if (
|
|
|
|
|
sponsorship.notify_date is None
|
|
|
|
|
or sponsorship.notify_date < sponsorship.end_date
|
|
|
|
|
):
|
2018-11-08 19:45:21 +00:00
|
|
|
b = sponsorship.notify_expiration()
|
2019-12-05 16:57:52 +00:00
|
|
|
# if b:
|
2018-11-08 19:45:21 +00:00
|
|
|
# self.log("Sent expiration notices for %s, expired on %s" % (sponsorship.org.name, sponsorship.end_date))
|