예제 #1
0
def problem_site_add_to_contest(request, problem):
    administered = administered_contests(request)
    administered = sorted(administered,
        key=lambda x: x.creation_date, reverse=True)
    return TemplateResponse(request, 'problems/add-to-contest.html',
                            {'site_key': problem.problemsite.url_key,
                             'contests': administered})
예제 #2
0
def problemset_add_to_contest_view(request, site_key):
    problem_name = request.GET.get('problem_name')
    if not problem_name:
        raise Http404
    administered = administered_contests(request)
    administered = sorted(administered,
                          key=lambda x: x.creation_date,
                          reverse=True)
    navbar_links = navbar_links_registry.template_context(request)
    problemset_tabs = generate_problemset_tabs(request)
    problemset_tabs.append({
        'name':
        _('Add to contest'),
        'url':
        reverse('problemset_add_to_contest', kwargs={'site_key': site_key}),
    })
    return TemplateResponse(
        request,
        'problems/problemset/select-contest.html',
        {
            'site_key': site_key,
            'administered_contests': administered,
            'problem_name': problem_name,
            'navbar_links': navbar_links,
            'problemset_tabs': problemset_tabs,
        },
    )
예제 #3
0
파일: views.py 프로젝트: sio2project/oioioi
def problemset_add_to_contest_view(request, site_key):
    problem_name = request.GET.get('problem_name')
    if not problem_name:
        raise Http404
    administered = administered_contests(request)
    administered = sorted(administered,
        key=lambda x: x.creation_date, reverse=True)
    return TemplateResponse(request, 'problems/problemset/select-contest.html',
                            {'site_key': site_key,
                             'administered_contests': administered,
                             'problem_name': problem_name})
예제 #4
0
def problemset_add_to_contest_view(request, site_key):
    problem_name = request.GET.get('problem_name')
    if not problem_name:
        raise Http404
    administered = administered_contests(request)
    administered = sorted(administered,
        key=lambda x: x.creation_date, reverse=True)
    return TemplateResponse(request, 'problems/problemset/select-contest.html',
                            {'site_key': site_key,
                             'administered_contests': administered,
                             'problem_name': problem_name})
예제 #5
0
파일: views.py 프로젝트: sio2project/oioioi
def problemset_add_to_contest_view(request, site_key):
    problem_name = request.GET.get("problem_name")
    if not problem_name:
        raise Http404
    administered = administered_contests(request)
    administered = sorted(administered, key=lambda x: x.creation_date, reverse=True)
    return TemplateResponse(
        request,
        "problems/problemset/select_contest.html",
        {"site_key": site_key, "administered_contests": administered, "problem_name": problem_name},
    )
예제 #6
0
파일: views.py 프로젝트: sio2project/oioioi
def _generate_add_to_contest_metadata(request):
    administered = administered_contests(request)
    # If user doesn't own any contest we won't show the option.
    if administered:
        show_add_button = True
    else:
        show_add_button = False
    # We want to show administered recent contests, because
    # these are most likely to be picked by an user.
    rcontests = recent_contests(request)
    administered_recent_contests = None
    if rcontests:
        administered_recent_contests = [
            contest for contest in rcontests if request.user.has_perm("contests.contest_admin", contest)
        ]
    return show_add_button, administered_recent_contests
예제 #7
0
def problem_site_add_to_contest(request, problem):
    administered = administered_contests(request)
    administered = sorted(administered,
                          key=lambda x: x.creation_date,
                          reverse=True)
    tests_package = TestsPackage.objects.filter(problem=problem)
    tests_package_visible = any(
        [tp.is_visible(request.timestamp) for tp in tests_package])
    return TemplateResponse(
        request,
        'problems/add-to-contest.html',
        {
            'site_key': problem.problemsite.url_key,
            'contests': administered,
            'tests_package_visible': tests_package_visible,
        },
    )
예제 #8
0
파일: views.py 프로젝트: AdiNar/oioioi
def _generate_add_to_contest_metadata(request):
    administered = administered_contests(request)
    # If user doesn't own any contest we won't show the option.
    if administered:
        show_add_button = True
    else:
        show_add_button = False
    # We want to show administered recent contests, because
    # these are most likely to be picked by an user.
    rcontests = recent_contests(request)
    administered_recent_contests = None
    if rcontests:
        administered_recent_contests = \
            [contest
             for contest in rcontests
             if request.user.has_perm('contests.contest_admin', contest)]
    return show_add_button, administered_recent_contests
예제 #9
0
def generate_add_to_contest_metadata(request):
    """This generates all metadata needed for
    "add to contest" functionality in problemset.
    """

    administered = administered_contests(request)
    # If user doesn't own any contest we won't show the option.
    if administered:
        show_add_button = True
    else:
        show_add_button = False
    # We want to show administered recent contests, because
    # these are most likely to be picked by an user.
    rcontests = recent_contests(request)
    administered_recent_contests = None
    if rcontests:
        administered_recent_contests = [
            contest
            for contest in rcontests
            if request.user.has_perm('contests.contest_admin', contest)
        ]
    return show_add_button, administered_recent_contests