Ejemplo n.º 1
0
def resetpass():
    """Reset the user's password

    If the user successfully submitted the form, send a password
    reset email. Otherwise, render the reset form again.
    """

    form = ForgotForm()
    if form.validate_on_submit():
        email = form.email.data
        pw_reset = PasswordReset(user=User.get_by_email(email), )
        db.session.add(pw_reset)
        db.session.commit()
        #Send email here
        title = 'Reset your Password'
        url = "{site}/auth/setnewpass/{key}".format(
            site=os.environ['DLI_REPORTS_SITE_URL'],
            key=pw_reset.key,
        )
        content = 'Click this link to reset your password: {url}'.format(
            url=url)
        content += '\nThis link will expire in 7 days!'
        msg = Message(title, recipients=[email])
        msg.body = content
        mail.send(msg)
        flash("Email sent!", "alert-success")
        return redirect(url_for('default.home'))
    else:
        flash_form_errors(form)
        return render_template('auth/resetpass.html', form=form)
Ejemplo n.º 2
0
def resetpass():
    """Reset the user's password

    If the user successfully submitted the form, send a password
    reset email. Otherwise, render the reset form again.
    """

    form = ForgotForm()
    if form.validate_on_submit():
        email = form.email.data
        pw_reset = PasswordReset(
            user=User.get_by_email(email),
        )
        db.session.add(pw_reset)
        db.session.commit()
        #Send email here
        title = 'Reset your Password'
        url = "{site}/auth/setnewpass/{key}".format(
            site=os.environ['DLI_REPORTS_SITE_URL'],
            key=pw_reset.key,
        )
        content = 'Click this link to reset your password: {url}'.format(url=url)
        content += '\nThis link will expire in 7 days!'
        msg = Message(title, recipients=[email])
        msg.body = content
        mail.send(msg)
        flash("Email sent!", "alert-success")
        return redirect(url_for('default.home'))
    else:
        flash_form_errors(form)
        return render_template('auth/resetpass.html', form=form)
Ejemplo n.º 3
0
    def send_new(cls):
        """Send new ErrorReports to the project developers"""
        error_reports = cls.query.filter_by(sent=False).all()
        today = datetime.datetime.today().strftime('%Y-%m-%d')

        if error_reports:
            title = 'Bug Reports and Feature Requests {}'.format(today)
            msg = Message(title, recipients=[os.environ['DLI_REPORTS_DEV_EMAIL']])
            msg.body = '\n\n'.join(er.email_format for er in error_reports)
            mail.send(msg)
            for er in error_reports:
                er.sent = True
            db.session.commit()
Ejemplo n.º 4
0
    def send_new(cls):
        """Send new ErrorReports to the project developers"""
        error_reports = cls.query.filter_by(sent=False).all()
        today = datetime.datetime.today().strftime('%Y-%m-%d')

        if error_reports:
            title = 'Bug Reports and Feature Requests {}'.format(today)
            msg = Message(title,
                          recipients=[os.environ['DLI_REPORTS_DEV_EMAIL']])
            msg.body = '\n\n'.join(er.email_format for er in error_reports)
            mail.send(msg)
            for er in error_reports:
                er.sent = True
            db.session.commit()
Ejemplo n.º 5
0
 def send_link(self):
     """Send a registration link to this user"""
     key = self.registration_key
     title = 'Activate your account'
     url = 'http://{site}/auth/register/{key}'.format(
         site=os.environ['DLI_REPORTS_SITE_URL'],
         key=key,
     )
     recipient = self.email
     msg = Message(title, recipients=[recipient])
     msg.html = """
         <p>Hello</p>
         <p>You are invited to register at DLI Reports!
         Please go to this link to activate your account:</p>
         <a href="{url}">{url}</a>
         <p>Thank you!</p>
     """.format(url=url)
     mail.send(msg)
Ejemplo n.º 6
0
 def send_link(self):
     """Send a registration link to this user"""
     key = self.registration_key
     title = 'Activate your account'
     url = 'http://{site}/auth/register/{key}'.format(
         site=os.environ['DLI_REPORTS_SITE_URL'],
         key=key,
     )
     recipient = self.email
     msg = Message(title, recipients=[recipient])
     msg.html = """
         <p>Hello</p>
         <p>You are invited to register at DLI Reports!
         Please go to this link to activate your account:</p>
         <a href="{url}">{url}</a>
         <p>Thank you!</p>
     """.format(url=url)
     mail.send(msg)
Ejemplo n.º 7
0
def question():
    """Email administrators"""
    form = AskQuestionForm()
    if form.validate_on_submit():
        # Send email to administrators
        users = [u.email for u in User.query.filter_by(is_admin=True)]
        emailtitle = form.emailtitle.data
        content = form.content.data
        msg = Message(emailtitle, recipients=users, reply_to=form.email.data)
        msg.body = '{notice}\n{content}'.format(
            notice=
            ('A new question was asked concerning the online DLI policies Wiki. '
             'Please reply to this email to answer the question.'),
            content=content,
        )
        mail.send(msg)
        flash("Email Sent!", "alert-success")
        return redirect(url_for('wiki.home'))
    else:
        flash_form_errors(form)
        return render_template('wiki/question.html', form=form)
Ejemplo n.º 8
0
def question():
    """Email administrators"""
    form = AskQuestionForm()
    if form.validate_on_submit():
        # Send email to administrators
        users = [u.email for u in User.query.filter_by(is_admin=True)]
        emailtitle = form.emailtitle.data
        content = form.content.data
        msg = Message(emailtitle, recipients=users, reply_to=form.email.data)
        msg.body = '{notice}\n{content}'.format(
            notice=(
                'A new question was asked concerning the online DLI policies Wiki. '
                'Please reply to this email to answer the question.'
            ),
            content=content,
        )
        mail.send(msg)
        flash("Email Sent!", "alert-success")
        return redirect(url_for('wiki.home'))
    else:
        flash_form_errors(form)
        return render_template('wiki/question.html', form=form)