Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions tests/campaign_backends/test_mailchimp_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,15 @@ def test_log_and_raise(caplog: pytest.LogCaptureFixture):

def test_inject_campaign_settings():
class InjectBackend(MockMailchimpCampaignBackend):
def get_campaign_request_body(self, *, recipients, subject, from_name, reply_to):
def get_campaign_request_body(
self, *, recipients, subject, from_name, reply_to
):
return dict(
super().get_campaign_request_body(
recipients=recipients, subject=subject, from_name=from_name, reply_to=reply_to
recipients=recipients,
subject=subject,
from_name=from_name,
reply_to=reply_to,
),
test_key="test_value",
)
Expand Down
6 changes: 3 additions & 3 deletions wagtail_newsletter/campaign_backends/mailchimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,16 @@ def get_campaign_request_body(
}

if recipients is not None:
body["recipients"] = {
recipients_mapping: dict[str, Any] = {
"list_id": recipients.audience,
}

if recipients.segment:
segment_id = int(recipients.segment.split("/")[1])
body["recipients"]["segment_opts"] = {
recipients_mapping["segment_opts"] = {
"saved_segment_id": segment_id,
}
body["recipients"] = recipients_mapping

return body

Expand All @@ -225,7 +226,6 @@ def save_campaign(
from_name: str,
html: str,
) -> str:

body = self.get_campaign_request_body(
recipients=recipients,
subject=subject,
Expand Down
4 changes: 2 additions & 2 deletions wagtail_newsletter/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Any, Optional

from django.core.exceptions import ValidationError
from django.db import models
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.db import models
from django.http import HttpResponse
from django.template.loader import render_to_string
from django.utils.safestring import SafeString
Expand Down