示例#1
0
def collections(username):
    # Get the user who's page is being viewed
    user = User.query.filter_by(username=username).first_or_404()
    
    # Get the statistics of the user's collections
    num_collections, num_items = user.collection_statistics

    # Get a preview of the user's collections
    collections = User.query.collection_preview(user.id)
    
    return render_template("user.html",
                           user=user,
                           num_collections=num_collections,
                           num_items=num_items,
                           collections=collections,
                           photo_base_url=photos.url(""))
示例#2
0
def item_summary(safe_id, slug):
    # Get the item and the id of the owner
    item = Item.query.filter_by(safe_id=safe_id).first_or_404()
    
    # Get the user who owns this item and their statistics
    user = User.query.get_or_404(item.collection.user_id)
    num_collections, num_items = user.collection_statistics

    # Setup flags to for controlling conditional elements on the ui
    logged_in = session.get('logged_in')
    is_owner = (user.username == session.get('username'))
    has_voted = False

    return render_template("item.html",
                           user=user,
                           num_collections=num_collections,
                           num_items=num_items,
                           item=item,
                           logged_in=logged_in,
                           is_owner=is_owner,
                           has_voted=has_voted,
                           photo_base_url=photos.url(""))