send_slack_invitation_email

Django management command to send the Slack invitation email to someone, now.

This module defines the send_slack_invitation_email management command for the Smarter platform. The Celery Beat task smarter.apps.account.tasks.send_slack_invitation_emails sends the email to every account contact two days after their welcome email. This command sends it ad hoc, to a user, an account contact, or anyone else.

Features

  • Sends the HTML Slack invitation email to a user, by username or email address.

  • Sends it to an email address that belongs to no user or account contact. Nothing is recorded for such an address.

  • Records the time in AccountContact.slack_invited_at of every contact with the address, so that the Celery Beat task doesn’t send it again.

  • Refuses an address that was already invited, unless --force is given, and always refuses an address that unsubscribed.

Command-line Options

  • --username: The username of the user.

  • --email: The email address, of a user, an account contact or anyone else.

  • --first_name: The first name in the greeting. Defaults to the user’s or contact’s first name.

  • --language: The language of the email, one of settings.LANGUAGES, e.g. es. Defaults to the user’s preferred language (UserProfile.language), or English.

  • --force: Send it to an address that was already invited.

Typical Usage

python manage.py send_slack_invitation_email --username jdoe
python manage.py send_slack_invitation_email --email jane@example.com --first_name Jane --language es
class smarter.apps.account.management.commands.send_slack_invitation_email.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Bases: SmarterCommand

Send the html Slack invitation email to a user, an account contact, or any email address.

add_arguments(parser)[source]

Add arguments to the command.

handle(*args, **options)[source]

Send the Slack invitation email.

static preferred_language(email)[source]

Return the preferred language of the user with an email address.

Parameters:

email (str) – The email address.

Return type:

str

Returns:

The user’s UserProfile.language, or settings.LANGUAGE_CODE for an address that is no user’s.