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

Monthly donation email hook #215

Merged
merged 10 commits into from
Apr 12, 2015
Merged

Monthly donation email hook #215

merged 10 commits into from
Apr 12, 2015

Conversation

erictshen
Copy link
Member

Fixes #125

Added a command for running monthly donation email jobs. Will add a job to heroku when this gets merged in.

@andylouisqin will also be working on email text once this gets merged in.

Example email from the terminal.
screen shot 2015-04-05 at 1 59 38 pm

from revolv.lib.mailer import send_revolv_email


class Command(BaseCommand):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call this something semantic? How about MonthlyDonationEmailCommand?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Django expects something called Command =(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh bleh, okay

@noahsark769
Copy link
Contributor

We need tests!

@erictshen
Copy link
Member Author

Tests currently fail. Main reason why is that we can't override the created_at variable for the payments.

FactoryBoy/factory_boy#102

Will most likely implement this the first way mentioned in that link, unless you'd prefer some other way of fixing this issue.

@erictshen
Copy link
Member Author

Updated factory boy so we can override the created_at attribute! Passes tests now, let me know if you would like more test coverage.

date_of_last_month = datetime.date.today().replace(day=1) - datetime.timedelta(days=1)

# creates two payments and sets their created_at date to a date from last month
Payment.factories.base.create(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You actually don't need to specify all of these values, you can just say Payment.factories.donation.create(created_at=...). Everything else doesn't really matter, so no need to include it

@noahsark769
Copy link
Contributor

@erictshen I think we should add two more tests: (1) one where we mock out the return value of .now() and make sure that we can run the command with override=False, and (2) one where we run the command from some random day of the month that's not the first day, and make sure that only the donations from the previous MONTH get tracked (not donations from the past 30 DAYS, which may be different than the past month).

Also, it might make sense to send the admins an email when this job is done running, like "An automatic batch of monthly donation engagement emails was sent" or something like that. What do you think - should be pretty easy to do, since we don't need a fancy email template and I believe we have a utility function to get all administrator emails already.

context, [user.email]
)
else:
print "Attempted to run monthlydonationemail command on a day that was not the 1st of the month"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we say that the command was not actually run? Or something about using --override to force it? Also we should at least end this sentence with a period :)

@erictshen
Copy link
Member Author

Added additional test coverage. Also added a command line arguments to email administrators when the monthlydonationemail command is run, I can make it default behavior if you'd prefer.

@noahsark769
Copy link
Contributor

Two more things!

  1. I think that emailing admins should be the default behavior
  2. I think that in the docstring for the Command, we should specify the functionality about only emailing people who have donated within the previous month, not the previous 30 days.

New tests look good!

@noahsark769
Copy link
Contributor

  1. Need to add tests to check that emails to admins are sent
  2. Admin email template should include the number of donation emails sent in the batch, I think

@noahsark769
Copy link
Contributor

Ship it!

 --    .-""-.
   ) (     )
  (   )   (
     /     )
    (_    _)                     0_,-.__
      (_  )_                     |_.-._/
       (    )                    |_--..\
        (__)                     |__--_/
     |''   ``\                   |
     |        \                  |      /b.
     |         \  ,,,---===?A`\  |  ,==y'
   ___,,,,,---==""\        |M] \ | ;|\ |>
           _   _   \   ___,|H,,---==""""bno,
    o  O  (_) (_)   \ /          _     AWAW/
                     /         _(+)_  dMM/
      \@_,,,,,,---=="   \      \\|//  MW/
--''''"                         ===  d/
                                    //
                                    ,'__________________________
   \    \    \     \               ,/~~~~~~~~~~~~~~~~~~~~~~~~~~~
                         _____    ,'  ~~~   .-""-.~~~~~~  .-""-.
      .-""-.           ///==---   /`-._ ..-'      -.__..-'
            `-.__..-' =====\\\\\\ V/  .---\.
 PGMG                 ~~~~~~~~~~~~, _',--/_.\  .-""-.
                            .-""-.___` --  \|         -.__..-

noahsark769 added a commit that referenced this pull request Apr 12, 2015
@noahsark769 noahsark769 merged commit 5af0942 into master Apr 12, 2015
@noahsark769 noahsark769 deleted the eric-monthly-donation-email branch May 25, 2015 20:34
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.

Monthly engagement email hook
2 participants