2013-11-25 08:51:48 -05:00
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from django.core.mail import send_mail
|
|
|
|
from gameday.models import RegisteredUser
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
|
|
|
|
def handle(self, *args, **kwargs):
|
|
|
|
subject = 'Students who RSVP\'ed to the game on %s:' %\
|
|
|
|
datetime.today().date()
|
|
|
|
from_ = 'rsvp@uncc-gameday.no-ip.org'
|
|
|
|
recipient_list = ['bspeice.nc@gmail.com']
|
|
|
|
|
|
|
|
message = 'The following people have registered as attending the game:\n\n'
|
|
|
|
|
|
|
|
for user in RegisteredUser.objects.filter(date_registered__gt=
|
|
|
|
(datetime.today() - timedelta(7))):
|
2013-12-08 19:50:40 -05:00
|
|
|
message += user.first_name + ' ' + user.last_name + ' - ' + \
|
|
|
|
user.date_registered.strftime('%I:%M %p %m/%d/%Y') + '\n'
|
2013-11-25 08:51:48 -05:00
|
|
|
|
|
|
|
send_mail(subject, message, from_,recipient_list)
|