コード例 #1
0
ファイル: views.py プロジェクト: Kerram/oioioi
def all_submissions_view(request):
    submissions = []

    if request.user.is_authenticated:
        queryset = Submission.objects \
                .filter(user=request.user) \
                .order_by('-date') \
                .select_related('user', 'problem_instance',
                                'problem_instance__contest',
                                'problem_instance__round',
                                'problem_instance__problem')

        for s in queryset:
            request.contest = s.problem_instance.contest
            submissions.append(submission_template_context(request, s))
        request.contest = None
        show_scores = any(s['can_see_score'] for s in submissions)

    navbar_links = navbar_links_registry.template_context(request)

    return TemplateResponse(
        request, 'contests/my_submissions_all.html', {
            'submissions': submissions,
            'show_scores': show_scores,
            'submissions_on_page': getattr(settings, 'SUBMISSIONS_ON_PAGE',
                                           100),
            'navbar_links': navbar_links
        })
コード例 #2
0
ファイル: views.py プロジェクト: JacquesWhite/oioioi
def main_page_view(request):
    navbar_links = navbar_links_registry.template_context(request)

    to_show = getattr(settings, 'NUM_RECENT_CONTESTS', 7)
    rcontests = recent_contests(request)
    contests = list(visible_contests(request).difference(rcontests))
    contests.sort(key=lambda x: x.creation_date, reverse=True)
    contests = (rcontests + contests)[:to_show]

    submissions = []
    show_scores = False
    if request.user.is_authenticated:
        queryset = Submission.objects.filter(
            user=request.user).order_by('-date')

        # current_contest = request.contest
        #
        # for s in queryset:
        #     request.contest = "lakdnasdn"#s.problem_instance.contest
        #     submissions.append(submission_template_context(request, s))
        #
        # request.contest = current_contest

        to_show = getattr(settings, 'NUM_PANEL_SUBMISSIONS', 7)

        # limit queryset size, because filtering all submissions is slow
        queryset = queryset[:to_show]
        limit_queryset_ids = [submission.id for submission in queryset]
        queryset = Submission.objects.filter(
            id__in=limit_queryset_ids).select_related(
                'user',
                'problem_instance',
                'problem_instance__contest',
                'problem_instance__round',
                'problem_instance__problem',
            )

        submissions_list = filter_my_all_visible_submissions(request, queryset)

        if django.VERSION >= (1, 11):
            submissions_list = submissions_list.order_by('-date')
        else:
            submissions_list.sort(reverse=True, key=lambda s: s.date)

        submissions = [
            submission_template_context(request, s) for s in submissions_list
        ]

        show_scores = any(s['can_see_score'] for s in submissions)

    context = {
        'navbar_links': navbar_links,
        'contests': contests,
        'submissions': submissions,
        'show_scores': show_scores,
    }

    return TemplateResponse(request, 'main-page.html', context)
コード例 #3
0
ファイル: views.py プロジェクト: wczyz/oioioi
def main_page_view(request):
    navbar_links = navbar_links_registry.template_context(request)

    to_show = getattr(settings, 'NUM_RECENT_CONTESTS', 7)
    rcontests = recent_contests(request)
    contests = list(visible_contests(request).difference(rcontests))
    contests.sort(key=lambda x: x.creation_date, reverse=True)
    contests = (rcontests + contests)[:to_show]

    submissions = []
    show_scores = False
    if request.user.is_authenticated:
        queryset = Submission.objects \
            .filter(user=request.user) \
            .order_by('-date') \
            .select_related('user', 'problem_instance',
                            'problem_instance__contest',
                            'problem_instance__round',
                            'problem_instance__problem')

        # current_contest = request.contest
        #
        # for s in queryset:
        #     request.contest = "lakdnasdn"#s.problem_instance.contest
        #     submissions.append(submission_template_context(request, s))
        #
        # request.contest = current_contest

        submissions = [
            submission_template_context(request, s) for s in queryset
        ]

        to_show = getattr(settings, 'NUM_PANEL_SUBMISSIONS', 7)
        submissions = submissions[:to_show]
        show_scores = any(s['can_see_score'] for s in submissions)

    context = {
        'navbar_links': navbar_links,
        'contests': contests,
        'submissions': submissions,
        'show_scores': show_scores,
    }

    return TemplateResponse(request, 'main-page.html', context)
コード例 #4
0
ファイル: views.py プロジェクト: JacquesWhite/oioioi
def all_submissions_view(request):
    submissions = []

    if request.user.is_authenticated:
        queryset = Submission.objects.filter(user=request.user).select_related(
            'user',
            'problem_instance',
            'problem_instance__contest',
            'problem_instance__round',
            'problem_instance__problem',
        )

        submissions_list = filter_my_all_visible_submissions(request, queryset)

        if django.VERSION >= (1, 11):
            submissions_list = submissions_list.order_by('-date')
        else:
            submissions_list.sort(reverse=True, key=lambda s: s.date)

        for s in submissions_list:
            request.contest = s.problem_instance.contest
            submissions.append(submission_template_context(request, s))
        request.contest = None
        show_scores = any(s['can_see_score'] for s in submissions)

    navbar_links = navbar_links_registry.template_context(request)

    return TemplateResponse(
        request,
        'contests/my_submissions_all.html',
        {
            'submissions': submissions,
            'show_scores': show_scores,
            'submissions_on_page': getattr(settings, 'SUBMISSIONS_ON_PAGE',
                                           100),
            'navbar_links': navbar_links,
        },
    )
コード例 #5
0
ファイル: views.py プロジェクト: sio2project/oioioi
def all_submissions_view(request):
    submissions = []

    if request.user.is_authenticated:
        queryset = Submission.objects \
                .filter(user=request.user) \
                .order_by('-date') \
                .select_related('user', 'problem_instance',
                                'problem_instance__contest',
                                'problem_instance__round',
                                'problem_instance__problem')

        for s in queryset:
            request.contest = s.problem_instance.contest
            submissions.append(submission_template_context(request, s))
        request.contest = None
        show_scores = any(s['can_see_score'] for s in submissions)

    navbar_links = navbar_links_registry.template_context(request)

    return TemplateResponse(request, 'contests/my_submissions_all.html',
        {'submissions': submissions, 'show_scores': show_scores,
         'submissions_on_page': getattr(settings, 'SUBMISSIONS_ON_PAGE', 100),
         'navbar_links': navbar_links})
コード例 #6
0
ファイル: views.py プロジェクト: cytadela8/oioioi
def main_page_view(request):
    navbar_links = navbar_links_registry.template_context(request)
    context = {
        'navbar_links': navbar_links,
    }
    return TemplateResponse(request, 'main-page.html', context)