Exemple #1
0
def get_profile(request, user):
    comment_count = Comment.objects.filter(user=user).count()
    problem_count = Problem.objects.filter(user=user, state=Problem.PUBLISHED).count()
    attempted_problem_count = Solver.objects.filter(user=user).count()
    all_problem_count = Problem.objects.filter(state=Problem.PUBLISHED).count()
    submission_chart = get_submission_chart_url(user)
    failed_problem_count = Solver.objects.filter(user=user, solved=False).count()
    category_chart = get_category_chart(user)
    actions = get_activities_for_user(request.user).filter(actor=user).order_by("-timestamp")[:20]
    rank = UserProfile.objects.filter(solved_problems__gt=
                                      user.get_profile().solved_problems).count()



    return render(request, "user_profile.html",
                  {"profile_user": user,
                   "post_count": user.get_profile().posts - comment_count,
                   "problem_count": problem_count,
                   "comment_count": comment_count,
                   "attempted_problem_count": attempted_problem_count,
                   "all_problem_count": all_problem_count,
                   "failed_problem_count": failed_problem_count,
                   "not_attempted_problem_count": all_problem_count - attempted_problem_count,
                   "submission_chart_url": submission_chart,
                   "submission_accepted_constant": Submission.ACCEPTED,
                   "category_chart_url": category_chart,
                   "actions": actions,
                   "oj_rank": rank+1,
                   "oj_rank_page": (rank / django_settings.ITEMS_PER_PAGE)+1,
                  })
Exemple #2
0
def get_profile(request, user):
    comment_count = Comment.objects.filter(user=user).count()
    problem_count = Problem.objects.filter(user=user,
                                           state=Problem.PUBLISHED).count()
    attempted_problem_count = Solver.objects.filter(user=user).count()
    all_problem_count = Problem.objects.filter(state=Problem.PUBLISHED).count()
    submission_chart = get_submission_chart_url(user)
    failed_problem_count = Solver.objects.filter(user=user,
                                                 solved=False).count()
    category_chart = get_category_chart(user)
    actions = get_activities_for_user(
        request.user).filter(actor=user).order_by("-timestamp")[:20]
    rank = UserProfile.objects.filter(
        solved_problems__gt=user.get_profile().solved_problems).count()

    return render(
        request, "user_profile.html", {
            "profile_user": user,
            "post_count": user.get_profile().posts - comment_count,
            "problem_count": problem_count,
            "comment_count": comment_count,
            "attempted_problem_count": attempted_problem_count,
            "all_problem_count": all_problem_count,
            "failed_problem_count": failed_problem_count,
            "not_attempted_problem_count":
            all_problem_count - attempted_problem_count,
            "submission_chart_url": submission_chart,
            "submission_accepted_constant": Submission.ACCEPTED,
            "category_chart_url": category_chart,
            "actions": actions,
            "oj_rank": rank + 1,
            "oj_rank_page": (rank / django_settings.ITEMS_PER_PAGE) + 1,
        })
Exemple #3
0
def index(request):
    news_category = Category.objects.get(slug='news')
    recent_news = Post.objects.filter(category=news_category).order_by('-modified_on')[0]
    recent_activity = get_activities_for_user(request.user).exclude(category='solved').order_by("-timestamp")
    recent_activity = recent_activity[:10].all()
    return render(request, "index.html",
                  {'title': u'알고스팟에 오신 것을 환영합니다!',
                   'news': recent_news,
                   'actions': recent_activity,
                  })
Exemple #4
0
def index(request):
    news_category = Category.objects.get(slug='news')
    recent_news = Post.objects.filter(
        category=news_category).order_by('-modified_on')[0]
    recent_activity = get_activities_for_user(
        request.user).exclude(category='solved').order_by("-timestamp")
    recent_activity = recent_activity[:10].all()
    return render(
        request, "index.html", {
            'title': u'알고스팟에 오신 것을 환영합니다!',
            'news': recent_news,
            'actions': recent_activity,
        })