Ejemplo n.º 1
0
def delete_store(store_id):

    # Remove the store from the database
    Store.get_by_id(store_id).remove_from_mongo()

    # return the user to '/stores/'
    return redirect(url_for('.index'))
Ejemplo n.º 2
0
def edit_store(store_id):

    # Getting store from database
    store = Store.get_by_id(store_id)

    # If POST then edit form has been completed already
    # After store edit form saved, user redirected to '/stores/'
    if request.method == 'POST':
        name = request.form['name']
        url_prefix = request.form['url_prefix']
        tag_name = request.form['tag_name']
        query = json.loads(request.form['query'].replace("'", "\""))
        store.name = name
        store.url_prefix = url_prefix
        store.tag_name = tag_name
        store.query = query
        store.save_to_mongo()
        return redirect(url_for('.index'))

    # If no POST, then user is presented with the edit store form to be completed.
    return render_template('stores/edit_store.html', store=store)