:py:mod:`oioioi.contests.admin` =============================== .. py:module:: oioioi.contests.admin Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: oioioi.contests.admin.ContestProxyAdminSite oioioi.contests.admin.RoundInline oioioi.contests.admin.AttachmentInline oioioi.contests.admin.ContestLinkInline oioioi.contests.admin.ContestAdmin oioioi.contests.admin.BaseContestAdmin oioioi.contests.admin.ProblemInstanceAdmin oioioi.contests.admin.ProblemFilter oioioi.contests.admin.ContestsProblemNameListFilter oioioi.contests.admin.SubmissionKindListFilter oioioi.contests.admin.SubmissionRoundListFilter oioioi.contests.admin.ContestListFilter oioioi.contests.admin.SystemErrorListFilter oioioi.contests.admin.SubmissionAdmin oioioi.contests.admin.RoundTimeRoundListFilter oioioi.contests.admin.RoundTimeExtensionAdmin oioioi.contests.admin.ContestPermissionAdminForm oioioi.contests.admin.ContestPermissionAdmin Attributes ~~~~~~~~~~ .. autoapisummary:: oioioi.contests.admin.contest_site .. py:class:: ContestProxyAdminSite(orig) Bases: :py:obj:`oioioi.base.admin.AdminSite` An AdminSite object encapsulates an instance of the Django admin application, ready to be hooked in to your URLconf. Models are registered with the AdminSite using the register() method, and the get_urls() method can then be used to access Django view functions that present a full admin interface for the collection of registered models. .. py:method:: register(model_or_iterable, admin_class=None, **options) Register the given model(s) with the given admin class. The model(s) should be Model classes, not instances. If an admin class isn't given, use ModelAdmin (the default admin options). If keyword arguments are given -- e.g., list_display -- apply them as options to the admin class. If a model is already registered, raise AlreadyRegistered. If a model is abstract, raise ImproperlyConfigured. .. py:method:: unregister(model_or_iterable) Unregister the given model(s). If a model isn't already registered, raise NotRegistered. .. py:method:: contest_register(model_or_iterable, admin_class=None, **options) .. py:method:: contest_unregister(model_or_iterable) .. py:method:: get_urls() .. py:method:: index(request, extra_context=None) Display the main admin index page, which lists all of the installed apps that have been registered in this site. .. py:method:: app_index(request, app_label, extra_context=None) .. py:data:: contest_site .. py:class:: RoundInline(parent_model, admin_site) Bases: :py:obj:`oioioi.base.admin.StackedInline` Options for inline editing of ``model`` instances. Provide ``fk_name`` to specify the attribute name of the ``ForeignKey`` from ``model`` to its parent. This is required if ``model`` has more than one ``ForeignKey`` to its parent. .. py:attribute:: model .. py:attribute:: extra :annotation: = 0 .. py:attribute:: inline_classes :annotation: = ['collapse open'] .. py:attribute:: category .. py:method:: has_add_permission(request, obj=None) Return True if the given request has permission to add an object. Can be overridden by the user in subclasses. .. py:method:: has_change_permission(request, obj=None) Return True if the given request has permission to change the given Django model instance, the default implementation doesn't examine the `obj` parameter. Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to change the `obj` model instance. If `obj` is None, this should return True if the given request has permission to change *any* object of the given type. .. py:method:: has_delete_permission(request, obj=None) Return True if the given request has permission to delete the given Django model instance, the default implementation doesn't examine the `obj` parameter. Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to delete the `obj` model instance. If `obj` is None, this should return True if the given request has permission to delete *any* object of the given type. .. py:method:: get_fieldsets(request, obj=None) Hook for specifying fieldsets. .. py:class:: AttachmentInline(parent_model, admin_site) Bases: :py:obj:`oioioi.base.admin.StackedInline` Options for inline editing of ``model`` instances. Provide ``fk_name`` to specify the attribute name of the ``ForeignKey`` from ``model`` to its parent. This is required if ``model`` has more than one ``ForeignKey`` to its parent. .. py:attribute:: model .. py:attribute:: extra :annotation: = 0 .. py:attribute:: readonly_fields :annotation: = ['content_link'] .. py:attribute:: category .. py:attribute:: short_description .. py:method:: has_add_permission(request, obj=None) Return True if the given request has permission to add an object. Can be overridden by the user in subclasses. .. py:method:: has_change_permission(request, obj=None) Return True if the given request has permission to change the given Django model instance, the default implementation doesn't examine the `obj` parameter. Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to change the `obj` model instance. If `obj` is None, this should return True if the given request has permission to change *any* object of the given type. .. py:method:: has_delete_permission(request, obj=None) Return True if the given request has permission to delete the given Django model instance, the default implementation doesn't examine the `obj` parameter. Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to delete the `obj` model instance. If `obj` is None, this should return True if the given request has permission to delete *any* object of the given type. .. py:method:: content_link(instance) .. py:method:: formfield_for_foreignkey(db_field, request, **kwargs) Get a form Field for a ForeignKey. .. py:class:: ContestLinkInline(parent_model, admin_site) Bases: :py:obj:`oioioi.base.admin.TabularInline` Options for inline editing of ``model`` instances. Provide ``fk_name`` to specify the attribute name of the ``ForeignKey`` from ``model`` to its parent. This is required if ``model`` has more than one ``ForeignKey`` to its parent. .. py:attribute:: model .. py:attribute:: extra :annotation: = 0 .. py:attribute:: category .. py:class:: ContestAdmin(model, admin_site) Bases: :py:obj:`oioioi.base.admin.ModelAdmin` Encapsulate all admin options and functionality for a given model. .. py:attribute:: inlines .. py:attribute:: readonly_fields :annotation: = ['creation_date'] .. py:attribute:: prepopulated_fields .. py:attribute:: list_display :annotation: = ['name', 'id', 'creation_date'] .. py:attribute:: list_display_links :annotation: = ['id', 'name'] .. py:attribute:: ordering :annotation: = ['-creation_date'] .. py:method:: has_add_permission(request) Return True if the given request has permission to add an object. Can be overridden by the user in subclasses. .. py:method:: has_change_permission(request, obj=None) Return True if the given request has permission to change the given Django model instance, the default implementation doesn't examine the `obj` parameter. Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to change the `obj` model instance. If `obj` is None, this should return True if the given request has permission to change *any* object of the given type. .. py:method:: get_fields(request, obj=None) Hook for specifying fields. .. py:method:: get_fieldsets(request, obj=None) Hook for specifying fieldsets. .. py:method:: get_readonly_fields(request, obj=None) Hook for specifying custom readonly fields. .. py:method:: get_prepopulated_fields(request, obj=None) Hook for specifying custom prepopulated fields. .. py:method:: get_form(request, obj=None, **kwargs) Return a Form class for use in the admin add view. This is used by add_view and change_view. .. py:method:: get_formsets(request, obj=None) .. py:method:: response_change(request, obj) Determine the HttpResponse for the change_view stage. .. py:method:: response_add(request, obj, post_url_continue=None) Determine the HttpResponse for the add_view stage. .. py:method:: response_delete(request) Determine the HttpResponse for the delete_view stage. .. py:method:: _get_extra_context(extra_context) .. py:method:: add_view(request, form_url='', extra_context=None) .. py:method:: change_view(request, object_id, form_url='', extra_context=None) .. py:method:: delete_selected_contests(modeladmin, request, queryset) .. py:method:: get_actions(request) Return a dictionary mapping the names of all actions for this ModelAdmin to a tuple of (callable, name, description) for each action. .. py:class:: BaseContestAdmin(*args, **kwargs) Bases: :py:obj:`oioioi.base.admin.MixinsAdmin` Encapsulate all admin options and functionality for a given model. .. py:attribute:: default_model_admin .. py:method:: _mixins_for_instance(request, instance=None) .. py:class:: ProblemInstanceAdmin(*args, **kwargs) Bases: :py:obj:`oioioi.base.admin.ModelAdmin` Encapsulate all admin options and functionality for a given model. .. py:attribute:: form .. py:attribute:: fields :annotation: = ['contest', 'round', 'problem', 'short_name', 'submissions_limit'] .. py:attribute:: list_display :annotation: = ['name_link', 'short_name_link', 'round', 'package', 'actions_field'] .. py:attribute:: readonly_fields :annotation: = ['contest', 'problem'] .. py:attribute:: ordering :annotation: = ['-round__start_date', 'short_name'] .. py:attribute:: short_description .. py:attribute:: short_description .. py:attribute:: admin_order_field :annotation: = ordering_name .. py:attribute:: short_description .. py:attribute:: admin_order_field :annotation: = short_name .. py:attribute:: short_description .. py:method:: has_add_permission(request) Return True if the given request has permission to add an object. Can be overridden by the user in subclasses. .. py:method:: has_change_permission(request, obj=None) Return True if the given request has permission to change the given Django model instance, the default implementation doesn't examine the `obj` parameter. Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to change the `obj` model instance. If `obj` is None, this should return True if the given request has permission to change *any* object of the given type. .. py:method:: has_delete_permission(request, obj=None) Return True if the given request has permission to delete the given Django model instance, the default implementation doesn't examine the `obj` parameter. Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to delete the `obj` model instance. If `obj` is None, this should return True if the given request has permission to delete *any* object of the given type. .. py:method:: _problem_change_href(instance) .. py:method:: _rejudge_all_submissions_for_problem_href(instance) .. py:method:: _set_needs_rejudge_to_false_href(instance) .. py:method:: _model_solutions_href(instance) .. py:method:: _problem_site_href(instance) .. py:method:: _reset_limits_href(instance) .. py:method:: _reattach_problem_href(instance) .. py:method:: _add_or_update_href(instance) .. py:method:: _replace_statement_href(instance) .. py:method:: _package_manage_href(instance) .. py:method:: _edit_quiz_href(instance) .. py:method:: _move_href(instance) .. py:method:: get_list_display(request) Return a sequence containing the fields to be displayed on the changelist. .. py:method:: inline_actions(instance) .. py:method:: actions_field(instance) .. py:method:: name_link(instance) .. py:method:: short_name_link(instance) .. py:method:: package(instance) .. py:method:: get_actions(request) Return a dictionary mapping the names of all actions for this ModelAdmin to a tuple of (callable, name, description) for each action. .. py:method:: get_custom_list_select_related() Returns a list of fields passed to queryset.select_related By default - empty list. Override this method (instead of get_queryset()) to pass another field to the select_related. .. py:method:: get_queryset(request) Return a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view. .. py:class:: ProblemFilter(field, request, params, model, model_admin, field_path) Bases: :py:obj:`django.contrib.admin.AllValuesFieldListFilter` .. py:attribute:: title .. py:class:: ContestsProblemNameListFilter(request, params, model, model_admin) Bases: :py:obj:`oioioi.base.utils.filters.ProblemNameListFilter` .. py:attribute:: initial_query_manager .. py:attribute:: contest_field .. py:attribute:: related_names :annotation: = problem_instance__problem__names .. py:attribute:: legacy_name_field .. py:attribute:: outer_ref .. py:class:: SubmissionKindListFilter(request, params, model, model_admin) Bases: :py:obj:`django.contrib.admin.SimpleListFilter` .. py:attribute:: title .. py:attribute:: parameter_name :annotation: = kind .. py:method:: lookups(request, model_admin) Must be overridden to return a list of tuples (value, verbose value) .. py:method:: queryset(request, queryset) Return the filtered queryset. .. py:class:: SubmissionRoundListFilter(request, params, model, model_admin) Bases: :py:obj:`django.contrib.admin.SimpleListFilter` .. py:attribute:: title .. py:attribute:: parameter_name :annotation: = round .. py:method:: lookups(request, model_admin) Must be overridden to return a list of tuples (value, verbose value) .. py:method:: queryset(request, queryset) Return the filtered queryset. .. py:class:: ContestListFilter(request, params, model, model_admin) Bases: :py:obj:`django.contrib.admin.SimpleListFilter` .. py:attribute:: title .. py:attribute:: parameter_name :annotation: = contest .. py:method:: lookups(request, model_admin) Must be overridden to return a list of tuples (value, verbose value) .. py:method:: queryset(request, queryset) Return the filtered queryset. .. py:class:: SystemErrorListFilter(request, params, model, model_admin) Bases: :py:obj:`django.contrib.admin.SimpleListFilter` .. py:attribute:: title .. py:attribute:: parameter_name :annotation: = has_active_system_error .. py:method:: lookups(request, model_admin) Must be overridden to return a list of tuples (value, verbose value) .. py:method:: queryset(request, queryset) Return the filtered queryset. .. py:class:: SubmissionAdmin(model, admin_site) Bases: :py:obj:`oioioi.base.admin.ModelAdmin` Encapsulate all admin options and functionality for a given model. .. py:class:: Media .. py:attribute:: js :annotation: = ['admin/js/jquery.init.js', 'js/admin-filter-collapse.js'] .. py:attribute:: date_hierarchy :annotation: = date .. py:attribute:: actions :annotation: = ['rejudge_action'] .. py:attribute:: search_fields :annotation: = ['user__username', 'user__last_name', 'problem_instance__problem__legacy_name',... .. py:attribute:: short_description .. py:attribute:: admin_order_field :annotation: = user__username .. py:attribute:: short_description .. py:attribute:: admin_order_field :annotation: = user__last_name .. py:attribute:: short_description .. py:attribute:: admin_order_field :annotation: = problem_instance .. py:attribute:: short_description .. py:attribute:: admin_order_field :annotation: = status .. py:attribute:: short_description .. py:attribute:: admin_order_field :annotation: = score_with_nulls_smallest .. py:attribute:: short_description .. py:attribute:: admin_order_field :annotation: = problem_instance__contest .. py:attribute:: short_description .. py:method:: get_list_display(request) Return a sequence containing the fields to be displayed on the changelist. .. py:method:: get_list_display_links(request, list_display) Return a sequence containing the fields to be displayed as links on the changelist. The list_display parameter is the list of fields returned by get_list_display(). .. py:method:: get_list_filter(request) Return a sequence containing the fields to be displayed as filters in the right sidebar of the changelist page. .. py:method:: get_urls() .. py:method:: get_search_results(request, queryset, search_term) Return a tuple containing a queryset to implement the search and a boolean indicating if the results may contain duplicates. .. py:method:: rejudge_view(request) .. py:method:: has_add_permission(request) Return True if the given request has permission to add an object. Can be overridden by the user in subclasses. .. py:method:: has_change_permission(request, obj=None) Return True if the given request has permission to change the given Django model instance, the default implementation doesn't examine the `obj` parameter. Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to change the `obj` model instance. If `obj` is None, this should return True if the given request has permission to change *any* object of the given type. .. py:method:: has_delete_permission(request, obj=None) Return True if the given request has permission to delete the given Django model instance, the default implementation doesn't examine the `obj` parameter. Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to delete the `obj` model instance. If `obj` is None, this should return True if the given request has permission to delete *any* object of the given type. .. py:method:: has_rejudge_permission(request) .. py:method:: get_actions(request) Return a dictionary mapping the names of all actions for this ModelAdmin to a tuple of (callable, name, description) for each action. .. py:method:: user_login(instance) .. py:method:: user_full_name(instance) .. py:method:: problem_instance_display(instance) .. py:method:: status_display(instance) .. py:method:: score_display(instance) .. py:method:: contest_display(instance) .. py:method:: rejudge_action(request, queryset) .. py:method:: get_custom_list_select_related() Returns a list of fields passed to queryset.select_related By default - empty list. Override this method (instead of get_queryset()) to pass another field to the select_related. .. py:method:: get_queryset(request) Return a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view. .. py:method:: lookup_allowed(key, value) .. py:method:: change_view(request, object_id, form_url='', extra_context=None) .. py:class:: RoundTimeRoundListFilter(request, params, model, model_admin) Bases: :py:obj:`django.contrib.admin.SimpleListFilter` .. py:attribute:: title .. py:attribute:: parameter_name :annotation: = round .. py:method:: lookups(request, model_admin) Must be overridden to return a list of tuples (value, verbose value) .. py:method:: queryset(request, queryset) Return the filtered queryset. .. py:class:: RoundTimeExtensionAdmin(model, admin_site) Bases: :py:obj:`oioioi.base.admin.ModelAdmin` Encapsulate all admin options and functionality for a given model. .. py:attribute:: list_display :annotation: = ['user_login', 'user_full_name', 'round', 'extra_time'] .. py:attribute:: list_display_links :annotation: = ['extra_time'] .. py:attribute:: list_filter .. py:attribute:: search_fields :annotation: = ['user__username', 'user__last_name'] .. py:attribute:: short_description .. py:attribute:: admin_order_field :annotation: = user__username .. py:attribute:: short_description .. py:attribute:: admin_order_field :annotation: = user__last_name .. py:method:: has_add_permission(request) Return True if the given request has permission to add an object. Can be overridden by the user in subclasses. .. py:method:: has_change_permission(request, obj=None) Return True if the given request has permission to change the given Django model instance, the default implementation doesn't examine the `obj` parameter. Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to change the `obj` model instance. If `obj` is None, this should return True if the given request has permission to change *any* object of the given type. .. py:method:: has_delete_permission(request, obj=None) Return True if the given request has permission to delete the given Django model instance, the default implementation doesn't examine the `obj` parameter. Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to delete the `obj` model instance. If `obj` is None, this should return True if the given request has permission to delete *any* object of the given type. .. py:method:: user_login(instance) .. py:method:: user_full_name(instance) .. py:method:: get_queryset(request) Return a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view. .. py:method:: formfield_for_foreignkey(db_field, request, **kwargs) Get a form Field for a ForeignKey. .. py:method:: get_custom_list_select_related() Returns a list of fields passed to queryset.select_related By default - empty list. Override this method (instead of get_queryset()) to pass another field to the select_related. .. py:class:: ContestPermissionAdminForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None) Bases: :py:obj:`django.forms.ModelForm` The main implementation of all the Form logic. Note that this class is different than Form. See the comments by the Form class for more info. Any improvements to the form API should be made to this class, not to the Form class. .. py:class:: Meta Bases: :py:obj:`object` .. py:attribute:: model .. py:attribute:: fields :annotation: = ['user', 'contest', 'permission'] .. py:attribute:: user .. py:class:: ContestPermissionAdmin(model, admin_site) Bases: :py:obj:`oioioi.base.admin.ModelAdmin` Encapsulate all admin options and functionality for a given model. .. py:attribute:: list_display :annotation: = ['permission', 'user', 'user_full_name'] .. py:attribute:: list_display_links :annotation: = ['user'] .. py:attribute:: ordering :annotation: = ['permission', 'user'] .. py:attribute:: form .. py:attribute:: short_description .. py:attribute:: admin_order_field :annotation: = user__last_name .. py:method:: user_full_name(instance) .. py:method:: get_queryset(request) Return a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view. .. py:method:: formfield_for_foreignkey(db_field, request, **kwargs) Get a form Field for a ForeignKey.