+ return self.payed_at is not None and (self.expires_at is None or self.expires_at > now())
+
+ def is_recurring(self):
+ return self.monthly or self.yearly
+
+ def get_next_installment(self, date):
+ if self.yearly:
+ return utils.add_year(date)
+ if self.monthly:
+ return utils.add_month(date)
+ club = Club.objects.first()
+ if club is not None and self.amount >= club.min_for_year:
+ return utils.add_year(date)
+ return utils.add_month(date)
+
+ def send_email(self):
+ ctx = {'schedule': self}
+ send_mail(
+ template.loader.render_to_string('club/email/thanks_subject.txt', ctx).strip(),
+ template.loader.render_to_string('club/email/thanks.txt', ctx),
+ settings.CONTACT_EMAIL, [self.email], fail_silently=False)
+ self.email_sent = True
+ self.save()
+
+ def update_contact(self):
+ Contact = apps.get_model('messaging', 'Contact')
+ if not self.payed_at:
+ level = Contact.TRIED
+ since = self.started_at
+ else:
+ since = self.payed_at
+ if self.is_recurring():
+ level = Contact.RECURRING
+ else:
+ level = Contact.SINGLE
+ Contact.update(self.email, level, since, self.expires_at)