Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 5
0
def edit(client_id):
    try:
        application = db_oauth_client.get_client(client_id)
    except db_exceptions.NoDataFoundException:
        raise NotFound()
    if str(application["user_id"]) != current_user.id:
        raise NotFound()
    form = ApplicationForm()
    if form.validate_on_submit():
        db_oauth_client.update(
            client_id=application["client_id"],
            name=form.name.data,
            desc=form.desc.data,
            website=form.website.data,
            redirect_uri=form.redirect_uri.data,
        )
        flash.success(gettext("You have updated an application!"))
        return redirect(url_for('.index'))

    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)