Skip to content

[BB-3963] Add marketing djangoapp

Boros Gábor requested to merge arjun/bb-3963-marketing into master

Created by: arjunsinghy96

Description

Adds a marketing django app with EmailTemplate, Subscriber and SentEmail models.

Adds settings MARKETING_EMAIL_SENDER and MARKETING_DELETE_FOLLOWUP_EMAILS_AFTER_DAYS

Adds periodic tasks send_followup_emails to dispatch all followup emails for the day and prune_emails to delete all old emails (configurable using settings.MARKETING_DELETE_FOLLOWUP_EMAILS_AFTER_DAYS)

Jira Tickets

BB-3963

Testing Instructions

Common

  1. Get the devstack running and checkout to this branch.
  2. Run migrations.

Checking admin and admin action

  1. Start the dev server and visit the admin panel at http://localhost:5000/admin/marketing/
  2. Verify that each of the three models EmailTemplate, SentEmail and Subscriber are registered.
  3. Create a new inactive EmailTemplate object.
  4. Verify that send_sample_emails action is available in EmailTemplate admin.
  5. Select the Template created above and trigger the send_sample_emails action.
  6. Check dev server logs and verfiy that the email was sent.

Testing tasks

  1. Set MARKETING_DELETE_FOLLOWUP_EMAILS_AFTER_DAYS to 0. (This will be required when testing prune_emails)
  2. Restart the dev server.
  3. Create a Subscriber object and set trial_started_at to a appropriate value such that trial_started_at + EmailTemplate.send_after_days is equal to now. One example will be to set send_after_days to 1 and trial_started_at to yesterday's date with time less than current time
  4. With dev server still running open a shell using make shell in another terminal.
  5. Run following code
from marketing.tasks import send_followup_emails
send_followup_emails()
  1. In dev server logs verify that the email was sent to subscriber.
  2. Trigger the task again (using send_followup_email) and verfiy that this time no email is sent.
  3. Verify that the SentEmail model have the recently sent email (Check in django admin)
  4. Verfiy that the saved emails in SentEmail are not editable from admin panel.
  5. Now run the following code in shell to verfiy the prune_email task
from marketing.tasks import prune_emails
prune_emails()
  1. Verify that the SentEmail models has no elements. (Django admin can be used.)

Template variables

Following variables are provided in template context:

  1. full_name: String
  2. username: String
  3. instance_name: String
  4. subdomain: String
  5. application: Instance of BetaTestApplication

Try out these variables using django's {{ variable }} template syntax.

Merge request reports