oioioi.base.admin
¶
Module Contents¶
Classes¶
Options for inline editing of |
|
Options for inline editing of |
|
Meta class triggering __classinit__ on class intialization. |
|
Encapsulate all admin options and functionality for a given model. |
|
An AdminSite object encapsulates an instance of the Django admin application, ready |
|
Encapsulate all admin options and functionality for a given model. |
|
Encapsulate all admin options and functionality for a given model. |
|
Encapsulate all admin options and functionality for a given model. |
|
Options for inline editing of |
|
Functions¶
|
Default ModelAdmin action that deletes the selected objects. |
|
Collects objects that are related to queryset items and checks |
Attributes¶
- class oioioi.base.admin.TabularInline(parent_model, admin_site)[source]¶
Bases:
django.contrib.admin.TabularInline
Options for inline editing of
model
instances.Provide
fk_name
to specify the attribute name of theForeignKey
frommodel
to its parent. This is required ifmodel
has more than oneForeignKey
to its parent.- has_add_permission(request, obj=None)[source]¶
Return True if the given request has permission to add an object. Can be overridden by the user in subclasses.
- has_change_permission(request, obj=None)[source]¶
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.
- has_delete_permission(request, obj=None)[source]¶
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.
- has_view_permission(request, obj=None)[source]¶
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.
- class oioioi.base.admin.StackedInline(parent_model, admin_site)[source]¶
Bases:
django.contrib.admin.StackedInline
Options for inline editing of
model
instances.Provide
fk_name
to specify the attribute name of theForeignKey
frommodel
to its parent. This is required ifmodel
has more than oneForeignKey
to its parent.- has_add_permission(request, obj=None)[source]¶
Return True if the given request has permission to add an object. Can be overridden by the user in subclasses.
- has_change_permission(request, obj=None)[source]¶
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.
- has_delete_permission(request, obj=None)[source]¶
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.
- has_view_permission(request, obj=None)[source]¶
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.
- class oioioi.base.admin.ModelAdminMeta(class_name, bases, new_attrs)[source]¶
Bases:
django.contrib.admin.ModelAdmin.__class__
,oioioi.base.utils.ClassInitMeta
Meta class triggering __classinit__ on class intialization.
- class oioioi.base.admin.ModelAdmin(model, admin_site)[source]¶
Bases:
django.contrib.admin.ModelAdmin
,oioioi.base.utils.ObjectWithMixins
Encapsulate all admin options and functionality for a given model.
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.
- get_queryset(request)[source]¶
Return a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view.
- has_view_permission(request, obj=None)[source]¶
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.
- oioioi.base.admin.delete_selected(modeladmin, request, queryset, **kwargs)[source]¶
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.
- oioioi.base.admin.collect_deleted_objects(modeladmin, request, queryset)[source]¶
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 thequeryset
.
- class oioioi.base.admin.AdminSite(*args, **kwargs)[source]¶
Bases:
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.
- class oioioi.base.admin.OioioiUserAdmin(model, admin_site)[source]¶
Bases:
django.contrib.auth.admin.UserAdmin
,oioioi.base.utils.ObjectWithMixins
Encapsulate all admin options and functionality for a given model.
- class oioioi.base.admin.InstanceDependentAdmin(model, admin_site)[source]¶
Bases:
django.contrib.admin.ModelAdmin
Encapsulate all admin options and functionality for a given model.
- history_view(request, object_id, extra_context=None)[source]¶
The ‘history’ admin view for this model.
- has_view_permission(request, obj=None)[source]¶
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.
- class oioioi.base.admin.MixinsAdmin(*args, **kwargs)[source]¶
Bases:
InstanceDependentAdmin
Encapsulate all admin options and functionality for a given model.
- class oioioi.base.admin.ConsentsInline(parent_model, admin_site)[source]¶
Bases:
StackedInline
Options for inline editing of
model
instances.Provide
fk_name
to specify the attribute name of theForeignKey
frommodel
to its parent. This is required ifmodel
has more than oneForeignKey
to its parent.- has_add_permission(request, obj=None)[source]¶
Return True if the given request has permission to add an object. Can be overridden by the user in subclasses.
- has_change_permission(request, obj=None)[source]¶
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.
- has_delete_permission(request, obj=None)[source]¶
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.