예제 #1
0
def edit_example(example_id):
    example = ExampleModel.get_by_id(example_id)
    form = ExampleForm(obj=example)
    if request.method == "POST":
        if form.validate_on_submit():
            example.example_name = form.data.get('example_name')
            example.example_description = form.data.get('example_description')
            example.put()
            flash(u'Example %s successfully saved.' % example_id, 'success')
            return redirect(url_for('list_examples'))
    return render_template('edit_example.html', example=example, form=form)
예제 #2
0
def edit_example(example_id):
    example = ExampleModel.get_by_id(example_id)
    form = ExampleForm(obj=example)

    if request.method == 'POST' and form.validate_on_submit():
        example.example_name = form.data.get('example_name')
        example.example_description = form.data.get('example_description')
        example.put()
        flash(u'Example %s successfully saved.' % example_id, 'success')
        return redirect(url_for('ExampleBP.list_examples'))

    return render('examples/edit.html', example=example, form=form)
예제 #3
0
def new_example():
    """Add a new example, detecting whether or not App Engine is in read-only mode."""
    form = ExampleForm()
    if form.validate_on_submit():
        example = ExampleModel(
                    example_id = form.example_id.data,
                    example_title = form.example_title.data,
                    added_by = users.get_current_user()
                    )
        try:
            example.put()
            flash(u'Example successfully saved.', 'success')
            return redirect(url_for('list_examples'))
        except CapabilityDisabledError:
            flash(u'App Engine Datastore is currently in read-only mode.', 'failure')
            return redirect(url_for('list_examples'))
    return render_template('new_example.html', form=form)
예제 #4
0
def list_examples():
    examples = ExampleModel.query()
    form = ExampleForm()

    if request.method == 'POST' and form.validate_on_submit():
        example = ExampleModel(example_name=form.example_name.data,
                               example_description=form.example_description.data,
                               added_by=users.get_current_user())

        try:
            example.put()
            example_id = example.key.id()
            flash(u'Example %s successfully saved.' % example_id, 'success')
        except CapabilityDisabledError:
            flash(u'App Engine Datastore is currently in read-only mode.', 'info')

        return redirect(url_for('ExampleBP.list_examples'))

    return render('examples/list.html', examples=examples, form=form)
예제 #5
0
def list_examples():
    examples = ExampleModel.query()
    form = ExampleForm()

    if request.method == 'POST' and form.validate_on_submit():
        example = ExampleModel(
            example_name=form.example_name.data,
            example_description=form.example_description.data,
            added_by=users.get_current_user())

        try:
            example.put()
            example_id = example.key.id()
            flash(u'Example %s successfully saved.' % example_id, 'success')
        except CapabilityDisabledError:
            flash(u'App Engine Datastore is currently in read-only mode.',
                  'info')

        return redirect(url_for('ExampleBP.list_examples'))

    return render('examples/list.html', examples=examples, form=form)