-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ def payment_reminder(): | |
|
||
if deadline_diff <= 0: | ||
if not_paid(payment): | ||
send_deadline_passed_mail(payment) | ||
send_deadline_passed_mail_payment(payment) | ||
notify_committee(payment) | ||
set_marks(payment) | ||
suspend(payment) | ||
|
@@ -119,7 +119,7 @@ def notify_committee(payment): | |
|
||
receivers = [payment.responsible_mail()] | ||
|
||
EmailMessage(subject, content, "[email protected]", [], receivers).send() | ||
EmailMessage(subject, content, "[email protected]", receivers).send() | ||
|
||
|
||
def not_paid(payment): | ||
|
@@ -223,7 +223,27 @@ def handle_suspensions(payment_delay): | |
suspension.save() | ||
|
||
|
||
def send_deadline_passed_mail(payment_delay, unattend_deadline_passed=True): | ||
def send_deadline_passed_mail_payment(payment: Payment): | ||
subject = _("Betalingsfrist utgått: ") + payment.description() | ||
|
||
content = render_to_string( | ||
"payment/email/reminder_deadline_passed.txt", | ||
{ | ||
"payment_description": payment.description(), | ||
"payment_url": settings.BASE_URL | ||
+ payment.content_object.event.get_absolute_url(), | ||
"payment_email": payment.responsible_mail(), | ||
}, | ||
) | ||
|
||
receivers = not_paid_mail_addresses(payment) | ||
|
||
EmailMessage(subject, content, payment.responsible_mail(), [], receivers).send() | ||
|
||
|
||
def send_deadline_passed_mail( | ||
payment_delay: PaymentDelay, unattend_deadline_passed=True | ||
): | ||
payment = payment_delay.payment | ||
|
||
subject = _("Betalingsfrist utgått: ") + payment.description() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from django.core import mail | ||
from django.test import TestCase | ||
from django.utils import timezone | ||
from django_dynamic_fixture import F, G | ||
|
||
from apps.authentication.models import OnlineGroup | ||
from apps.events.tests.utils import attend_user_to_event, generate_event, generate_user | ||
from apps.payment.models import PaymentTypes | ||
from apps.payment.mommy import payment_reminder | ||
from apps.payment.tests.utils import generate_event_payment | ||
|
||
|
||
class PaymentReminderTests(TestCase): | ||
def setup_testcase(self): | ||
self.committee = G( | ||
OnlineGroup, group=F(name="Arrkom"), email="[email protected]" | ||
) | ||
self.user = generate_user(username="test_user", email="[email protected]") | ||
|
||
self.event = generate_event(organizer=self.committee.group) | ||
self.event.event_end = timezone.now() - timezone.timedelta(days=3) | ||
self.event.event_start = timezone.now() - timezone.timedelta(days=2) | ||
self.event.attendance_event.registration_end = ( | ||
timezone.now() - timezone.timedelta(days=1) | ||
) | ||
self.event.attendance_event.unattend_deadline = ( | ||
timezone.now() - timezone.timedelta(days=1) | ||
) | ||
self.event.save() | ||
self.event.attendance_event.save() | ||
|
||
self.payment = generate_event_payment( | ||
self.event, | ||
deadline=timezone.now() - timezone.timedelta(days=1), | ||
payment_type=PaymentTypes.DEADLINE, | ||
) | ||
self.attendee = attend_user_to_event(self.event, self.user) | ||
|
||
def test_no_attend_no_mail(self): | ||
payment_reminder() | ||
self.assertEqual(len(mail.outbox), 0) | ||
|
||
def test_attend_mail(self): | ||
self.setup_testcase() | ||
payment_reminder() | ||
self.assertEqual(len(mail.outbox), 2) | ||
user_mail, committee_mail = mail.outbox | ||
self.assertEqual(user_mail.bcc, [self.user.email]) | ||
self.assertEqual(committee_mail.to, [self.committee.email]) |