Exemple #1
0
def show_user_details(scholar_id):
    """Return page showing the details of a scholar's history."""

    # queries database for scholar information by id
    scholar_data = User.query.filter(User.user_id == scholar_id).first()

    # queries database for all ratings by the scholar by scholar id
    user_ratings_list = Rating.query.filter(Rating.user_id == scholar_id).all()

    # query for badge data for the current reading session.
    badge_data = Badge.query.filter(
        Badge.badge_id == session['session_badge']).first()

    # calculates how many of different badges were earned
    badges_dict = calculates_total_badges(badges_list, user_ratings_list)

    # calculates total time reading
    total_time = calculates_total_reading_time(user_ratings_list)

    # collects individual book ratings
    book_rating_dict = tally_book_ratings(book_list, user_ratings_list)

    flash("You worked hard %s !" % session['first_name'])

    return render_template("user_details.html",
                           today_date=today_date,
                           avatar=scholar_data.avatar,
                           user_details=scholar_data,
                           badge_id=session['session_badge'],
                           time_length=session['time'],
                           user_ratings_list=user_ratings_list,
                           time=total_time,
                           badges_dict=badges_dict,
                           badge_data=badge_data,
                           book_rating_dict=book_rating_dict)
Exemple #2
0
def books_data():
    """Return chart data about scholar's reading history."""
    
    user_ratings_list = Rating.query.filter(Rating.user_id == session['scholar_id']).all()

    book_rating_dict = tally_book_ratings(book_list, user_ratings_list)

    books_data = format_chart_colors(book_rating_dict)
    
    return jsonify(books_data)
Exemple #3
0
def books_data():
    """Return chart data about scholar's reading history."""

    user_ratings_list = Rating.query.filter(
        Rating.user_id == session['scholar_id']).all()

    book_rating_dict = tally_book_ratings(book_list, user_ratings_list)

    books_data = format_chart_colors(book_rating_dict)

    return jsonify(books_data)
Exemple #4
0
def show_user_details(scholar_id):
    """Return page showing the details of a scholar's history."""
    
    # queries database for scholar information by id
    scholar_data = User.query.filter(User.user_id == scholar_id).first()
    
    # queries database for all ratings by the scholar by scholar id
    user_ratings_list = Rating.query.filter(Rating.user_id == scholar_id).all()
    
    # query for badge data for the current reading session.
    badge_data = Badge.query.filter(Badge.badge_id == session['session_badge']).first()

    # calculates how many of different badges were earned
    badges_dict = calculates_total_badges(badges_list, user_ratings_list)


    # calculates total time reading
    total_time = calculates_total_reading_time(user_ratings_list)

    # collects individual book ratings
    book_rating_dict = tally_book_ratings(book_list, user_ratings_list)


    flash("You worked hard %s !" % session['first_name'])
    
    return render_template("user_details.html",
                           today_date=today_date,
                           avatar=scholar_data.avatar,
                           user_details=scholar_data,
                           badge_id=session['session_badge'],
                           time_length = session['time'],
                           user_ratings_list=user_ratings_list,
                           time=total_time,
                           badges_dict=badges_dict,
                           badge_data=badge_data,
                           book_rating_dict=book_rating_dict)