oioioi.base.admin

Module Contents

Classes

TabularInline

Options for inline editing of model instances.

StackedInline

Options for inline editing of model instances.

ModelAdminMeta

Meta class triggering __classinit__ on class intialization.

ModelAdmin

Encapsulate all admin options and functionality for a given model.

AdminSite

An AdminSite object encapsulates an instance of the Django admin application, ready

OioioiUserAdmin

Encapsulate all admin options and functionality for a given model.

InstanceDependentAdmin

Encapsulate all admin options and functionality for a given model.

MixinsAdmin

Encapsulate all admin options and functionality for a given model.

ConsentsInline

Options for inline editing of model instances.

UserWithConsentsAdminMixin

Functions

delete_selected(modeladmin, request, queryset, **kwargs)

Default ModelAdmin action that deletes the selected objects.

collect_deleted_objects(modeladmin, request, queryset)

Collects objects that are related to queryset items and checks

Attributes

oioioi.base.admin.NO_CATEGORY = __no_category__[source]
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 the ForeignKey from model to its parent. This is required if model has more than one ForeignKey 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 the ForeignKey from model to its parent. This is required if model has more than one ForeignKey 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.

allow_too_late_mixins = True[source]
response_change(request, obj)[source]

Determine the HttpResponse for the change_view stage.

change_view(request, object_id, form_url='', extra_context=None)[source]
response_delete(request)[source]

Determine the HttpResponse for the delete_view stage.

delete_view(request, object_id, extra_context=None)[source]

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.short_description[source]
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 the queryset.

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.

has_permission(request)[source]

Return True if the given HttpRequest has permission to view at least one page in the admin site.

_reinit_model_admins()[source]
get_urls()[source]
login(request, extra_context=None)[source]

Display the login form for the given HttpRequest.

oioioi.base.admin.site[source]
oioioi.base.admin.system_admin_menu_registry[source]
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.

form[source]
add_form[source]
allow_too_late_mixins = True[source]
fieldsets = [None, None, None, None][source]
list_filter = ['is_superuser', 'is_active'][source]
list_display = ['username', 'email', 'first_name', 'last_name', 'is_active'][source]
filter_horizontal = [][source]
actions = ['activate_user'][source]
short_description[source]
activate_user(request, qs)[source]
class oioioi.base.admin.InstanceDependentAdmin(model, admin_site)[source]

Bases: django.contrib.admin.ModelAdmin

Encapsulate all admin options and functionality for a given model.

default_model_admin[source]
abstract _model_admin_for_instance(request, instance=None)[source]
_find_model_admin(request, object_id)[source]
add_view(request, form_url='', extra_context=None)[source]
change_view(request, object_id, form_url='', extra_context=None)[source]
delete_view(request, object_id, extra_context=None)[source]
changelist_view(request, extra_context=None)[source]

The ‘change list’ admin view for this 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.

_model_admin_for_instance(request, instance=None)[source]
abstract _mixins_for_instance(request, instance=None)[source]
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 the ForeignKey from model to its parent. This is required if model has more than one ForeignKey to its parent.

model[source]
extra = 0[source]
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.

class oioioi.base.admin.UserWithConsentsAdminMixin(*args, **kwargs)[source]

Bases: object