예제 #1
0
def create():
    """Create application."""
    form = ApplicationForm()
    if form.validate_on_submit():
        OAuthClient.create(user=current_user,
                           name=form.name.data,
                           desc=form.desc.data,
                           website=form.website.data,
                           redirect_uri=form.redirect_uri.data)
        flash(gettext('You have created an application!'), 'success')
        return redirect(url_for('.index'))
    return render_template('profile/applications/create.html', form=form)
예제 #2
0
def create():
    """Create application."""
    form = ApplicationForm()
    if form.validate_on_submit():
        OAuthClient.create(
            user=current_user,
            name=form.name.data,
            desc=form.desc.data,
            website=form.website.data,
            redirect_uri=form.redirect_uri.data,
        )
        flash(gettext("You have created an application!"), "success")
        return redirect(url_for(".index"))
    return render_template("profile/applications/create.html", form=form)
예제 #3
0
def edit(client_id):
    application = OAuthClient.query.get_or_404(client_id)
    if application.user != current_user:
        raise NotFound()
    form = ApplicationForm()
    if form.validate_on_submit():
        application.update(
            name=form.name.data, desc=form.desc.data, website=form.website.data, redirect_uri=form.redirect_uri.data
        )
        flash(gettext("You have updated an application!"), "success")
        return redirect(url_for(".index"))
    else:
        form.name.data = application.name
        form.desc.data = application.desc
        form.website.data = application.website
        form.redirect_uri.data = application.redirect_uri
    return render_template("profile/applications/edit.html", form=form)
예제 #4
0
def edit(client_id):
    application = OAuthClient.query.get_or_404(client_id)
    if application.user != current_user:
        raise NotFound()
    form = ApplicationForm()
    if form.validate_on_submit():
        application.update(name=form.name.data,
                           desc=form.desc.data,
                           website=form.website.data,
                           redirect_uri=form.redirect_uri.data)
        flash(gettext("You have updated an application!"), 'success')
        return redirect(url_for('.index'))
    else:
        form.name.data = application.name
        form.desc.data = application.desc
        form.website.data = application.website
        form.redirect_uri.data = application.redirect_uri
    return render_template('profile/applications/edit.html', form=form)