oioioi.contestexcl.middleware
¶
Module Contents¶
Classes¶
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:
If ONLY_DEFAULT_CONTEST is set, only the default contest is taken into account.
All contests with active
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.