oioioi.rankings.controllers
¶
Module Contents¶
Classes¶
ContestController mixin that sets up rankings app. |
|
Ranking system uses two types of keys: "partial key"s and "full key"s. |
|
Ranking system uses two types of keys: "partial key"s and "full key"s. |
Functions¶
|
Attributes¶
- class oioioi.rankings.controllers.RankingMixinForContestController[source]¶
Bases:
object
ContestController mixin that sets up rankings app.
- ranking_controller()[source]¶
Return the actual
RankingController
for the contest.
- class oioioi.rankings.controllers.RankingController(contest)[source]¶
Bases:
oioioi.base.utils.RegisteredSubclassesBase
,oioioi.base.utils.ObjectWithMixins
Ranking system uses two types of keys: “partial key”s and “full key”s. Please note that full keys are abbreviated in the code as “key”s.
A pair (request, partial_key) should allow to build a full key, while a partial_key can always be extracted from the full key. partial keys identify the rounds to display and are used everywhere outside controllers and rankingsd (e.g. in views and urls). However, the actual ranking contents can depend on many other factors, like user permissions. This was the reason for introduction of full keys, which are always sufficient to choose the right data for serialization and display.
- get_full_key(request, partial_key)[source]¶
Returns a full key associated with request and partial_key
- is_admin_key(key)[source]¶
Returns true if a given full key corresponds to users with administrative permissions.
- abstract available_rankings(request)[source]¶
Returns a list of available rankings.
Each ranking is a pair
(key, description)
.
- abstract find_user_position(request, partial_key, user)[source]¶
Returns user’s position in the ranking. User should be an object of class User, not a string with username.
If user is not in the ranking, None is returned.
- get_rendered_ranking(request, partial_key)[source]¶
Retrieves ranking generated by rankingsd.
You should never override this function. It will be responsible for communication with rankingsd and use render_ranking for actual HTML generation. Feel free to override render_ranking to customize its logic.
If the ranking is still being generated, or the user requested an invalid page, displays an appropriate message.
- build_ranking(key)[source]¶
Serializes data and renders html for given key.
Results are processed using serialize_ranking, and then as many pages as needed are rendered. Returns a tuple containing serialized data and a list of strings, that are html code of ranking pages.
- class oioioi.rankings.controllers.DefaultRankingController(contest)[source]¶
Bases:
RankingController
Ranking system uses two types of keys: “partial key”s and “full key”s. Please note that full keys are abbreviated in the code as “key”s.
A pair (request, partial_key) should allow to build a full key, while a partial_key can always be extracted from the full key. partial keys identify the rounds to display and are used everywhere outside controllers and rankingsd (e.g. in views and urls). However, the actual ranking contents can depend on many other factors, like user permissions. This was the reason for introduction of full keys, which are always sufficient to choose the right data for serialization and display.
- available_rankings(request)[source]¶
Returns a list of available rankings.
Each ranking is a pair
(key, description)
.
- find_user_position(request, partial_key, user)[source]¶
Returns user’s position in the ranking. User should be an object of class User, not a string with username.
If user is not in the ranking, None is returned.