oioioi.problems.problem_sources

Module Contents

Classes

Functions

problem_sources(request[, existing_problem])

Attributes

oioioi.problems.problem_sources.logger[source]
oioioi.problems.problem_sources.problem_sources(request, existing_problem=False)[source]
class oioioi.problems.problem_sources.ProblemSource[source]

Bases: object

key = __override_in_a_subclass__[source]
short_description = __override_in_a_subclass__[source]
abstract view(request, contest, existing_problem=None)[source]

Renders the view where the user can upload the file or point out where to get the problem from.

If the request method is GET, it should return rendered HTML, which will be injected in an appropriate div element. TemplateResponse is fine, too.

If the request method is POST, it should start the unpacking process. If no errors occur, it should return HttpResponseRedirect (e.g. to a view with problem packages queued for processing).

Parameters
  • request – Django request

  • contestContest where the problem is going to be attached (or is already attached); may be None.

  • existing_problemProblem to update (if problem update was requested)

is_available(request)[source]

Returns True if the source is available for the given request.

class oioioi.problems.problem_sources.PackageSource[source]

Bases: ProblemSource

key = upload[source]
short_description[source]
template_name = problems/package-source.html[source]
abstract make_form(request, contest, existing_problem=None)[source]

Creates a form, which can be later filled in by the user with information necessary for obtaining the problem package.

If the request method is POST, then the form should be filled with its data.

abstract get_package_file(request, contest, form, existing_problem=None)[source]

Extracts the information from the validated form and returns the package file provided by the user.

Should return a pair (filename, file_manager), where filename is the original name of the file specified by the user and file_manager is a context manager. This file_manager will be later used like this:

Moreover, file_manager should take care of unlinking the file if this is necessary.

The filename may be None if the name of the file returned by the file_manager ends with an appropriate extension (so that it is possible to choose the right backend for it).

choose_backend(path, original_filename=None)[source]

Returns the dotted name of a ProblemPackageBackend suitable for processing a given package.

This function is called when an unpacking environment is created, i.e. from create_env().

create_package_instance(user, contest, path, existing_problem=None, original_filename=None)[source]

Creates a ProblemPackage instance from a given package file.

create_env(user, contest, path, package, form, round_id=None, visibility=Problem.VISIBILITY_FRIENDS, existing_problem=None, original_filename=None)[source]

Creates an environment which will be later passed to unpackmgr_job().

_redirect_response(request)[source]
handle_form(form, request, contest, existing_problem=None)[source]
process_package(request, file_manager, user, contest, original_filename=None, existing_problem=None, round_id=None, visibility=Problem.VISIBILITY_FRIENDS, form=None)[source]
view(request, contest, existing_problem=None)[source]

Renders the view where the user can upload the file or point out where to get the problem from.

If the request method is GET, it should return rendered HTML, which will be injected in an appropriate div element. TemplateResponse is fine, too.

If the request method is POST, it should start the unpacking process. If no errors occur, it should return HttpResponseRedirect (e.g. to a view with problem packages queued for processing).

Parameters
  • request – Django request

  • contestContest where the problem is going to be attached (or is already attached); may be None.

  • existing_problemProblem to update (if problem update was requested)

class oioioi.problems.problem_sources.UploadedPackageSource[source]

Bases: PackageSource

make_form(request, contest, existing_problem=None)[source]

Creates a form, which can be later filled in by the user with information necessary for obtaining the problem package.

If the request method is POST, then the form should be filled with its data.

get_package_file(request, contest, form, existing_problem=None)[source]

Extracts the information from the validated form and returns the package file provided by the user.

Should return a pair (filename, file_manager), where filename is the original name of the file specified by the user and file_manager is a context manager. This file_manager will be later used like this:

Moreover, file_manager should take care of unlinking the file if this is necessary.

The filename may be None if the name of the file returned by the file_manager ends with an appropriate extension (so that it is possible to choose the right backend for it).

is_available(request)[source]

Returns True if the source is available for the given request.

class oioioi.problems.problem_sources.ProblemsetSource[source]

Bases: ProblemSource

key = problemset_source[source]
short_description[source]
view(request, contest, existing_problem=None)[source]

Renders the view where the user can upload the file or point out where to get the problem from.

If the request method is GET, it should return rendered HTML, which will be injected in an appropriate div element. TemplateResponse is fine, too.

If the request method is POST, it should start the unpacking process. If no errors occur, it should return HttpResponseRedirect (e.g. to a view with problem packages queued for processing).

Parameters
  • request – Django request

  • contestContest where the problem is going to be attached (or is already attached); may be None.

  • existing_problemProblem to update (if problem update was requested)