Exemple #1
0
def problem_site_external_statement_view(request, site_key):
    problem = get_object_or_404(Problem, problemsite__url_key=site_key)
    statement = query_statement(problem.id)
    if statement.extension == '.zip' \
            and not can_admin_problem(request, problem):
        raise PermissionDenied
    return stream_file(statement.content, statement.download_name)
Exemple #2
0
def problem_statement_view(request, problem_instance):
    controller = request.contest.controller
    pi = get_object_or_404(
        ProblemInstance, round__contest=request.contest, short_name=problem_instance
    )

    if not controller.can_see_problem(request, pi) or not controller.can_see_statement(
        request, pi
    ):
        raise PermissionDenied

    if not pi.problem.controller.supports_problem_statement():
        # if the problem doesn't support having a problem statement,
        # redirect to submission
        return redirect('submit', problem_instance_id=pi.id)

    statement = query_statement(pi.problem)

    if not statement:
        return TemplateResponse(
            request, 'contests/no_problem_statement.html', {'problem_instance': pi}
        )

    if statement.extension == '.zip':
        return redirect(
            'problem_statement_zip_index',
            contest_id=request.contest.id,
            problem_instance=problem_instance,
            statement_id=statement.id,
        )
    return stream_file(statement.content, statement.download_name)
Exemple #3
0
def problem_site_external_statement_view(request, site_key):
    problem = get_object_or_404(Problem, problemsite__url_key=site_key)
    statement = query_statement(problem.id)
    if statement.extension == '.zip' \
            and not can_admin_problem(request, problem):
        raise PermissionDenied
    return stream_file(statement.content, statement.download_name)
Exemple #4
0
def problem_statement_view(request, problem_instance):
    controller = request.contest.controller
    pi = get_object_or_404(ProblemInstance, round__contest=request.contest,
            short_name=problem_instance)

    if not controller.can_see_problem(request, pi) or \
            not controller.can_see_statement(request, pi):
        raise PermissionDenied

    if not pi.problem.controller.supports_problem_statement():
        # if the problem doesn't support having a problem statement,
        # redirect to submission
        return redirect('submit', problem_instance_id=pi.id)

    statement = query_statement(pi.problem)

    if not statement:
        return TemplateResponse(request, 'contests/no_problem_statement.html',
                    {'problem_instance': pi})

    if statement.extension == '.zip':
        return redirect('problem_statement_zip_index',
                contest_id=request.contest.id,
                problem_instance=problem_instance, statement_id=statement.id)
    return stream_file(statement.content, statement.download_name)
Exemple #5
0
def problem_site_statement(request, problem):
    statement = query_statement(problem.id)
    if not statement:
        statement_html = render_to_string("problems/no_problem_statement.html", {"problem": problem})
    elif statement.extension == ".zip":
        response = problem_site_statement_zip_view(request, problem.problemsite.url_key, "index.html")
        statement_html = mark_safe(response.content)
    else:
        statement_url = reverse("problem_site_external_statement", kwargs={"site_key": problem.problemsite.url_key})
        statement_html = render_to_string(
            "problems/external_statement.html", {"problem": problem, "statement_url": statement_url}
        )

    return statement_html
Exemple #6
0
def problem_site_statement(request, problem):
    statement = query_statement(problem.id)
    if not statement:
        statement_html = render_to_string(
                'problems/no-problem-statement.html',
                {'problem': problem})
    elif statement.extension == '.zip':
        response = problem_site_statement_zip_view(request,
                problem.problemsite.url_key, 'index.html')
        statement_html = mark_safe(response.content)
    else:
        statement_url = reverse('problem_site_external_statement',
                kwargs={'site_key': problem.problemsite.url_key})
        statement_html = render_to_string(
                'problems/external-statement.html',
                {'problem': problem, 'statement_url': statement_url})

    return statement_html
Exemple #7
0
def problem_site_statement(request, problem):
    statement = query_statement(problem.id)
    if not statement:
        statement_html = render_to_string(
                'problems/no-problem-statement.html',
                {'problem': problem})
    elif statement.extension == '.zip':
        response = problem_site_statement_zip_view(request,
                problem.problemsite.url_key, 'index.html')
        statement_html = mark_safe(response.content)
    else:
        statement_url = reverse('problem_site_external_statement',
                kwargs={'site_key': problem.problemsite.url_key})
        statement_html = render_to_string(
                'problems/external-statement.html',
                {'problem': problem, 'statement_url': statement_url})

    return statement_html
Exemple #8
0
def problem_statement_view(request, problem_instance):
    controller = request.contest.controller
    pi = get_object_or_404(ProblemInstance, round__contest=request.contest,
            short_name=problem_instance)

    if not controller.can_see_problem(request, pi) or \
            not controller.can_see_statement(request, pi):
        raise PermissionDenied

    statement = query_statement(pi.problem)

    if not statement:
        return TemplateResponse(request, 'contests/no_problem_statement.html',
                    {'problem_instance': pi})

    if statement.extension == '.zip':
        return redirect('problem_statement_zip_index',
                contest_id=request.contest.id,
                problem_instance=problem_instance, statement_id=statement.id)
    return stream_file(statement.content)
Exemple #9
0
def problem_statement_view(request, problem_instance):
    controller = request.contest.controller
    pi = get_object_or_404(ProblemInstance, round__contest=request.contest,
            short_name=problem_instance)

    if not controller.can_see_problem(request, pi) or \
            not controller.can_see_statement(request, pi):
        raise PermissionDenied

    statement = query_statement(pi.problem)

    if not statement:
        return TemplateResponse(request, 'contests/no_problem_statement.html',
                    {'problem_instance': pi})

    if statement.extension == '.zip':
        return redirect('problem_statement_zip_index',
                contest_id=request.contest.id,
                problem_instance=problem_instance, statement_id=statement.id)
    return stream_file(statement.content, statement.download_name)
Exemple #10
0
def problem_site_statement_zip_view(request, site_key, path):
    problem = get_object_or_404(Problem, problemsite__url_key=site_key)
    statement = query_statement(problem.id)
    return query_zip(statement, path)
Exemple #11
0
def problem_site_statement_zip_view(request, site_key, path):
    problem = get_object_or_404(Problem, problemsite__url_key=site_key)
    statement = query_statement(problem.id)
    return query_zip(statement, path)