-
-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic subscription #367
base: master
Are you sure you want to change the base?
Dynamic subscription #367
Conversation
Welcome to Codecov 🎉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 ☂️ |
@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 #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 #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.