oioioi.contestexcl.middleware

Module Contents

Classes

ExclusiveContestsMiddleware

Middleware which checks whether the user participate in an

class oioioi.contestexcl.middleware.ExclusiveContestsMiddleware(get_response)[source]

Bases: oioioi.base.utils.ObjectWithMixins

Middleware which checks whether the user participate in an exclusive contest, which is a contest that blocks other contests, and sets the current contest to that contest.

It works as follows:

  1. If ONLY_DEFAULT_CONTEST is set, only the default contest is taken into account.

  2. All contests with active ExclusivenessConfig instance are acquired from the database.

  3. They are filtered with a special selector function, which by default checks if the user is not a contest admin. In addition, process_view accepts another selector function as an argument. If it is present, the contest list is filtered with a logical conjunction of the default selector and the selector passed as an argument (it may be useful with mixins).

  4. If there is only one contest left, the request.contest variable is set to this contest or a redirect is made if necessary.

  5. If there is more than one contest left, the user is logged out, an error message is displayed and an e-mail describing the situation is sent to the administrators.

__call__(request)[source]
process_view(request, view_func, view_args, view_kwargs, selector=None)[source]
_check_requirements(request)[source]
_send_error_email(request, contests)[source]
_error_email_message(context)[source]
_error_email_context(request, contests)[source]