oioioi.problems.models

Module Contents

Classes

Problem

Represents a problem in the problems database.

ProblemName

Represents a problem's name translation in a given language.

ProblemStatement

Represents a file containing problem statement.

ProblemAttachment

Represents an additional file visible to the contestant, linked to

ProblemPackage

Represents a file with data necessary for creating a

ProblemSite

Represents a global problem site.

MainProblemInstance

Make subclasses preserve the alters_data attribute on overridden methods.

ProblemStatistics

Make subclasses preserve the alters_data attribute on overridden methods.

UserStatistics

Make subclasses preserve the alters_data attribute on overridden methods.

OriginTag

OriginTags are used along with OriginInfoCategories and OriginInfoValue

OriginTagLocalization

Make subclasses preserve the alters_data attribute on overridden methods.

OriginInfoCategory

This class represents a category of information, which further specifies

OriginInfoCategoryLocalization

Make subclasses preserve the alters_data attribute on overridden methods.

OriginInfoValue

This class represents additional information, further specifying

OriginInfoValueLocalization

Make subclasses preserve the alters_data attribute on overridden methods.

DifficultyTag

Make subclasses preserve the alters_data attribute on overridden methods.

DifficultyTagThrough

Make subclasses preserve the alters_data attribute on overridden methods.

DifficultyTagLocalization

Make subclasses preserve the alters_data attribute on overridden methods.

DifficultyTagProposal

Make subclasses preserve the alters_data attribute on overridden methods.

AlgorithmTag

Make subclasses preserve the alters_data attribute on overridden methods.

AlgorithmTagThrough

Make subclasses preserve the alters_data attribute on overridden methods.

AlgorithmTagLocalization

Make subclasses preserve the alters_data attribute on overridden methods.

AlgorithmTagProposal

Make subclasses preserve the alters_data attribute on overridden methods.

Functions

make_problem_filename(instance, filename)

_call_controller_adjust_problem(sender, instance, raw, ...)

_check_problem_instance_integrity(sender, instance, ...)

_make_package_filename(instance, filename)

truncate_unicode(string, length[, encoding])

Truncates string to be length bytes long.

_localized(*localized_fields)

Some models may have fields with language-specific data, which cannot be

Attributes

oioioi.problems.models.logger[source]
oioioi.problems.models.make_problem_filename(instance, filename)[source]
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, see oioioi.contests.models.ProblemInstance for those.

Each Problem has associated main oioioi.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.

class Meta[source]

Bases: object

verbose_name[source]
verbose_name_plural[source]
permissions = [None, None][source]
property controller[source]
property package_backend[source]
legacy_name[source]
short_name[source]
controller_name[source]
contest[source]
author[source]
VISIBILITY_PUBLIC = PU[source]
VISIBILITY_FRIENDS = FR[source]
VISIBILITY_PRIVATE = PR[source]
VISIBILITY_LEVELS_CHOICES = [None, None, None][source]
visibility[source]
package_backend_name[source]
ascii_name[source]
main_problem_instance[source]
name()[source]
classmethod create(*args, **kwargs)[source]

Creates a new Problem object, with associated main_problem_instance.

After the call, the Problem and the ProblemInstance objects will be saved in the database.

__str__()[source]

Return str(self).

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.

oioioi.problems.models._call_controller_adjust_problem(sender, instance, raw, **kwargs)[source]
oioioi.problems.models._check_problem_instance_integrity(sender, instance, **kwargs)[source]
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 Meta[source]

Bases: object

unique_together = ['problem', 'language'][source]
verbose_name[source]
verbose_name_plural[source]
problem[source]
name[source]
language[source]
__str__()[source]

Return str(self).

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 Meta[source]

Bases: object

verbose_name[source]
verbose_name_plural[source]
property filename[source]
property download_name[source]
property extension[source]
problem[source]
language[source]
content[source]
__str__()[source]

Return str(self).

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.

class Meta[source]

Bases: object

verbose_name[source]
verbose_name_plural[source]
property filename[source]
property download_name[source]
problem[source]
description[source]
content[source]
__str__()[source]

Return str(self).

oioioi.problems.models._make_package_filename(instance, filename)[source]
oioioi.problems.models.package_statuses[source]
oioioi.problems.models.TRACEBACK_STACK_LIMIT = 100[source]
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.

class Meta[source]

Bases: object

verbose_name[source]
verbose_name_plural[source]
ordering = ['-creation_date'][source]
class StatusSaver(package)[source]

Bases: object

__enter__()[source]
__exit__(type, value, traceback)[source]
property download_name[source]
package_file[source]
contest[source]
problem[source]
created_by[source]
problem_name[source]
celery_task_id[source]
info[source]
traceback[source]
status[source]
creation_date[source]
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 package status field is set to OK.

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, a oioioi.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 Meta[source]

Bases: object

verbose_name[source]
verbose_name_plural[source]
problem[source]
url_key[source]
__str__()[source]

Return str(self).

class oioioi.problems.models.MainProblemInstance(*args, **kwargs)[source]

Bases: oioioi.contests.models.ProblemInstance

Make subclasses preserve the alters_data attribute on overridden methods.

class Meta[source]

Bases: object

proxy = True[source]
class oioioi.problems.models.ProblemStatistics(*args, **kwargs)[source]

Bases: django.db.models.Model

Make subclasses preserve the alters_data attribute on overridden methods.

problem[source]
user_statistics[source]
submitted[source]
solved[source]
avg_best_score[source]
_best_score_sum[source]
class oioioi.problems.models.UserStatistics(*args, **kwargs)[source]

Bases: django.db.models.Model

Make subclasses preserve the alters_data attribute on overridden methods.

class Meta[source]

Bases: object

unique_together = ['problem_statistics', 'user'][source]
problem_statistics[source]
user[source]
has_submitted[source]
has_solved[source]
best_score[source]
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 Meta[source]

Bases: object

verbose_name[source]
verbose_name_plural[source]
name[source]
problems[source]
__str__()[source]

Return str(self).

class oioioi.problems.models.OriginTagLocalization(*args, **kwargs)[source]

Bases: django.db.models.Model

Make subclasses preserve the alters_data attribute on overridden methods.

class Meta[source]

Bases: object

unique_together = ['origin_tag', 'language'][source]
verbose_name[source]
verbose_name_plural[source]
origin_tag[source]
language[source]
full_name[source]
short_name[source]
description[source]
__str__()[source]

Return str(self).

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 Meta[source]

Bases: object

verbose_name[source]
verbose_name_plural[source]
unique_together = ['name', 'parent_tag'][source]
parent_tag[source]
name[source]
order[source]
__str__()[source]

Return str(self).

class oioioi.problems.models.OriginInfoCategoryLocalization(*args, **kwargs)[source]

Bases: django.db.models.Model

Make subclasses preserve the alters_data attribute on overridden methods.

class Meta[source]

Bases: object

unique_together = ['origin_info_category', 'language'][source]
verbose_name[source]
verbose_name_plural[source]
origin_info_category[source]
language[source]
full_name[source]
__str__()[source]

Return str(self).

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 Meta[source]

Bases: object

unique_together = ['parent_tag', 'value'][source]
verbose_name[source]
verbose_name_plural[source]
property name[source]
property full_name[source]
parent_tag[source]
category[source]
value[source]
order[source]
problems[source]
__str__()[source]

Return str(self).

class oioioi.problems.models.OriginInfoValueLocalization(*args, **kwargs)[source]

Bases: django.db.models.Model

Make subclasses preserve the alters_data attribute on overridden methods.

class Meta[source]

Bases: object

unique_together = ['origin_info_value', 'language'][source]
verbose_name[source]
verbose_name_plural[source]
origin_info_value[source]
language[source]
full_value[source]
__str__()[source]

Return str(self).

class oioioi.problems.models.DifficultyTag(*args, **kwargs)[source]

Bases: django.db.models.Model

Make subclasses preserve the alters_data attribute on overridden methods.

class Meta[source]

Bases: object

verbose_name[source]
verbose_name_plural[source]
name[source]
problems[source]
__str__()[source]

Return str(self).

class oioioi.problems.models.DifficultyTagThrough(*args, **kwargs)[source]

Bases: django.db.models.Model

Make subclasses preserve the alters_data attribute on overridden methods.

problem[source]
tag[source]
__str__()[source]

Return str(self).

class oioioi.problems.models.DifficultyTagLocalization(*args, **kwargs)[source]

Bases: django.db.models.Model

Make subclasses preserve the alters_data attribute on overridden methods.

class Meta[source]

Bases: object

unique_together = ['difficulty_tag', 'language'][source]
verbose_name[source]
verbose_name_plural[source]
difficulty_tag[source]
language[source]
full_name[source]
__str__()[source]

Return str(self).

class oioioi.problems.models.DifficultyTagProposal(*args, **kwargs)[source]

Bases: django.db.models.Model

Make subclasses preserve the alters_data attribute on overridden methods.

class Meta[source]

Bases: object

verbose_name[source]
verbose_name_plural[source]
problem[source]
tag[source]
user[source]
__str__()[source]

Return str(self).

class oioioi.problems.models.AlgorithmTag(*args, **kwargs)[source]

Bases: django.db.models.Model

Make subclasses preserve the alters_data attribute on overridden methods.

class Meta[source]

Bases: object

verbose_name[source]
verbose_name_plural[source]
name[source]
problems[source]
__str__()[source]

Return str(self).

class oioioi.problems.models.AlgorithmTagThrough(*args, **kwargs)[source]

Bases: django.db.models.Model

Make subclasses preserve the alters_data attribute on overridden methods.

class Meta[source]

Bases: object

unique_together = ['problem', 'tag'][source]
problem[source]
tag[source]
__str__()[source]

Return str(self).

class oioioi.problems.models.AlgorithmTagLocalization(*args, **kwargs)[source]

Bases: django.db.models.Model

Make subclasses preserve the alters_data attribute on overridden methods.

class Meta[source]

Bases: object

unique_together = ['algorithm_tag', 'language'][source]
verbose_name[source]
verbose_name_plural[source]
algorithm_tag[source]
language[source]
full_name[source]
__str__()[source]

Return str(self).

class oioioi.problems.models.AlgorithmTagProposal(*args, **kwargs)[source]

Bases: django.db.models.Model

Make subclasses preserve the alters_data attribute on overridden methods.

class Meta[source]

Bases: object

verbose_name[source]
verbose_name_plural[source]
problem[source]
tag[source]
user[source]
__str__()[source]

Return str(self).