rctab.routers.accounting.send_emails

Tools for sending email notifications to users.

Functions

check_for_overbudget_subs(database)

Check for subscriptions that are overbudget and should trigger an email.

check_for_subs_nearing_expiry(database)

Check for subscriptions that should trigger an email as they near expiry.

extract_sub_id(my_dict)

Returns the value for the key "subscription_id".

get_allocations_since(database, ...)

Get new allocations since given datetime.

get_approvals_since(database, ...)

Get new approvals since given datetime.

get_emails_sent_since(database, ...)

Get information about emails sent since a given time.

get_finance_entries_since(database, ...)

Get finance info grouped by subscription id.

get_new_subscriptions_since(database, ...)

Returns a list of all the subscriptions created since the provided datetime.

get_sub_email_recipients(database, ...)

Get the email adresses of users that should be emailed about this subscription.

get_subscription_details_since(database, ...)

Get the oldest and newest rows of the subscription details table.

prepare_roles_email(database, new_status, ...)

Prepare arguments for sending a role assignment change email, if necessary.

prepare_subscription_status_email(database, ...)

Prepare arguments for sending a status change email, if necessary.

prepare_summary_email(database[, ...])

Prepares and returns data needed to send summary email.

prepare_welcome_email(database, new_status)

Prepare arguments for sending a welcome email for a new_status, if necessary.

render_template(template_name, template_data)

Renders html based on the provided template and data.

send_expiry_looming_emails(database, ...)

Send an email to notify users that a subscription is nearing its expiry date.

send_generic_email(database, ...)

Sends template-based emails.

send_overbudget_emails(database, overbudget_subs)

Send an email to notify users that subscription is overbudget.

send_status_change_emails(database, new_status)

Send emails after a change in subscription status.

send_with_sendgrid(subject, template_name, ...)

Sends an email to those in to_list with subject=subject.

should_send_expiry_email(date_of_expiry, ...)

Work out whether we should send an email for this subscription.

sub_time_based_emails()

Builds a query to get the most recent time-based email for each subscription.

sub_usage_emails()

Builds a query to get the most recent warning emails each subscription.

Classes

UsageEmailContextManager(database)

Compare usage at enter and exit, sending emails as necessary.

Exceptions

MissingEmailParamsError(subject, recipients, ...)

Exception for when email settings are missing.