Example #1
0
def categories_route():
    """
    List of all categories
    """
    return render_template('categories.html',
                           page={'title': 'Categories'},
                           user=user_info(),
                           content={'categories': get_categories()})
Example #2
0
def index_route():
    # Homepage for web interface
    return render_template('index.html',
                           page={
                               'title': 'Catalog Application Homepage',
                               'has_sidebar': True
                           },
                           user=user_info(),
                           content={'categories': get_categories()})
Example #3
0
def profile_route():
    # Shows user information on the page
    user = user_info()

    if not user_is_authorized():
        return redirect(url_for('login_route'))

    return render_template('profile.html',
                           page={'title': user['name'] + ' profile'},
                           user=user,
                           content={'categories': get_categories()})
Example #4
0
def item_route(item_name):
    """
    Route that outputs item info
    """
    target_item = get_item(item_name)

    if target_item is None:
        flash('Item not found')
        # sending user to categories page for he has done
        return redirect(url_for('categories_route'))

    return render_template('item.html',
                           page={
                               'title': 'Item ' + target_item.name,
                               'has_sidebar': True
                           },
                           user=user_info(),
                           content={
                               'categories': get_categories(),
                               'item': target_item
                           })
Example #5
0
def category_route(category_name):
    """
    Outputing category info
    """
    target_category = get_category(category_name)
    print target_category

    # ooops category not found
    if target_category is None:
        abort(404)

    return render_template('category.html',
                           page={
                               'title': 'Category ' + target_category.name,
                               'has_sidebar': True
                           },
                           user=user_info(),
                           content={
                               'categories': get_categories(),
                               'category': target_category
                           })