Beispiel #1
0
 def handle(self, *args, **options):
     print[f.datetime for f in flags]
     print EMAIL_REASONS['payment_overdue']
     now = datetime.datetime.now()
     day = datetime.timedelta(1)
     first_warning = 1
     second_warning = 7
     final_warning = 2
     #email anyone whos flag is ten or more days old
     flags = Flag.objects.filter(emailed__isnull=True)
     overdue_flags = flags.filter(
         reason__in=EMAIL_REASONS['payment_overdue'],
         datetime__lte=now - 1 * day)
     email_tuples = [('first_warning', first_warning),
                     ('second_warning', second_warning),
                     ('final_warning', final_warning + second_warning)]
     email_dict = dict(email_tuples)
     for template, num_days in email_tuples:
         for flag in overdue_flags:
             context = {
                 'flag': flag,
             }
             context.update(email_dict)
             send_membership_email('email/flag/%' % template,
                                   flag.subscription.user.email,
                                   context=context)
             flag.emailed = now
             flag.save()
     if overdue_flags:
         mail_admins("Overdue emails sent",
                     "for flags %s" % ([f.pk for f in overdue_flags]))
Beispiel #2
0
 def send_welcome_email(self):
     from membership.utils import send_membership_email
     send_membership_email('email/new_member',
                           self.email,
                           context={'user': self})
     self.create_fake_safety()
     self.save()
Beispiel #3
0
 def apply_status(self,new_status,mail=True):
   if self.status == new_status:
     return
   from membership.utils import send_membership_email
   context = {
     'flag': self,
     'last_warning_date': datetime.timedelta(21)+self.datetime,
   }
   try:
     if mail:
       send_membership_email('email/flags/%s'%new_status,self.subscription.user.email,context=context)
   except TemplateDoesNotExist:
     print "template not found %s"%new_status
   self.status = new_status
   self.emailed = datetime.datetime.now()
   self.save()
Beispiel #4
0
 def apply_status(self,new_status,mail=True):
   if self.status == new_status:
     return
   from membership.utils import send_membership_email
   context = {
     'flag': self,
     'last_warning_date': datetime.timedelta(21)+self.datetime,
   }
   try:
     if mail:
       send_membership_email('email/flags/%s'%new_status,self.subscription.user.email,context=context)
   except TemplateDoesNotExist:
     print "template not found %s"%new_status
   self.status = new_status
   self.emailed = datetime.datetime.now()
   self.save()
Beispiel #5
0
class Command(BaseCommand):
  @print_to_mail
  def handle(self, *args, **options):
    print [f.datetime for f in flags]
    print EMAIL_REASONS['payment_overdue']
    now = datetime.datetime.now()
    day = datetime.timedelta(1)
    first_warning = 1
    second_warning = 7
    final_warning = 2
    #email anyone whos flag is ten or more days old
    flags = Flag.objects.filter(emailed__isnull=True)
    overdue_flags = flags.filter(reason__in=EMAIL_REASONS['payment_overdue'],datetime__lte=now-1*day)
    email_tuples = [
      ('first_warning', first_warning),
      ('second_warning', second_warning),
      ('final_warning', final_warning+second_warning)
    ]
    email_dict = dict(email_tuples)
    for template,num_days in email_tuples:
      for flag in overdue_flags:
        context = {
          'flag': flag,
        }
        context.update(email_dict)
        send_membership_email('email/flag/%'%template,flag.subscription.user.email,context=context)
        flag.emailed = now
        flag.save()
    if overdue_flags:
      mail_admins("Overdue emails sent","for flags %s"%([f.pk for f in overdue_flags]))
Beispiel #6
0
 def send_welcome_email(self):
   from membership.utils import send_membership_email
   send_membership_email('email/new_member',self.email,context={'user': self})
   self.create_fake_safety()
   self.save()