def get_top_rated(topN): items = get_all_fragrances() items = sort(items, 'rating') if len(items) < topN: return items else: items = items[:topN] return items
def get_trend_favors(topN): items = get_all_fragrances() items = sort(items, 'favors') if len(items) < topN: return items else: items = items[:topN] return items
def get_most_reviews(topN): items = get_all_fragrances() items = sort(items, 'reviews') if len(items) < topN: return items else: items = items[:topN] return items
def list(): items = get_all_fragrances() items = sort(items, 'name') if 'account' in session: account = session['account'] table = get_table('Users') try: response = table.get_item(Key={'account': account}) except ClientError as e: raise e else: user = response['Item'] return render_template('list.html', name=user['name'], items=items, viewAll=True) else: return render_template('list.html', items=items, viewAll=True)
def list_sort(): sortBy = request.form.get('sortBy', "name") items = get_all_fragrances() items = sort(items, sortBy) if 'account' not in session: return render_template('list.html', items=items, sortBy=sortBy, viewAll=True) else: account = session['account'] table = get_table('Users') try: response = table.get_item(Key={'account': account}) except ClientError as e: raise e else: user = response['Item'] return render_template('list.html', name=user['name'], items=items, sortBy=sortBy, viewAll=True)