def resend_confirmation(_modeladmin, _request: HttpRequest, queryset: QuerySet) -> None: """ Resends the confirmation email to the selected applications. """ for application in queryset: send_confirmation_email(application)
def test_send_confirmation_email_customizes_body(self): send_confirmation_email(self.app) email: EmailMultiAlternatives = mail.outbox[0] self.assertIn(self.app.first_name, email.body) self.assertIn(settings.EVENT_NAME, email.body)
def post(self, request: HttpRequest, *args, **kwargs): pk = self.kwargs["pk"] app: Application = Application.objects.get(pk=pk) if app.status == STATUS_CONFIRMED: # Do nothing, they already confirmed. return redirect(reverse_lazy("status")) if app.user != request.user: raise PermissionDenied( "You don't have permission to view this application.") if app.status != STATUS_ADMITTED: raise PermissionDenied( "You can't confirm your application if it hasn't been approved." ) app.status = STATUS_CONFIRMED app.save() send_confirmation_email(app) return redirect(reverse_lazy("status"))
def test_send_confirmation_email_attaches_file(self): send_confirmation_email(self.app) email: EmailMultiAlternatives = mail.outbox[0] self.assertEqual(len(email.attachments), 1)
def test_send_confirmation_email_sends_email(self): send_confirmation_email(self.app) self.assertEqual(len(mail.outbox), 1)