Esempio n. 1
0
def password_reset_email(user,
                         token_generator,
                         use_https=False,
                         domain=None,
                         template=None,
                         subject=None,
                         sender=None):
    domain = domain or htk_setting('HTK_DEFAULT_DOMAIN')
    context = {
        'user': user,
        'email': user.email,
        'protocol': use_https and 'https' or 'http',
        'domain': domain,
        'site_name': htk_setting('HTK_SITE_NAME'),
        'reset_path':
        reverse(htk_setting('HTK_ACCOUNTS_RESET_PASSWORD_URL_NAME')),
        'uid': int_to_base36(user.id),
        'token': token_generator.make_token(user),
    }

    reset_uri = '%(protocol)s://%(domain)s%(reset_path)s?u=%(uid)s&t=%(token)s' % context
    context['reset_uri'] = reset_uri
    template = template or 'accounts/reset_password'
    subject = (
        subject
        or htk_setting('HTK_ACCOUNT_EMAIL_SUBJECT_PASSWORD_RESET')) % context
    send_email(template=template,
               subject=subject,
               sender=sender,
               to=[context['email']],
               context=context)
Esempio n. 2
0
def activation_email(user_email, use_https=False, domain=None, template=None, subject=None):
    """Sends an activation/confirmation email for user to confirm email address
    """
    user = user_email.user
    email = user_email.email
    domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN')

    context = {
        'user': user,
        'email': email,
        'protocol': use_https and 'https' or 'http', 
        'domain': domain,
        'site_name': htk_setting('HTK_SITE_NAME'),
        'confirm_email_path': reverse(
            htk_setting('HTK_ACCOUNTS_CONFIRM_EMAIL_URL_NAME'),
            args=(user_email.activation_key,)
        ),
    }

    if template is None:
        template='accounts/activation'

    if subject is None:
        subject = 'Confirm your email address, %s' % email

    activation_uri = '%(protocol)s://%(domain)s%(confirm_email_path)s' % context
    context['activation_uri'] = activation_uri
    bcc = htk_setting('HTK_DEFAULT_EMAIL_BCC')
    send_email(
        template=template,
        subject=subject,
        to=[email,],
        context=context,
        bcc=bcc
    )
Esempio n. 3
0
def welcome_email(user):
    context = {
        'user': user,
    }
    send_email(
        template='accounts/welcome',
        subject='Welcome to Hacktoolkit.com, %s' % user.email,
        to=[user.email],
        context=context,
        bcc=[WATCHER_EMAIL]
    )
Esempio n. 4
0
    def send_email(self, recipient, **kwargs):
        """Workhorse function called by `self.send_emails` for
        sending to one `recipient`

        Can be overridden
        """
        email_params = self._craft_email_params(recipient, **kwargs)
        context = email_params.get('context', {})
        send_email(template=email_params.get('template'),
                   subject=context.get('subject'),
                   to=email_params.get('recipients', []),
                   context=context)
Esempio n. 5
0
def activation_email(user_email,
                     use_https=False,
                     domain=None,
                     template=None,
                     subject=None,
                     sender=None):
    """Sends an activation/confirmation email for user to confirm email address
    """
    user = user_email.user
    email = user_email.email
    domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN')

    context = {
        'user':
        user,
        'first_name':
        user.first_name,
        'last_name':
        user.last_name,
        'email':
        email,
        'protocol':
        use_https and 'https' or 'http',
        'domain':
        domain,
        'site_name':
        htk_setting('HTK_SITE_NAME'),
        'confirm_email_path':
        reverse(htk_setting('HTK_ACCOUNTS_CONFIRM_EMAIL_URL_NAME'),
                args=(user_email.activation_key, )),
    }

    if template is None:
        template = 'accounts/activation'

    if subject is None:
        subject = htk_setting('HTK_ACCOUNT_EMAIL_SUBJECT_ACTIVATION') % context

    activation_uri = '%(protocol)s://%(domain)s%(confirm_email_path)s' % context
    context['activation_uri'] = activation_uri
    if htk_setting('HTK_ACCOUNT_EMAIL_BCC_ACTIVATION'):
        bcc = htk_setting('HTK_DEFAULT_EMAIL_BCC')
    else:
        bcc = None
    send_email(template=template,
               subject=subject,
               sender=sender,
               to=[
                   email,
               ],
               context=context,
               bcc=bcc)
Esempio n. 6
0
def welcome_email(user):
    context = {
        'user': user,
        'site_name': htk_setting('HTK_SITE_NAME'),
    }
    bcc = htk_setting('HTK_DEFAULT_EMAIL_BCC')
    send_email(
        template='accounts/welcome',
        subject='Welcome to %s, %s' % (htk_setting('HTK_SITE_NAME'), user.email,),
        to=[user.email],
        context=context,
        bcc=bcc
    )
Esempio n. 7
0
def password_changed_email(user):
    context = {
        'user': user,
        'email': user.email,
        'domain': htk_setting('HTK_DEFAULT_DOMAIN'),
        'site_name': htk_setting('HTK_SITE_NAME'),
    }
    subject = htk_setting(
        'HTK_ACCOUNT_EMAIL_SUBJECT_PASSWORD_CHANGED') % context
    send_email(template='accounts/password_changed',
               subject=subject,
               to=[user.email],
               context=context)
Esempio n. 8
0
def password_changed_email(user):
    context = {
        'user': user,
        'email': user.email,
        'domain': htk_setting('HTK_DEFAULT_DOMAIN'),
        'site_name': htk_setting('HTK_SITE_NAME'),
    }
    send_email(
        template='accounts/password_changed',
        subject='Password changed on %s' % context['site_name'],
        to=[user.email],
        context=context
    )
Esempio n. 9
0
def password_changed_email(user):
    context = {
        'user': user,
        'email': user.email,
        'domain': htk_setting('HTK_DEFAULT_DOMAIN'),
        'site_name': htk_setting('HTK_SITE_NAME'),
    }
    subject = htk_setting('HTK_ACCOUNT_EMAIL_SUBJECT_PASSWORD_CHANGED') % context
    send_email(
        template='accounts/password_changed',
        subject=subject,
        to=[user.email],
        context=context
    )
Esempio n. 10
0
    def send_email(self, recipient, **kwargs):
        """Workhorse function called by `self.send_emails` for
        sending to one `recipient`

        Can be overridden
        """
        email_params = self._craft_email_params(recipient, **kwargs)
        context = email_params.get('context', {})
        send_email(
            template=email_params.get('template'),
            subject=context.get('subject'),
            to=email_params.get('recipients', []),
            context=context
        )
Esempio n. 11
0
def activation_email(user_email,
                     use_https=False,
                     domain=None,
                     template=None,
                     subject=None,
                     sender=None):
    """Sends an activation/confirmation email for user to confirm email address
    """
    user = user_email.user
    email = user_email.email
    domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN')

    context = {
        'user':
        user,
        'first_name':
        user.first_name,
        'last_name':
        user.last_name,
        'email':
        email,
        'protocol':
        use_https and 'https' or 'http',
        'domain':
        domain,
        'activation_uri':
        user_email.get_activation_uri(use_https=use_https, domain=domain),
        'site_name':
        htk_setting('HTK_SITE_NAME'),
    }

    if template is None:
        template = 'accounts/activation'

    if subject is None:
        subject = htk_setting('HTK_ACCOUNT_EMAIL_SUBJECT_ACTIVATION') % context

    if htk_setting('HTK_ACCOUNT_EMAIL_BCC_ACTIVATION'):
        bcc = htk_setting('HTK_DEFAULT_EMAIL_BCC')
    else:
        bcc = None
    send_email(template=template,
               subject=subject,
               sender=sender,
               to=[
                   email,
               ],
               context=context,
               bcc=bcc)
Esempio n. 12
0
def feedback_email(feedback, domain=None):
    domain = domain or htk_setting('HTK_DEFAULT_DOMAIN')

    subject = htk_setting('HTK_FEEDBACK_EMAIL_SUBJECT',
                          HTK_FEEDBACK_EMAIL_SUBJECT)
    to = htk_setting('HTK_FEEDBACK_EMAIL_TO', [])
    if to:
        context = {
            'feedback': feedback,
            'domain': domain,
        }
        send_email(template='htk/feedback',
                   subject=subject,
                   to=to,
                   context=context)
Esempio n. 13
0
def prelaunch_email(prelaunch_signup):
    template = htk_setting('HTK_PRELAUNCH_EMAIL_TEMPLATE', HTK_PRELAUNCH_EMAIL_TEMPLATE)
    subject = htk_setting('HTK_PRELAUNCH_EMAIL_SUBJECT', HTK_PRELAUNCH_EMAIL_SUBJECT)
    bcc = htk_setting('HTK_PRELAUNCH_EMAIL_BCC', HTK_PRELAUNCH_EMAIL_BCC)

    context = {
        'prelaunch_signup': prelaunch_signup,
        'site_name': htk_setting('HTK_SITE_NAME')
    }
    send_email(
        template=template,
        subject=subject,
        to=[prelaunch_signup.email,],
        bcc=bcc,
        context=context
    )
Esempio n. 14
0
def feedback_email(feedback, domain=None):
    domain = domain or htk_setting('HTK_DEFAULT_DOMAIN')

    subject = htk_setting('HTK_FEEDBACK_EMAIL_SUBJECT', HTK_FEEDBACK_EMAIL_SUBJECT)
    to = htk_setting('HTK_FEEDBACK_EMAIL_TO', [])
    if to:
        context = {
            'feedback': feedback,
            'domain': domain,
        }
        send_email(
            template='htk/feedback',
            subject=subject,
            to=to,
            context=context
        )
Esempio n. 15
0
def prelaunch_email(prelaunch_signup):
    template = htk_setting('HTK_PRELAUNCH_EMAIL_TEMPLATE',
                           HTK_PRELAUNCH_EMAIL_TEMPLATE)
    subject = htk_setting('HTK_PRELAUNCH_EMAIL_SUBJECT',
                          HTK_PRELAUNCH_EMAIL_SUBJECT)
    bcc = htk_setting('HTK_PRELAUNCH_EMAIL_BCC', HTK_PRELAUNCH_EMAIL_BCC)

    context = {
        'prelaunch_signup': prelaunch_signup,
        'site_name': htk_setting('HTK_SITE_NAME')
    }
    send_email(template=template,
               subject=subject,
               to=[
                   prelaunch_signup.email,
               ],
               bcc=bcc,
               context=context)
Esempio n. 16
0
def password_reset_email(user, token_generator, use_https=False, domain=DEFAULT_DOMAIN):
    context = {
        'user': user,
        'email': user.email,
        'protocol': use_https and 'https' or 'http', 
        'domain': domain,
        'site_name': 'Hacktoolkit',
        'reset_path': reverse('account_reset_password'),
        'uid': int_to_base36(user.id),
        'token': token_generator.make_token(user),
    }

    reset_uri = '%(protocol)s://%(domain)s%(reset_path)s?u=%(uid)s&t=%(token)s' % context
    context['reset_uri'] = reset_uri
    send_email(
        template='accounts/reset_password',
        subject='Password reset on %s' % context['site_name'],
        to=[context['email']],
        context=context
    )
Esempio n. 17
0
def welcome_email(user):
    context = {
        'user': user,
        'email': user.email,
        'first_name': user.first_name,
        'last_name': user.last_name,
        'site_name': htk_setting('HTK_SITE_NAME'),
    }
    if htk_setting('HTK_ACCOUNT_EMAIL_BCC_WELCOME'):
        bcc = htk_setting('HTK_DEFAULT_EMAIL_BCC')
    else:
        bcc = None
    subject = htk_setting('HTK_ACCOUNT_EMAIL_SUBJECT_WELCOME') % context
    send_email(
        template='accounts/welcome',
        subject=subject,
        to=[user.email],
        context=context,
        bcc=bcc
    )
Esempio n. 18
0
def welcome_email(user, template=None, subject=None, sender=None):
    context = {
        'user': user,
        'email': user.email,
        'first_name': user.first_name,
        'last_name': user.last_name,
        'site_name': htk_setting('HTK_SITE_NAME'),
    }
    if htk_setting('HTK_ACCOUNT_EMAIL_BCC_WELCOME'):
        bcc = htk_setting('HTK_DEFAULT_EMAIL_BCC')
    else:
        bcc = None
    template = template or 'accounts/welcome'
    subject = (subject
               or htk_setting('HTK_ACCOUNT_EMAIL_SUBJECT_WELCOME')) % context
    send_email(template=template,
               subject=subject,
               sender=sender,
               to=[user.email],
               context=context,
               bcc=bcc)
Esempio n. 19
0
def password_reset_email(user, token_generator, use_https=False, domain=None):
    domain = domain or htk_setting('HTK_DEFAULT_DOMAIN')
    context = {
        'user': user,
        'email': user.email,
        'protocol': use_https and 'https' or 'http', 
        'domain': domain,
        'site_name': htk_setting('HTK_SITE_NAME'),
        'reset_path': reverse('account_reset_password'),
        'uid': int_to_base36(user.id),
        'token': token_generator.make_token(user),
    }

    reset_uri = '%(protocol)s://%(domain)s%(reset_path)s?u=%(uid)s&t=%(token)s' % context
    context['reset_uri'] = reset_uri
    subject = htk_setting('HTK_ACCOUNT_EMAIL_SUBJECT_PASSWORD_RESET') % context
    send_email(
        template='accounts/reset_password',
        subject=subject,
        to=[context['email']],
        context=context
    )
Esempio n. 20
0
def welcome_email(user, template=None, subject=None, sender=None):
    context = {
        'user': user,
        'email': user.profile.confirmed_email or user.email,
        'first_name': user.first_name,
        'last_name': user.last_name,
        'site_name': htk_setting('HTK_SITE_NAME'),
    }
    if htk_setting('HTK_ACCOUNT_EMAIL_BCC_WELCOME'):
        bcc = htk_setting('HTK_DEFAULT_EMAIL_BCC')
    else:
        bcc = None
    template = template or 'accounts/welcome'
    subject = (subject or htk_setting('HTK_ACCOUNT_EMAIL_SUBJECT_WELCOME')) % context
    send_email(
        template=template,
        subject=subject,
        sender=sender,
        to=[user.email],
        context=context,
        bcc=bcc
    )
Esempio n. 21
0
def activation_email(user_email, use_https=False, domain=DEFAULT_EMAIL_SENDING_DOMAIN):
    """Sends an activation/confirmation email for user to confirm email address
    """
    user = user_email.user
    email = user_email.email

    context = {
        'user': user,
        'email': email,
        'protocol': use_https and 'https' or 'http', 
        'domain': domain,
        'confirm_email_path': reverse('account_confirm_email', args=(user_email.activation_key,)),
    }

    activation_uri = '%(protocol)s://%(domain)s%(confirm_email_path)s' % context
    context['activation_uri'] = activation_uri
    send_email(
        template='accounts/activation',
        subject='Confirm your email address, %s' % email,
        to=[email],
        context=context,
        bcc=[WATCHER_EMAIL]
    )
Esempio n. 22
0
def activation_email(user_email, use_https=False, domain=None, template=None, subject=None, sender=None):
    """Sends an activation/confirmation email for user to confirm email address
    """
    user = user_email.user
    email = user_email.email
    domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN')

    context = {
        'user': user,
        'first_name': user.first_name,
        'last_name': user.last_name,
        'email': email,
        'protocol': use_https and 'https' or 'http',
        'domain': domain,
        'activation_uri': user_email.get_activation_uri(use_https=use_https, domain=domain),
        'site_name': htk_setting('HTK_SITE_NAME'),
    }

    if template is None:
        template = 'accounts/activation'

    if subject is None:
        subject = htk_setting('HTK_ACCOUNT_EMAIL_SUBJECT_ACTIVATION') % context

    if htk_setting('HTK_ACCOUNT_EMAIL_BCC_ACTIVATION'):
        bcc = htk_setting('HTK_DEFAULT_EMAIL_BCC')
    else:
        bcc = None
    send_email(
        template=template,
        subject=subject,
        sender=sender,
        to=[email,],
        context=context,
        bcc=bcc
    )