Exemple #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})
Exemple #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,
        },
    )
Exemple #3
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})
Exemple #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})
Exemple #5
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},
    )
Exemple #6
0
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
Exemple #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,
        },
    )
Exemple #8
0
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
Exemple #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