示例#1
0
def listDetailView(list_id):
    ''' View details for a single list
    '''
    thelist, list_owner = get_list_with_permission(list_id, session['user_id'])
    items = Item.fetch_all(list_id=list_id)
    rendered_items =\
        [render_html('wishlist/item/view.html', item=item, list_owner=list_owner)  # noqa
            for item in items]
    quick_add_form = render_html(
        'wishlist/item/quick_add.html',
        list_id=list_id
    )
    return render_template(
        'list-detail.html',
        thelist=thelist,
        items=rendered_items,
        quick_add_form=quick_add_form,
        list_owner=list_owner
    )
示例#2
0
def createItemView(list_id):
    ''' View for adding a new item to an existing list
    '''
    thelist, list_owner = get_list_with_permission(list_id, session['user_id'])
    new_item = request.form.to_dict()
    new_item.update({'list_id': list_id, })
    status = None
    message = None
    item_result = None
    item_id = None
    try:
        item = Item.create(new_item)
        status = 'ok'
        message = 'added item to list'
        item_id = item.id
        item_result = render_html(
            'wishlist/item/view.html',
            item=item,
            list_owner=list_owner
        )
    except Exception, e:
        status = 'error'
        message = str(e)