예제 #1
0
def keen_add_event(user_id, event_type, event_time):
    user = User.query.filter_by(id=user_id).first()
    fmt = '%Y-%m-%dT%H:%M:%S.%f'
    data = {
        # Birthday can be string from local signup or datetime.date from mlh signup
        'date_of_birth': str(user.birthday),
        'dietary_restrictions': user.dietary_restrictions,
        'email': user.email,
        'first_name': user.fname,
        'last_name': user.lname,
        'gender': user.gender,
        'id': user.id,
        'major': user.major,
        'phone_number': user.phone_number,
        'school': {
            'id': user.school_id,
            'name': user.school_name
        },
        'keen': {
            'timestamp': event_time.strftime(fmt)
        },
        'interests': user.interests,
        'skill_level': user.skill_level,
        'races': user.race,
        'num_hackathons': user.num_hackathons,
        'class_standing': user.class_standing,
        'shirt_size': user.shirt_size,
        'special_needs': user.special_needs
    }
    worker_queue.enqueue(_keen_add_event, event_type, data, 0)
예제 #2
0
def send_batch_static_emails(users, subject, html_content, from_name=None):
    for i in range(0, len(users), settings.MAX_BATCH_EMAILS):
        emails = [
            user.email for user in users[i:i + settings.MAX_BATCH_EMAILS]
        ]
        worker_queue.enqueue(_send_batch_static_emails, emails, subject,
                             html_content, from_name)
예제 #3
0
def send_attending_email(user):
    # send email saying that they are confirmed to attend
    html = render_template(
        'emails/application_decisions/confirmed_invite.html', user=user)
    worker_queue.enqueue(
        send_email, settings.GENERAL_INFO_EMAIL,
        "You're confirmed for {}".format(settings.HACKATHON_NAME), user.email,
        None, html)
예제 #4
0
def send_forgot_password_email(user):
    token = timed_serializer.dumps(user.email, salt=settings.RECOVER_SALT)
    url = url_for('reset-password', token=token, _external=True)
    html = render_template('emails/reset_password.html', user=user, link=url)
    txt = render_template('emails/reset_password.txt', user=user, link=url)
    g.log.info('Sending password reset to:', email=user.email)
    worker_queue.enqueue(send_email, settings.GENERAL_INFO_EMAIL,
                         'Your password reset link', user.email, txt, html)
예제 #5
0
def _keen_add_event(event_type, data, count):
    try:
        keen.add_event(event_type, data)
        print 'success'
    except Exception as e:
        print e
        if count < settings.KEEN_MAX_RETRIES:
            worker_queue.enqueue(_keen_add_event, event_type, data, count + 1)
        else:
            print 'Keen failed too many times, {}'.format(event_type)
예제 #6
0
def send_batch_emails_with_context(users, subject, html_func, from_name=None):
    for i in range(0, len(users), settings.MAX_BATCH_EMAILS):
        email_contexts = [(user.email, html_func(user))
                          for user in users[i:i + settings.MAX_BATCH_EMAILS]]
        worker_queue.enqueue(_send_batch_emails_with_context, subject,
                             email_contexts, from_name)
예제 #7
0
def send_applied_email(user):
    html = render_template('emails/applied.html', user=user)
    worker_queue.enqueue(
        send_email, settings.GENERAL_INFO_EMAIL,
        'Thank you for applying to {0}'.format(settings.HACKATHON_NAME),
        user.email, None, html)
예제 #8
0
def send_confirmation_email(user):
    token = serializer.dumps(user.email)
    url = url_for('confirm-account', token=token, _external=True)
    html = render_template('emails/confirm_account.html', link=url, user=user)
    worker_queue.enqueue(send_email, settings.GENERAL_INFO_EMAIL,
                         'Confirm Your Account', user.email, None, html)