Dynamic mixins

class oioioi.base.utils.ObjectWithMixins(*args, **kwargs)[source]

Base class for objects which support mixins.

Mixins are nice tools in Python. But they have one drawback – you have to specify new class’ mixins at the point where you declare it. This class solves this problem. Mixins can be now be added on the fly by mix_in() method. This allows for a more flexible modular design.

For example:

# base.py
class UserController(ObjectWithMixins):
    def render_user_info(self, user):
        return "Login: " + user.username

# some_external_module.py
class UserControllerBeautifier(object):
    def render_user_info(self, user):
        super_info = super(UserControllerBeautifier, self)                                 .render_user_info(user)
        return '<font color="red">' + super_info + '</font>'

Mixins can also be specified by providing a mixins class attribute or by passing an additional keyword argument mixins to the constructor.

A class with a mixin behave as if it was replaced with a subclass which bases are the mixin and the original class.

The actual class with the mixins is created when the constructor is called or a subclass defined. Mixing in a new mixin to a class which have instances has an undefined effect on them.

mixins = []

A list of mixins to be automatically mixed in to all instances of the particular class and its subclasses.

allow_too_late_mixins = False

Setting this to True allows adding mixins to the class after it has been instantiated. Existing instances will not have new mixins added.

classmethod mix_in(mixin)[source]

Appends the given mixin to the list of class mixins.

Baseclasses that allow for adding mixins









Admin panel mixins

class oioioi.complaints.admin.ComplaintsAdminMixin(*args, **kwargs)[source]

Adds ComplaintConfig to an admin panel.

class oioioi.balloons.admin.BalloonsDeliveryAccessDataAdminMixin(*args, **kwargs)[source]

Adds BalloonsDeliveryAccessData fields to an admin panel.

class oioioi.contestexcl.admin.ContestAdminWithExclusivenessInlineMixin(*args, **kwargs)[source]

Adds ExclusivenessConfig to an admin panel.

class oioioi.contestlogo.admin.ContestLogoAdminMixin(*args, **kwargs)[source]

Adds ContestLogo to an admin panel.

class oioioi.contestlogo.admin.ContestIconAdminMixin(*args, **kwargs)[source]

Adds ContestIcon to an admin panel.

class oioioi.mailsubmit.admin.MailSubmissionConfigAdminMixin(*args, **kwargs)[source]

Adds MailSubmissionConfig to an admin panel.

class oioioi.oisubmit.admin.OISubmitSubmissionAdminMixin(*args, **kwargs)[source]

Adds oisubmit specific information (e.g. suspected submissions) to an admin panel.

class oioioi.pa.admin.PAProblemInstanceAdminMixin(*args, **kwargs)[source]

Adds PAProblemInstanceData to an admin panel.

class oioioi.participants.admin.OnsiteSubmissionAdminMixin(*args, **kwargs)[source]

Adds RegionListFilter filter to an admin panel.

class oioioi.participants.admin.UserWithParticipantsAdminMixin(*args, **kwargs)[source]

Adds Participant to an admin panel.

class oioioi.participants.admin.ParticipantsRoundTimeExtensionMixin[source]

Adds contest participants to an admin panel.

class oioioi.problems.admin.StatementConfigAdminMixin(*args, **kwargs)[source]

Adds ProblemStatementConfig to an admin panel.

class oioioi.programs.admin.LibraryProblemDataAdminMixin(*args, **kwargs)[source]

Adds LibraryProblemData to an admin panel.

class oioioi.programs.admin.ProgrammingProblemAdminMixin(*args, **kwargs)[source]

Adds ReportActionsConfig, OutputChecker, LibraryProblemData and ProblemAllowedLanguage and ProblemCompiler to an admin panel.

class oioioi.programs.admin.ProgrammingProblemInstanceAdminMixin(*args, **kwargs)[source]

Adds Test to an admin panel.

class oioioi.programs.admin.ProgrammingMainProblemInstanceAdminMixin(*args, **kwargs)[source]

Adds Test to an admin panel.

class oioioi.programs.admin.ProblemPackageAdminMixin[source]

Adds model solutions action to an admin panel.

class oioioi.programs.admin.ModelSubmissionAdminMixin[source]

Adds model submission to an admin panel.

class oioioi.programs.admin.ProgramSubmissionAdminMixin(*args, **kwargs)[source]

Adds submission diff action, language display and language filter to an admin panel.

class oioioi.questions.admin.MessageNotifierContestAdminMixin(*args, **kwargs)[source]

Adds MessageNotifierConfig to an admin panel.

class oioioi.scoresreveal.admin.ScoresRevealSubmissionAdminMixin(*args, **kwargs)[source]

Adds reveal info and filter to an admin panel.

class oioioi.sinolpack.admin.SinolpackProblemAdminMixin(*args, **kwargs)[source]

Adds ExtraConfig and ExtraFile to an admin panel.

class oioioi.statistics.admin.StatisticsAdminMixin(*args, **kwargs)[source]

Adds StatisticsConfig to an admin panel.

class oioioi.suspendjudge.admin.SuspendJudgeProblemInstanceAdminMixin(*args, **kwargs)[source]

Sets up admin panel for suspendjudge app.

class oioioi.teachers.admin.ContestAdminMixin(*args, **kwargs)[source]

Adjusts contest admin panel for teachers app usage. Superusers continue to work as usual but teachers have special options.

class oioioi.teams.admin.TeamsAdminMixin(*args, **kwargs)[source]

Adds TeamsConfig to an admin panel.

class oioioi.testspackages.admin.TestsPackageAdminMixin(*args, **kwargs)[source]

Adds TestsPackage to an admin panel.

class oioioi.zeus.admin.ZeusProblemAdminMixin(*args, **kwargs)[source]

Adds ZeusProblemData to an admin panel.


class oioioi.acm.controllers.NotificationsMixinForACMContestController[source]

Modifies default contest notification settings from NotificationsMixinForContestController. It enables sending notifications about new public messages to all participants and modifies submission notification messages so that

class oioioi.balloons.controllers.BalloonsDeliveryACMControllerMixin[source]

Creates a BalloonDelivery object for every submission that has been successfully judged, but only if it’s the first judged submission for that problem instance or a BalloonDelivery object was already created for that problem instance.

class oioioi.confirmations.controllers.ConfirmationContestControllerMixin[source]

Adds an option to contest controllers to send participants a proof of receiving their submissions.

class oioioi.contestlogo.controllers.LogoContestControllerMixin[source]

Sets default empty contest logo and icons settings.

class oioioi.contests.controllers.NotificationsMixinForContestController[source]

Sets default contest notification settings.

class oioioi.contests.controllers.PastRoundsHiddenContestControllerMixin[source]

ContestController mixin that hides past rounds if another round is starting soon.

The period when the past rounds are hidden is called round’s preparation time.

Do not use it with overlapping rounds.

class oioioi.contests.controllers.ProblemUploadingContestControllerMixin[source]

ContestController mixin that declares empty methods for extending problem uploading process.

class oioioi.dashboard.controllers.DashboardDefaultViewMixin[source]

ContestController mixin that sets contest dashboard as a default contest view.

class oioioi.disqualification.controllers.DisqualificationContestControllerMixin[source]

ContestController mixin that adds a disqualification functionality to the contest.

class oioioi.disqualification.controllers.DisqualificationProgrammingContestControllerMixin[source]

ContestController mixin that renders submission disqualification info.

class oioioi.disqualification.controllers.WithDisqualificationRankingControllerMixin[source]

RankingController mixin that manages disqualification module influence on rankings.

class oioioi.ipauthsync.controllers.IpAuthSyncControllerMixin[source]

ContestController mixin that sets up the ipauthsync app.

class oioioi.ipauthsync.controllers.IpAuthSyncRegistrationControllerMixin[source]

RegistrationController mixin that adds a functionality to validate IP address.

class oioioi.livedata.controllers.LivedataContestControllerMixin[source]

ContestController mixin that sets a default setting for livedata visibility.

class oioioi.oisubmit.controllers.OiSubmitContestControllerMixin[source]

ContestController mixin that adds extra information about submission from the oisubmit app to the submission footer.

class oioioi.participants.controllers.EmailShowContestControllerMixin[source]

Contest controller defines whether in participants’ data view email should be shown. That is a case in OI-type contest.

class oioioi.participants.controllers.AnonymousContestControllerMixin[source]

ContestController mixin that adds participants info for anonymous contests.

class oioioi.participants.controllers.OnsiteContestControllerMixin[source]

ContestController mixin that sets up an onsite contest.

class oioioi.participants.middleware.ExclusiveContestsWithParticipantsMiddlewareMixin[source]

This middleware mixin passes an additional selector to the ExclusiveContestsMiddleware when the participants application is used.

Now, a contest with ExclusivenessConfig which has participants is exclusive only for its participants.

Note that this feature makes greater sense when combined with automatic login, see oioioi.ipdnsauth.middleware.IpDnsAuthMiddleware.

class oioioi.printing.controllers.PrintingContestControllerMixin[source]

Disallow printing by default.

class oioioi.publicsolutions.controllers.PublicSolutionsContestControllerMixin[source]

ContestController mixin that sets up publicsolutions app.

class oioioi.questions.controllers.QuestionsContestControllerMixin[source]

ContestController mixin that adds participants’ questions to his info.

class oioioi.rankings.controllers.RankingMixinForContestController[source]

ContestController mixin that sets up rankings app.

class oioioi.scoresreveal.controllers.ScoresRevealContestControllerMixin[source]

ContestController mixin that sets up scoresreveal app.

class oioioi.similarsubmits.controllers.SimilarityDisqualificationMixin[source]

ContestController mixin that sets up similarsubmits app.

class oioioi.statistics.controllers.StatisticsMixinForContestController[source]

The basic unit of statistics module is a plot group. It is a group of plots. A plot group is calculated for an object. The object can be a contest or a problem.

Example plot groups are:

1. Contest – Data is calculated for a whole contest. 1. Problem XYZ – Data is calculated for a XYZ problem.

A cluster of plot groups for a certain type of object is a category.

A plot group is represented by a category identifier and an object name. The name is identifying an object for which statistics will be calculated. The type of the object depends on the category. It can be a contest or a problem. The meaning of the name also depends on category. For a problem it is a short name. In some cases the string is not necessary (for example for current contest), so an empty string is also possible.

A plot is a graphical representation of some data. For example: a histogram of results for a contest, a pie chart of AC and WA for a problem, a table with lengths of the shortest solutions for problems or even some text with the total number of submissions.

Plot kind tells what information we want to get. For example: a distribution of points for a problem, length of the shortest solution for a problem, numbers of solution for each problem in a contest. It also defines the type of object for which data will be calculated.

Example plot kinds for a problem:

1. Number of submissions. 1. Histogram of points. 1. Structure of results – how many AC, WA or TLE were reported.

Example plot kinds for a contest:

1. Number of accepted solutions. 1. Time of the first AC for every problem. 1. Number of accepted solutions for each problem. 1. Size of the shortest solution for each problem. 1. Structure of the results – how many AC, WA or TLE were reported.

Plot data is a portion of information sufficient to render a plot. To get plot data we need two pieces of information. One is the desired kind of plot. The other is the name of the object. The meaning of the name depends on the object type. For problem, the name is short_name.

Plot data is represented as a dict containing several entries:

1. plot_name – Title of the plot. 1. plot_type – An object of

PlotType. It determines a way to render data. For example a histogram, plain text or x-y plot.

Additional dict entries depend on plot_type. Look at PlotType implementations.

Plot kind is represented as a pair of an enum entry and a string.

class oioioi.submitservice.controllers.SubmitServiceMixinForProgrammingContestController[source]

ContestController mixin that adds information about the possibility to submit solutions from terminal.

class oioioi.suspendjudge.controllers.SuspendJudgeContestControllerMixin[source]

ContestController mixin that adds suspendjudge app’s handlers to environ recipe.

class oioioi.teams.controllers.TeamsMixinForContestController[source]

Mixin for contests containing teams. Gives information about permissions to modifications of teams.

class oioioi.testrun.controllers.TestRunProblemControllerMixin[source]

ProblemController mixin that adds testrun handlers to the recipe and adds testrun config to contest’s admin panel.

class oioioi.testrun.controllers.TestRunContestControllerMixin[source]

ContestController mixin that sets up testrun app for the contest.