Skip to content

Commit 0edfb9e

Browse files
authored
Import ImproperlyConfigured (#93)
1 parent bfe54eb commit 0edfb9e

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

tests/campaign_backends/test_mailchimp_backend.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,15 @@ def test_log_and_raise(caplog: pytest.LogCaptureFixture):
410410

411411
def test_inject_campaign_settings():
412412
class InjectBackend(MockMailchimpCampaignBackend):
413-
def get_campaign_request_body(self, *, recipients, subject, from_name, reply_to):
413+
def get_campaign_request_body(
414+
self, *, recipients, subject, from_name, reply_to
415+
):
414416
return dict(
415417
super().get_campaign_request_body(
416-
recipients=recipients, subject=subject, from_name=from_name, reply_to=reply_to
418+
recipients=recipients,
419+
subject=subject,
420+
from_name=from_name,
421+
reply_to=reply_to,
417422
),
418423
test_key="test_value",
419424
)

wagtail_newsletter/campaign_backends/mailchimp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,16 @@ def get_campaign_request_body(
203203
}
204204

205205
if recipients is not None:
206-
body["recipients"] = {
206+
recipients_mapping: dict[str, Any] = {
207207
"list_id": recipients.audience,
208208
}
209209

210210
if recipients.segment:
211211
segment_id = int(recipients.segment.split("/")[1])
212-
body["recipients"]["segment_opts"] = {
212+
recipients_mapping["segment_opts"] = {
213213
"saved_segment_id": segment_id,
214214
}
215+
body["recipients"] = recipients_mapping
215216

216217
return body
217218

@@ -225,7 +226,6 @@ def save_campaign(
225226
from_name: str,
226227
html: str,
227228
) -> str:
228-
229229
body = self.get_campaign_request_body(
230230
recipients=recipients,
231231
subject=subject,

wagtail_newsletter/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from typing import Any, Optional
22

3-
from django.core.exceptions import ValidationError
4-
from django.db import models
53
from django.conf import settings
4+
from django.core.exceptions import ImproperlyConfigured, ValidationError
5+
from django.db import models
66
from django.http import HttpResponse
77
from django.template.loader import render_to_string
88
from django.utils.safestring import SafeString

0 commit comments

Comments
 (0)