Skip to content
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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

newearthmartin
Copy link
Contributor

@newearthmartin newearthmartin commented Mar 27, 2021

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 field subscription_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 of Subscription objects to be used for sending the message. These dynamic Submission 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 generated Subscriptions will be added to DB Subscription objects. Also, unsubscribed DB Subscriptions will be removed from the dynamically generated Subscriptions.

@codecov
Copy link

codecov bot commented Mar 27, 2021

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 ☂️

@newearthmartin
Copy link
Contributor Author

@dokterbob curious if you have any opinions about this PR

@aclark4life
Copy link

@newearthmartin Nice to see someone still working on this!

@newearthmartin
Copy link
Contributor Author

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.

@newearthmartin
Copy link
Contributor Author

Thanks @aclark4life ! Would be great to get some feedback here or at the original discussion #359

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants