Reputation: 2770
The Goal: Once a user has signed up they start a challenge. Once they've started the challenge I'd like to be able to send users weekly emails for 12 weeks (Or however long the challenge lasts for). Bearing in mind, one user may sign up today and one may sign up in three months time. Each week, the email will be different and be specific to that week. So I don't want the week one email being sent alongside week 2 for 12 weeks.
Should I add 12 boolean fields inside the extended User model, then run checks against them and set the value to True once that week gas passed?
Assuming this is the case. Would i then need to setup a cron task which runs every week, and compares the users sign up date to todays date and then checks off the week one boolean? Then use the post_save signal to run a check to see which week has been completed and send the 'week one' email?
I hope that makes sense and i'm trying to get my head around the logic. I'm comfortable with sending email now. It's trying to put together an automated process as currently it's all manual.
Please let me know if I need to elaborate on anything. Any help would be much appreciated.
Upvotes: 1
Views: 806
Reputation: 148
You definitely need to use cron task - I recommend Celery. I think that you just need to build 12 templates (for every week, or maybe building less and use different parameters in the message) in your mailing service and name them with a format (for example {challenge_name}-{week_num}). Every week when your cron task runs target the email message that you want to send by calculating the number weeks from the user registration date and planting it in your format to choose the correct email.
Upvotes: 0
Reputation: 3153
The easiest way would be something like this:
challenge
in database with following cols: challenge_name, week1, week2, ..., as much weeks as you need. Make them nullable, so if some challenge is shorter, the rest of weeks can be null.challenge
for mail content and then send.I think this is the best solution, certainly the most simple and solid one :)
Upvotes: 2