Exemple #1
0
def delete_provider(provider_id):
    """Delete a provider object"""
    provider = ProviderModel.get_by_id(provider_id)
    try:
        provider.key.delete()
        flash(u'Provider %s successfully deleted.' % provider_id, 'success')
        return redirect(url_for('list_providers'))
    except CapabilityDisabledError:
        flash(u'App Engine Datastore is currently in read-only mode.', 'info')
        return redirect(url_for('list_providers'))
Exemple #2
0
def edit_provider(provider_id):
    provider = ProviderModel.get_by_id(provider_id)
    form = ProviderForm(obj=provider)
    if request.method == "POST":
        if form.validate_on_submit():
            provider.trading_name = form.data.get('trading_name')
            provider.phone_number = form.data.get('phone_number')
            provider.post_code = form.data.get('post_code')
            try:
                provider.put()
                provider_id = provider.key.id()
                flash(u'Provider %s successfully saved.' % provider_id, 'success')
                return redirect(url_for('list_providers'))
            except CapabilityDisabledError:
                flash(u'App Engine Datastore is currently in read-only mode.', 'info')
                return redirect(url_for('list_providers'))

    return render_template('edit_provider.html', provider=provider, form=form)