:py:mod:`oioioi.contestexcl.middleware` ======================================= .. py:module:: oioioi.contestexcl.middleware Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: oioioi.contestexcl.middleware.ExclusiveContestsMiddleware .. py:class:: ExclusiveContestsMiddleware(get_response) Bases: :py:obj:`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: #. If ONLY_DEFAULT_CONTEST is set, only the default contest is taken into account. #. All contests with active :class:`~oioioi.contestexcl.models.ExclusivenessConfig` instance are acquired from the database. #. 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). #. If there is only one contest left, the ``request.contest`` variable is set to this contest or a redirect is made if necessary. #. 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. .. py:method:: __call__(request) .. py:method:: process_view(request, view_func, view_args, view_kwargs, selector=None) .. py:method:: _check_requirements(request) .. py:method:: _send_error_email(request, contests) .. py:method:: _error_email_message(context) .. py:method:: _error_email_context(request, contests)