oioioi.problems.models¶
Module Contents¶
Classes¶
Represents a problem in the problems database. |
|
Represents a problem's name translation in a given language. |
|
Represents a file containing problem statement. |
|
Represents an additional file visible to the contestant, linked to |
|
Represents a file with data necessary for creating a |
|
Represents a global problem site. |
|
Make subclasses preserve the alters_data attribute on overridden methods. |
|
Make subclasses preserve the alters_data attribute on overridden methods. |
|
Make subclasses preserve the alters_data attribute on overridden methods. |
|
OriginTags are used along with OriginInfoCategories and OriginInfoValue |
|
Make subclasses preserve the alters_data attribute on overridden methods. |
|
This class represents a category of information, which further specifies |
|
Make subclasses preserve the alters_data attribute on overridden methods. |
|
This class represents additional information, further specifying |
|
Make subclasses preserve the alters_data attribute on overridden methods. |
|
Make subclasses preserve the alters_data attribute on overridden methods. |
|
Make subclasses preserve the alters_data attribute on overridden methods. |
|
Make subclasses preserve the alters_data attribute on overridden methods. |
|
Make subclasses preserve the alters_data attribute on overridden methods. |
|
Make subclasses preserve the alters_data attribute on overridden methods. |
|
Make subclasses preserve the alters_data attribute on overridden methods. |
|
Make subclasses preserve the alters_data attribute on overridden methods. |
|
Make subclasses preserve the alters_data attribute on overridden methods. |
Functions¶
|
|
|
|
|
|
|
|
|
Truncates string to be length bytes long. |
|
Some models may have fields with language-specific data, which cannot be |
Attributes¶
- class oioioi.problems.models.Problem(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelRepresents a problem in the problems database.
Instances of
Problemdo not represent problems in contests, seeoioioi.contests.models.ProblemInstancefor those.Each
Problemhas associated mainoioioi.contests.models.ProblemInstance, called main_problem_instance: 1) It is not assigned to any contest. 2) It allows sending submissions aside from contests. 3) It is a base to create another instances.- classmethod create(*args, **kwargs)[source]¶
Creates a new
Problemobject, with associated main_problem_instance.After the call, the
Problemand theProblemInstanceobjects will be saved in the database.
- save(*args, **kwargs)[source]¶
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- class oioioi.problems.models.ProblemName(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelRepresents a problem’s name translation in a given language.
Problem should have its name translated to all available languages.
- class oioioi.problems.models.ProblemStatement(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelRepresents a file containing problem statement.
Problem may have multiple statements, for example in various languages or formats. Formats should be detected according to filename extension of
content.
- class oioioi.problems.models.ProblemAttachment(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelRepresents an additional file visible to the contestant, linked to a problem.
This may be used for things like input data for open data tasks, or for giving users additional libraries etc.
- oioioi.problems.models.truncate_unicode(string, length, encoding='utf-8')[source]¶
Truncates string to be length bytes long.
- class oioioi.problems.models.ProblemPackage(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelRepresents a file with data necessary for creating a
Probleminstance.- save_operation_status()[source]¶
Returns a context manager to be used during the unpacking process.
The code inside the
withstatment is executed in a transaction.If the code inside the
withstatement executes successfully, the packagestatusfield is set toOK.If an exception is thrown, it gets logged together with the traceback. Additionally, its value is saved in the package
infofield.Lastly, if the package gets deleted from the database before the
withstatement ends, aoioioi.problems.models.ProblemPackage.DoesNotExistexception is thrown.
- class oioioi.problems.models.ProblemSite(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelRepresents a global problem site.
Contains configuration necessary to view and submit solutions to a
Problem.
- class oioioi.problems.models.MainProblemInstance(*args, **kwargs)[source]¶
Bases:
oioioi.contests.models.ProblemInstanceMake subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.ProblemStatistics(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelMake subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.UserStatistics(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelMake subclasses preserve the alters_data attribute on overridden methods.
- oioioi.problems.models._localized(*localized_fields)[source]¶
Some models may have fields with language-specific data, which cannot be translated through the normal internalization tools, as it is not defined in the source code (e.g. names of dynamically defined items).
- Decorate a class with this decorator when there exists a class that:
has a ForeignKey to the decorated class with a related_name of localizations.
has a language field, and all of localized_fields.
The localized_fields can then be accessed directly through the decorated class, and will be matched to the current language.
Be sure to use prefetch_related(‘localizations’) if you will be querying multiple localized model instances!
Also see: LocalizationForm
- class oioioi.problems.models.OriginTag(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelOriginTags are used along with OriginInfoCategories and OriginInfoValue to give information about the problem’s origin. OriginTags themselves represent general information about a problem’s origin, whereas OriginInfoValues grouped under OriginInfoCategories represent more specific information. A Problem should probably not have more than one OriginTag, and should probably have one OriginInfoValue for each category.
See also: OriginInfoCategory, OriginInfoValue
- class oioioi.problems.models.OriginTagLocalization(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelMake subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.OriginInfoCategory(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelThis class represents a category of information, which further specifies what its parent_tag is already telling about the origin. It doesn’t do much by itself and is instead used to group OriginInfoValues by category
See also: OriginTag, OriginInfoValue
- class oioioi.problems.models.OriginInfoCategoryLocalization(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelMake subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.OriginInfoValue(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelThis class represents additional information, further specifying what its parent_tag is already telling about the origin. Each OriginInfoValue has a category, in which it should be unique, and problems should only have one OriginInfoValue within any category.
See alse: OriginTag, OriginInfoCategory
- class oioioi.problems.models.OriginInfoValueLocalization(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelMake subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.DifficultyTag(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelMake subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.DifficultyTagThrough(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelMake subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.DifficultyTagLocalization(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelMake subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.DifficultyTagProposal(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelMake subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.AlgorithmTag(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelMake subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.AlgorithmTagThrough(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelMake subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.AlgorithmTagLocalization(*args, **kwargs)[source]¶
Bases:
django.db.models.ModelMake subclasses preserve the alters_data attribute on overridden methods.