wagtail / wagtail-newsletter

Send email newsletters based on Wagtail content
https://wagtail-newsletter.readthedocs.io
BSD 3-Clause "New" or "Revised" License
9 stars 3 forks source link

Recipients model #22

Closed mgax closed 1 month ago

mgax commented 1 month ago

Fixes https://github.com/wagtail/wagtail-newsletter/issues/14.

This PR introduces the queryish library, to wrap the Mailchimp API results into a queryset-like interface, which can be consumed by ChooserViewSet, to have a nice picker for the audience and segment fields of the Recipients model.

Individual results are cached for 5 minutes (configurable) so that repeated page loads don't stall waiting for API calls to Mailchimp.

The recipients model is swappable, and I'll add some tests around this when implementing https://github.com/wagtail/wagtail-newsletter/issues/15 (when the recipients model will actually be referenced).

mgax commented 1 month ago

@olivierphi sorry for the late change, I've refactored some of the tests, to include a new MemoryCampaignBackend class that helps with mocking a campaign backend, because I've found it useful for subsequent tests. Would you mind checking the new changes too? Thanks!