Open newearthmartin opened 3 years ago
Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.
Thanks for integrating Codecov - We've got you covered :open_umbrella:
@dokterbob curious if you have any opinions about this PR
@newearthmartin Nice to see someone still working on this!
I just added a modification in the original proposed behavior. Now, existing DB Subscription objects will be joined with dynamically generated ones. This is especially useful to keep track of user unsubscribes.
Thanks @aclark4life ! Would be great to get some feedback here or at the original discussion https://github.com/jazzband/django-newsletter/issues/359
The goal of this PR is to be able to dynamically generate a list of subscriptions at the moment of submitting the
Submission
. It is following on this idea https://github.com/jazzband/django-newsletter/issues/359.The
Newsletter
class has a new fieldsubscription_generator_class
. If this field is empty, it will continue behaving as usual. However, if the field is not empty, It is a class name that will be instantiated into a subscription generator object. The subscription generator will be in charge of generating the list of subscriptions at the moment of sending the message.This is done by implementing the
generate_subscriptions(submission)
method. This method must return a list ofSubscription
objects to be used for sending the message. These dynamicSubmission
objects must be in-memory objects and should not be saved to the DB.Existing Subscription objects in the DB for this
Newsletter
/Submission
will still be used. At the time of submission, dynamically generatedSubscription
s will be added to DBSubscription
objects. Also, unsubscribed DBSubscription
s will be removed from the dynamically generatedSubscription
s.