oioioi.problems.problem_sources¶
Module Contents¶
Classes¶
Functions¶
|
Attributes¶
- class oioioi.problems.problem_sources.ProblemSource[source]¶
Bases:
object- 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.TemplateResponseis fine, too.If the request method is
POST, it should start the unpacking process. If no errors occur, it should returnHttpResponseRedirect(e.g. to a view with problem packages queued for processing).
- class oioioi.problems.problem_sources.PackageSource[source]¶
Bases:
ProblemSource- 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), wherefilenameis the original name of the file specified by the user andfile_manageris a context manager. Thisfile_managerwill be later used like this:Moreover,
file_managershould take care of unlinking the file if this is necessary.The
filenamemay beNoneif the name of the file returned by thefile_managerends 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
ProblemPackageBackendsuitable 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
ProblemPackageinstance 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().
- 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.TemplateResponseis fine, too.If the request method is
POST, it should start the unpacking process. If no errors occur, it should returnHttpResponseRedirect(e.g. to a view with problem packages queued for processing).
- 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), wherefilenameis the original name of the file specified by the user andfile_manageris a context manager. Thisfile_managerwill be later used like this:Moreover,
file_managershould take care of unlinking the file if this is necessary.The
filenamemay beNoneif the name of the file returned by thefile_managerends with an appropriate extension (so that it is possible to choose the right backend for it).
- class oioioi.problems.problem_sources.ProblemsetSource[source]¶
Bases:
ProblemSource- 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.TemplateResponseis fine, too.If the request method is
POST, it should start the unpacking process. If no errors occur, it should returnHttpResponseRedirect(e.g. to a view with problem packages queued for processing).