コード例 #1
0
def _send_batch_static_emails(emails, subject, html_content, from_name=None):
    for email in emails:
        send_email(settings.GENERAL_INFO_EMAIL,
                   subject,
                   email,
                   html_content=html_content,
                   from_name=from_name)
コード例 #2
0
def _send_batch_emails_with_context(subject, email_contexts, from_name=None):
    for email, html_content in email_contexts:
        send_email(settings.GENERAL_INFO_EMAIL,
                   subject,
                   email,
                   html_content=html_content,
                   from_name=from_name)
コード例 #3
0
    def run(self):
        users = User.query.filter(
            and_(User.status == status.CONFIRMED,
                 User.confirmed.is_(True))).all()
        for user in users:
            user_email = user.email
            buffered = cStringIO.StringIO()
            qr_code = qrcode.make(user_email)
            qr_code.save(buffered, 'png')
            encoded = base64.b64encode(buffered.getvalue()).decode()

            attachments = [{
                'encoded': encoded,
                'file_type': 'image/png',
                'filename': 'qrcode.png'
            }]
            html = render_template(
                'emails/application_decisions/preevent.html', user=user)
            send_email(settings.GENERAL_INFO_EMAIL,
                       "Important {} Pre-Event Information".format(
                           settings.HACKATHON_NAME),
                       user.email,
                       html_content=html,
                       attachments=attachments)
            print('Sent event day email to user_id={}'.format(user.id))
コード例 #4
0
    def run(self):
        users = []

        query_result = User.query.filter(
            User.school_name.op('~')('[uU][nN][iI].*'),
            User.school_name.op('~')('.*[tT][eE][xX][aA][sS].*'),
            User.school_name.op('~')('.*[aA][uU][sS].*')
        ).all()
        users += query_result

        query_result = User.query.filter(
            User.school_name.op('~')('.*[uU][tT] [aA][uU].*')
        ).all()
        users += query_result

        for user in users:
            user_email = user.email

            html = render_template('emails/application_decisions/freetail_recruitment.html', user=user)
            send_email(
                settings.GENERAL_INFO_EMAIL,
                "Join Freetail Hackers -- the organizers of {}!".format(settings.HACKATHON_NAME),
                user.email,
                html_content=html,
                attachments=None
            )
            print ('Sent freetail recruitment email to user_id={}'.format(user.id))
コード例 #5
0
    def run(self, user_id, new_status, current_status):
        if user_id is None or new_status is None:
            print('Please specify user_id and new_status')
            return

        user = User.query.filter(User.id == user_id).first()
        if user is None:
            print('There is no user with user_id={}'.format(user_id))
            return

        if current_status is not None:
            assert user.status.lower() == current_status.lower(
            ), 'User status is {}'.format(user.status)

        new_status = new_status.lower()
        changed_status = False
        if (new_status == 'accepted'):
            user.status = status.ACCEPTED
            html = render_template(
                'emails/application_decisions/accepted.html', user=user)
            changed_status = True
        elif (new_status == 'accepted-from-waitlist'):
            assert current_status.lower() == status.WAITLISTED.lower(
            ), "Current status should be waitlisted"
            user.status = status.ACCEPTED
            html = render_template(
                'emails/application_decisions/accept_from_waitlist.html',
                user=user)
            changed_status = True
        elif (new_status == 'waitlisted'):
            user.status = status.WAITLISTED
            html = render_template(
                'emails/application_decisions/waitlisted-initial.html',
                user=user)
            changed_status = True
        elif (new_status == 'rejected'):
            user.status = status.REJECTED
            html = render_template(
                'emails/application_decisions/rejected.html', user=user)
            changed_status = True
        else:
            raise Exception('{} is not a valid status'.format(new_status))
        if (changed_status):
            DB.session.add(user)
            DB.session.commit()
            print(html)
            send_email(settings.GENERAL_INFO_EMAIL,
                       'Your {} Application Status'.format(
                           settings.EVENT_NAME),
                       user.email,
                       html_content=html)
            print('{} user_id={}'.format(new_status, user.id))
コード例 #6
0
ファイル: views.py プロジェクト: shry678/pepper
def forgot_password():
    if request.method == 'GET':
        return render_template('users/forgot_password.html')
    else:
        email = request.form.get('email')
        user = User.query.filter_by(email=email).first()
        if user:
            token = timed_serializer.dumps(user.email, salt=settings.RECOVER_SALT)
            url = url_for('corp-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)
            send_email('*****@*****.**', 'Your password reset link', email, txt, html)
        flash('If there is a registered user with {}, then a password reset email has been sent!'.format(email),
              'success')
        return redirect(url_for('corp-login'))
コード例 #7
0
 def run(self):
     users = User.query.filter(
         and_(User.status == status.PENDING,
              User.confirmed.is_(True))).all()
     for user in users:
         user.status = status.WAITLISTED
         html = render_template(
             'emails/application_decisions/waitlisted-initial.html',
             user=user)
         DB.session.add(user)
         DB.session.commit()
         send_email(settings.GENERAL_INFO_EMAIL,
                    "Your {} Application Status".format(
                        settings.HACKATHON_NAME),
                    user.email,
                    html_content=html)
         print 'Moving user_id={} to the waitlist'.format(user.id)
コード例 #8
0
def reject_users():
    waitlisted_users = User.query.filter(
        User.status == status.WAITLISTED).all()

    if request.method == 'GET':
        return render_template('users/admin/reject_users.html',
                               users=waitlisted_users)
    else:
        for user in waitlisted_users:
            html = render_template(
                'emails/application_decisions/rejected.html', user=user)
            send_email(settings.GENERAL_INFO_EMAIL,
                       "Update from HackTX",
                       user.email,
                       html_content=html)
            user.status = status.REJECTED
            DB.session.add(user)
            DB.session.commit()
        flash('Successfully rejected all waitlisted user(s)', 'success')
        return redirect(url_for('reject-users'))
コード例 #9
0
ファイル: helpers.py プロジェクト: shry678/pepper
def send_recruiter_invite(user):
    g.log.info('Sending a recruiter invite for user {}'.format(user.id))
    # send invite to the recruiter
    token = utils.serializer.dumps(user.email)
    url = url_for('new-user-setup', token=token, _external=True)
    txt = render_template('emails/corporate_welcome.txt',
                          user=user,
                          setup_url=url)
    html = render_template('emails/corporate_welcome.html',
                           user=user,
                           setup_url=url)

    try:
        utils.send_email(from_email=settings.GENERAL_INFO_EMAIL,
                         subject='Your invitation to join my{}'.format(
                             settings.HACKATHON_NAME),
                         to_email=user.email,
                         txt_content=txt,
                         html_content=html)
    except Exception as e:
        g.log = g.log.bind(error=e)
        g.log.error('Unable to send recruiter email: ')