Beispiel #1
0
def create_item(_id):
    """creates an item"""
    page_title = "Add"
    form = TextForm(request.form)
    if request.method == 'POST' and form.validate():
        item_name = form.title.data
        description = form.body.data
        User.create_item(_id, item_name, description)
        flash(' You have created a bucketlist item', 'success')
        return redirect(url_for('bucketlist_items', _id=_id))
    return render_template('add_item.html', form=form, title=page_title)
Beispiel #2
0
def create_bucketlist():
    """creates a bucketlist"""
    page_title = "Add"
    form = TextForm(request.form)
    user = User(session['username'], session['email'], session['password'],
                session['id'])
    if request.method == 'POST' and form.validate():
        title = form.title.data
        intro = form.body.data
        user.create_bucketlist(title, intro)
        flash(' You have created a bucketlist', 'success')
        return redirect(url_for('dashboard'))
    return render_template('create.html', form=form, title=page_title)
Beispiel #3
0
def edit_bucketlist(_id):
    """method lets the user  edit existing buckelists"""
    page_title = "Edit"
    index_ = Data.get_index(_id, Data.bucketlists)
    form = TextForm(request.form)

    form.title.data = Data.bucketlists[index_]['title']
    form.body.data = Data.bucketlists[index_]['intro']

    if request.method == 'POST' and form.validate():
        title = request.form['title']
        intro = request.form['body']
        Data.bucketlists[index_]['title'] = title
        Data.bucketlists[index_]['intro'] = intro
        flash('Your Bucketlist has been updated', 'success')
        return redirect(url_for('dashboard'))
    return render_template('create.html', form=form, title=page_title)
Beispiel #4
0
def edit_bucketlist_item(_id):
    """method lets the user  edit existing buckelists"""
    page_title = "Edit"
    index_ = Data.get_index(_id, Data.items)
    form = TextForm(request.form)

    #    ### populating the form for user to edit ###

    form.title.data = Data.items[index_]['item_name']
    form.body.data = Data.items[index_]['description']

    if request.method == 'POST' and form.validate():
        title = request.form['title']
        intro = request.form['body']
        Data.items[index_]['item_name'] = title
        Data.items[index_]['description'] = intro
        flash('Your Item has been updated', 'success')
        return redirect(
            url_for('bucketlist_items', _id=Data.items[index_]['owner_id']))
    return render_template('add_item.html', form=form, title=page_title)