:py:mod:`oioioi.base.admin` =========================== .. py:module:: oioioi.base.admin Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: oioioi.base.admin.TabularInline oioioi.base.admin.StackedInline oioioi.base.admin.ModelAdminMeta oioioi.base.admin.ModelAdmin oioioi.base.admin.AdminSite oioioi.base.admin.OioioiUserAdmin oioioi.base.admin.InstanceDependentAdmin oioioi.base.admin.MixinsAdmin oioioi.base.admin.ConsentsInline oioioi.base.admin.UserWithConsentsAdminMixin Functions ~~~~~~~~~ .. autoapisummary:: oioioi.base.admin.delete_selected oioioi.base.admin.collect_deleted_objects Attributes ~~~~~~~~~~ .. autoapisummary:: oioioi.base.admin.NO_CATEGORY oioioi.base.admin.short_description oioioi.base.admin.site oioioi.base.admin.system_admin_menu_registry .. py:data:: NO_CATEGORY :annotation: = __no_category__ .. py:class:: TabularInline(parent_model, admin_site) Bases: :py:obj:`django.contrib.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: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:: has_view_permission(request, obj=None) Return True if the given request has permission to view the given Django model instance. The default implementation doesn't examine the `obj` parameter. If overridden by the user in subclasses, it should return True if the given request has permission to view the `obj` model instance. If `obj` is None, it should return True if the request has permission to view any object of the given type. .. py:class:: StackedInline(parent_model, admin_site) Bases: :py:obj:`django.contrib.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: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:: has_view_permission(request, obj=None) Return True if the given request has permission to view the given Django model instance. The default implementation doesn't examine the `obj` parameter. If overridden by the user in subclasses, it should return True if the given request has permission to view the `obj` model instance. If `obj` is None, it should return True if the request has permission to view any object of the given type. .. py:class:: ModelAdminMeta(class_name, bases, new_attrs) Bases: :py:obj:`django.contrib.admin.ModelAdmin.__class__`, :py:obj:`oioioi.base.utils.ClassInitMeta` Meta class triggering __classinit__ on class intialization. .. py:class:: ModelAdmin(model, admin_site) Bases: :py:obj:`django.contrib.admin.ModelAdmin`, :py:obj:`oioioi.base.utils.ObjectWithMixins` Encapsulate all admin options and functionality for a given model. .. py:attribute:: allow_too_late_mixins :annotation: = True .. py:method:: response_change(request, obj) Determine the HttpResponse for the change_view stage. .. py:method:: change_view(request, object_id, form_url='', extra_context=None) .. py:method:: response_delete(request) Determine the HttpResponse for the delete_view stage. .. py:method:: delete_view(request, object_id, extra_context=None) .. 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:: has_view_permission(request, obj=None) Return True if the given request has permission to view the given Django model instance. The default implementation doesn't examine the `obj` parameter. If overridden by the user in subclasses, it should return True if the given request has permission to view the `obj` model instance. If `obj` is None, it should return True if the request has permission to view any object of the given type. .. py:function:: delete_selected(modeladmin, request, queryset, **kwargs) Default ModelAdmin action that deletes the selected objects. Django's default handler doesn't even check the has_delete_permission() of corresponding ModelAdmin with specific instances (only the general permission), and requires django's User model permissions as well. Theese aren't currently used in OIOIOI, so this custom method doesn't care about them. This implementation checks if deleted model is registered in the current AdminSite and if it is, then uses has_delete_permission() with it's instance. It first displays a confirmation page that shows all the deleteable objects, or, if the user has no permission for one of the related objects (foreignkeys), a "permission denied" message. Next, it deletes all selected objects and redirects back to the change list. .. py:data:: short_description .. py:function:: collect_deleted_objects(modeladmin, request, queryset) Collects objects that are related to queryset items and checks their permissions. This method checks if the user has permissions to delete items that are anyhow related to theese in the queryset (regardless of the depth). ``modeladmin`` is expected to be a ModelAdmin instance corresponding to the class of items contained in the ``queryset``. .. py:class:: AdminSite(*args, **kwargs) Bases: :py:obj:`django.contrib.admin.sites.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:: has_permission(request) Return True if the given HttpRequest has permission to view *at least one* page in the admin site. .. py:method:: _reinit_model_admins() .. py:method:: get_urls() .. py:method:: login(request, extra_context=None) Display the login form for the given HttpRequest. .. py:data:: site .. py:data:: system_admin_menu_registry .. py:class:: OioioiUserAdmin(model, admin_site) Bases: :py:obj:`django.contrib.auth.admin.UserAdmin`, :py:obj:`oioioi.base.utils.ObjectWithMixins` Encapsulate all admin options and functionality for a given model. .. py:attribute:: form .. py:attribute:: add_form .. py:attribute:: allow_too_late_mixins :annotation: = True .. py:attribute:: fieldsets :annotation: = [None, None, None, None] .. py:attribute:: list_filter :annotation: = ['is_superuser', 'is_active'] .. py:attribute:: list_display :annotation: = ['username', 'email', 'first_name', 'last_name', 'is_active'] .. py:attribute:: filter_horizontal :annotation: = [] .. py:attribute:: actions :annotation: = ['activate_user'] .. py:attribute:: short_description .. py:method:: activate_user(request, qs) .. py:class:: InstanceDependentAdmin(model, admin_site) Bases: :py:obj:`django.contrib.admin.ModelAdmin` Encapsulate all admin options and functionality for a given model. .. py:attribute:: default_model_admin .. py:method:: _model_admin_for_instance(request, instance=None) :abstractmethod: .. py:method:: _find_model_admin(request, object_id) .. 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_view(request, object_id, extra_context=None) .. py:method:: changelist_view(request, extra_context=None) The 'change list' admin view for this model. .. py:method:: history_view(request, object_id, extra_context=None) The 'history' admin view for this model. .. py:method:: has_view_permission(request, obj=None) Return True if the given request has permission to view the given Django model instance. The default implementation doesn't examine the `obj` parameter. If overridden by the user in subclasses, it should return True if the given request has permission to view the `obj` model instance. If `obj` is None, it should return True if the request has permission to view any object of the given type. .. py:class:: MixinsAdmin(*args, **kwargs) Bases: :py:obj:`InstanceDependentAdmin` Encapsulate all admin options and functionality for a given model. .. py:method:: _model_admin_for_instance(request, instance=None) .. py:method:: _mixins_for_instance(request, instance=None) :abstractmethod: .. py:class:: ConsentsInline(parent_model, admin_site) Bases: :py:obj:`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: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:class:: UserWithConsentsAdminMixin(*args, **kwargs) Bases: :py:obj:`object`