How to use the ramp-frontend.ramp_frontend.utils.send_mail function in ramp-frontend

To help you get started, we’ve selected a few ramp-frontend examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paris-saclay-cds / ramp-board / ramp-frontend / ramp_frontend / views / auth.py View on Github external
"for an approval from a RAMP administrator", category='error'
        )
        return redirect(url_for('general.index'))
    User.query.filter_by(email=email).update({'access_level': 'asked'})
    db.session.commit()
    admin_users = User.query.filter_by(access_level='admin')
    for admin in admin_users:
        subject = 'Approve registration of {}'.format(
            user.name
        )
        body = body_formatter_user(user)
        url_approve = ('http://{}/sign_up/{}'
                       .format(app.config['DOMAIN_NAME'], user.name))
        body += 'Click on the link to approve the registration '
        body += 'of this user: {}'.format(url_approve)
        send_mail(admin.email, subject, body)
    flash(
        "An email has been sent to the RAMP administrator(s) who will "
        "approve your account"
    )
    return redirect(url_for('auth.login'))
github paris-saclay-cds / ramp-board / ramp-frontend / ramp_frontend / views / auth.py View on Github external
form = EmailForm()
    error = ''
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).one_or_none()
        if user and user.access_level != 'asked':
            token = ts.dumps(user.email)
            recover_url = url_for(
                'auth.reset_with_token', token=token, _external=True
            )

            subject = "Password reset requested - RAMP website"
            body = ('Hi {}, \n\nclick on the link to reset your password:\n'
                    .format(user.firstname))
            body += recover_url
            body += '\n\nSee you on the RAMP website!'
            send_mail(user.email, subject, body)
            logger.info(
                'Password reset requested for user {}'.format(user.name)
            )
            logger.info(recover_url)
            flash('An email to reset your password has been sent')
            return redirect(url_for('auth.login'))
        elif user is None:
            error = ('The email address is not linked to any user. You can '
                     'sign-up instead.')
        else:
            error = ('Your account has not been yet approved. You cannot '
                     'change the password already.')
    return render_template('reset_password.html', form=form, error=error)
github paris-saclay-cds / ramp-board / ramp-frontend / ramp_frontend / views / admin.py View on Github external
)
        for asked_id in event_teams_to_be_approved:
            asked_event_team = EventTeam.query.get(asked_id)
            user = select_user_by_name(db.session, asked_event_team.team.name)

            if request.form["submit_button"] == "Approve!":
                sign_up_team(db.session, asked_event_team.event.name,
                             asked_event_team.team.name)

                subject = ('Signed up for the RAMP event {}'
                           .format(asked_event_team.event.name))
                body = ('{}, you have been registered to the RAMP event {}. '
                        'You can now proceed to your sandbox and make '
                        'submissions.\nHave fun!!!'
                        .format(user.name, asked_event_team.event.name))
                send_mail(
                    to=user.email, subject=subject, body=body
                )
            elif request.form["submit_button"] == "Remove!":
                delete_event_team(
                    db.session, asked_event_team.event.name,
                    asked_event_team.team.name
                )
            message += "{}\n".format(asked_event_team)
        return redirect_to_user(
            message, is_error=False,
            category="{}d users".format(request.form["submit_button"][:-1])
        )
github paris-saclay-cds / ramp-board / ramp-frontend / ramp_frontend / views / ramp.py View on Github external
ask_sign_up_team(db.session, event.name, flask_login.current_user.name)
    if event.is_controled_signup:
        admin_users = User.query.filter_by(access_level='admin')
        for admin in admin_users:
            subject = ('Request to sign-up {} to RAMP event {}'
                       .format(event.name, flask_login.current_user.name))
            body = body_formatter_user(flask_login.current_user)
            url_approve = ('http://{}/events/{}/sign_up/{}'
                           .format(
                               app.config['DOMAIN_NAME'], event.name,
                               flask_login.current_user.name
                           ))
            body += ('Click on this link to approve the sign-up request: {}'
                     .format(url_approve))
            send_mail(admin.email, subject, body)
        return redirect_to_user("Sign-up request is sent to event admins.",
                                is_error=False, category='Request sent')
    sign_up_team(db.session, event.name, flask_login.current_user.name)
    return redirect_to_sandbox(
        event,
        '{} is signed up for {}.'
        .format(flask_login.current_user.firstname, event),
        is_error=False,
        category='Successful sign-up'
    )
github paris-saclay-cds / ramp-board / ramp-frontend / ramp_frontend / views / auth.py View on Github external
logger.info(str(e))
            return render_template('index.html')
        # send an email to the participant such that he can confirm his email
        token = ts.dumps(user.email)
        recover_url = url_for(
            'auth.user_confirm_email', token=token, _external=True
        )
        subject = "Confirm your email for signing-up to RAMP"
        body = ('Hi {}, \n\n Click on the following link to confirm your email'
                ' address and finalize your sign-up to RAMP.\n\n Note that '
                'your account still needs to be approved by a RAMP '
                'administrator.\n\n'
                .format(user.firstname))
        body += recover_url
        body += '\n\nSee you on the RAMP website!'
        send_mail(user.email, subject, body)
        logger.info(
            '{} has signed-up to RAMP'.format(user.name)
        )
        flash(
            "We sent a confirmation email. Go read your email and click on "
            "the confirmation link"
        )
        return render_template('index.html')
    return render_template('sign_up.html', form=form)
github paris-saclay-cds / ramp-board / ramp-frontend / ramp_frontend / views / admin.py View on Github external
user = User.query.filter_by(name=user_name).one_or_none()
    if not is_admin(db.session, event_name, flask_login.current_user.name):
        return redirect_to_user('Sorry {}, you do not have admin rights'
                                .format(flask_login.current_user.firstname),
                                is_error=True)
    if not event or not user:
        return redirect_to_user('No event {} or no user {}'
                                .format(event_name, user_name), is_error=True)
    sign_up_team(db.session, event.name, user.name)

    subject = ('Signed up for the RAMP event {}'
               .format(event.name))
    body = ('{}, you have been registered to the RAMP event {}. '
            'You can now proceed to your sandbox and make submissions.'
            '\nHave fun!!!'.format(user.name, event.name))
    send_mail(to=user.email, subject=subject, body=body)

    return redirect_to_user('{} is signed up for {}.'.format(user, event),
                            is_error=False, category='Successful sign-up')
github paris-saclay-cds / ramp-board / ramp-frontend / ramp_frontend / views / ramp.py View on Github external
new_submission.name, event_team))
            if event.is_send_submitted_mails:
                admin_users = User.query.filter_by(access_level='admin')
                for admin in admin_users:
                    subject = 'Submission {} sent for training'.format(
                        new_submission.name
                    )
                    body = """A new submission have been submitted:
                    event: {}
                    user: {}
                    submission: {}
                    submission path: {}
                    """.format(event_team.event.name,
                               flask_login.current_user.name,
                               new_submission.name, new_submission.path)
                    send_mail(admin.email, subject, body)
            if app.config['TRACK_USER_INTERACTION']:
                add_user_interaction(
                    db.session,
                    interaction='submit',
                    user=flask_login.current_user,
                    event=event,
                    submission=new_submission
                )

            return redirect_to_sandbox(
                event,
                '{} submitted {} for {}'
                .format(flask_login.current_user.firstname,
                        new_submission.name, event_team),
                is_error=False, category='Submission'
            )
github paris-saclay-cds / ramp-board / ramp-frontend / ramp_frontend / views / ramp.py View on Github external
number of students: {}
            waiting time between resubmission: {}:{}:{}
            opening data: {}
            closing data: {}
            """.format(
                flask_login.current_user.name,
                problem.name + '_' + form.suffix.data,
                form.title.data,
                form.n_students.data,
                form.min_duration_between_submissions_hour.data,
                form.min_duration_between_submissions_minute.data,
                form.min_duration_between_submissions_second.data,
                form.opening_date.data,
                form.closing_date.data
            )
            send_mail(admin.email, subject, body)
        return redirect_to_user(
            'Thank you. Your request has been sent to RAMP administrators.',
            category='Event request', is_error=False
        )

    return render_template('ask_for_event.html', form=form, problem=problem)