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.Model
Represents a problem in the problems database.
Instances of
Problem
do not represent problems in contests, seeoioioi.contests.models.ProblemInstance
for those.Each
Problem
has 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
Problem
object, with associated main_problem_instance.After the call, the
Problem
and theProblemInstance
objects 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.Model
Represents 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.Model
Represents 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.Model
Represents 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.Model
Represents a file with data necessary for creating a
Problem
instance.- save_operation_status()[source]¶
Returns a context manager to be used during the unpacking process.
The code inside the
with
statment is executed in a transaction.If the code inside the
with
statement executes successfully, the packagestatus
field is set toOK
.If an exception is thrown, it gets logged together with the traceback. Additionally, its value is saved in the package
info
field.Lastly, if the package gets deleted from the database before the
with
statement ends, aoioioi.problems.models.ProblemPackage.DoesNotExist
exception is thrown.
- class oioioi.problems.models.ProblemSite(*args, **kwargs)[source]¶
Bases:
django.db.models.Model
Represents 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.ProblemInstance
Make subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.ProblemStatistics(*args, **kwargs)[source]¶
Bases:
django.db.models.Model
Make subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.UserStatistics(*args, **kwargs)[source]¶
Bases:
django.db.models.Model
Make 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.Model
OriginTags 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.Model
Make subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.OriginInfoCategory(*args, **kwargs)[source]¶
Bases:
django.db.models.Model
This 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.Model
Make subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.OriginInfoValue(*args, **kwargs)[source]¶
Bases:
django.db.models.Model
This 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.Model
Make subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.DifficultyTag(*args, **kwargs)[source]¶
Bases:
django.db.models.Model
Make subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.DifficultyTagThrough(*args, **kwargs)[source]¶
Bases:
django.db.models.Model
Make subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.DifficultyTagLocalization(*args, **kwargs)[source]¶
Bases:
django.db.models.Model
Make subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.DifficultyTagProposal(*args, **kwargs)[source]¶
Bases:
django.db.models.Model
Make subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.AlgorithmTag(*args, **kwargs)[source]¶
Bases:
django.db.models.Model
Make subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.AlgorithmTagThrough(*args, **kwargs)[source]¶
Bases:
django.db.models.Model
Make subclasses preserve the alters_data attribute on overridden methods.
- class oioioi.problems.models.AlgorithmTagLocalization(*args, **kwargs)[source]¶
Bases:
django.db.models.Model
Make subclasses preserve the alters_data attribute on overridden methods.