예제 #1
0
def _send_message():
    _message = ModalMessage()
    if request.method == 'POST':
        if _message.validate_on_submit():
            send_message(sender=current_user.id, recipient=_message.recipient.data, subject=_message.subject.data,
                         body=_message.body.data)
        else:
            flash_errors(_message)
    return redirect(url_for('message.new'))
예제 #2
0
def new():
    _embedded = EmbeddedMessage()
    if request.method == 'POST':
        if _embedded.validate_on_submit():
            send_message(sender=current_user.id, recipient=_embedded.recipient.data,
                         subject=_embedded.subject.data,
                         body=_embedded.body.data)
            return redirect(url_for('message.sent'))
        else:
            flash_errors(_embedded)
    return render_template("message/new.html", _embedded=_embedded)
예제 #3
0
def login():
    form = LoginForm(request.form)
    if request.method == 'POST':
        if form.validate_on_submit():
            login_user(form.user)
            after_this_request(_commit)
            flash("You are now logged in.", 'success')
            if request.args.get("next"):
                return redirect(request.args.get("next"))
            else:
                return redirect(url_for('public.overview'))
        else:
            flash_errors(form)
    return render_template("public/login.html", form=form)
예제 #4
0
def register():
    form = RegisterForm(request.form, csrf_enabled=False)
    if form.validate_on_submit():
        default_role = user_datastore.find_role('Contractor')
        new_user = user_datastore.create_user(username=form.username.data,
                                              email=form.email.data,
                                              password=form.password.data)
        user_datastore.add_role_to_user(new_user, default_role)
        db.session.commit()
        flash("Thank you for registering. You can now log in.", 'success')
        return redirect(url_for('public.home'))
    else:
        flash_errors(form)
    return render_template('public/register.html', form=form)
예제 #5
0
def settings():
    form = EditProfile()
    user = User.query.filter_by(username=current_user.username).first()
    if request.method == 'POST':
        if form.validate_on_submit():
            current_user.email = form.email.data
            current_user.website = form.website.data
            current_user.organization = form.organization.data
            current_user.spectrum = form.spectrum.data
            current_user.handle = form.handle.data
            current_user.interests = form.interests.data
            db.session.add(user)
            db.session.commit()
            flash('Your settings has been updated.', 'info')
            return redirect(url_for('public.profile'))
        else:
            flash_errors(form)
    form.email.data = current_user.email
    form.website.data = current_user.website
    form.organization.data = current_user.organization
    form.spectrum.data = current_user.spectrum
    form.handle.data = current_user.handle
    form.interests.data = current_user.interests
    return render_template("public/profile.html", form=form)