Middleware which checks whether the user participate in an
- class oioioi.contestexcl.middleware.ExclusiveContestsMiddleware(get_response)¶
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
ExclusivenessConfiginstance 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_viewaccepts 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.contestvariable 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.
- process_view(request, view_func, view_args, view_kwargs, selector=None)¶
- _send_error_email(request, contests)¶
- _error_email_context(request, contests)¶