Admin — Django Building Blocks documentation

# Admin

Contents

- Admin

  - Base

  - Mixins

  - Models

  - Utils

- Admin blocks
  - Bases
  - Implementations
  - Utils
- Admin for Abstracts
  - Archivable
  - Publishable
  - Status

## Base

BaseModelAdmins for Kaos Models

class building_blocks.admin.base.BaseKaosModelAdmin

  Bases: `BaseModelAdmin`

  Base model admin for KaosModel

  Parameters

    - ordering – None

    - exclude – None

    - fields – None

    - autocomplete_fields – ()

    - readonly_fields – (‘uuid’, ‘created’, ‘modified’)

    - fieldsets – ((None, {‘fields’: ((‘name’,),)}), (‘Admin’, {‘fields’: (‘uuid’, ‘created’)}))

class building_blocks.admin.base.BaseKaosModelAdminExtra

  Bases: `BaseKaosModelAdmin`

  BaseKaosModelAdmin with extra admin fields (modified)

  Parameters

    fieldsets – ((None, {‘fields’: ((‘name’,),)}), (‘Admin’, {‘fields’: (‘uuid’, ‘created’, ‘modified’)}))

class building_blocks.admin.base.BaseBasicSluggedKaosModelAdmin

  Bases: `BaseKaosModelAdmin`

  Basic Base model admin for SluggedKaosModel.

  This basic admin lacks fancy features for slug like prepopulate, edit readonly or being unrequired.

  Mixing this and EnhancedSluggedKaosModelAdminMixin results in BaseSluggedKaosModelAdmin.

  Parameters

    - ordering – None

    - exclude – None

    - fields – None

    - autocomplete_fields – ()

    - readonly_fields – (‘uuid’, ‘created’, ‘modified’)

    - fieldsets – ((None, {‘fields’: ((‘name’,),)}), (‘Admin’, {‘fields’: (‘slug’, ‘uuid’, ‘created’)}))

class building_blocks.admin.base.BaseBasicSluggedKaosModelAdminExtra

  Bases: `BaseKaosModelAdmin`

  BaseBasicSluggedKaosModelAdmin with extra admin fields (modified)

  Parameters

    fieldsets – ((None, {‘fields’: ((‘name’,),)}), (‘Admin’, {‘fields’: (‘slug’, ‘uuid’, ‘created’, ‘modified’)}))

class building_blocks.admin.base.BaseSluggedKaosModelAdmin

  Bases: `EnhancedSluggedKaosModelAdminMixin`, `BaseBasicSluggedKaosModelAdmin`

  Base model admin for SluggedKaosModel.

  This admin has the enhancements for slug like prepopulate, edit readonly or being unrequired.

  Parameters

    - edit_readonly_fields – (‘slug’,)

    - slug_field – ‘slug’

    - slug_source – ‘name’

class building_blocks.admin.base.BaseSluggedKaosModelAdminExtra

  Bases: `EnhancedSluggedKaosModelAdminMixin`, `BaseBasicSluggedKaosModelAdminExtra`

  BaseSluggedKaosModelAdmin with extra admin fields (modified)

  Parameters

    fieldsets – ((None, {‘fields’: ((‘name’,),)}), (‘Admin’, {‘fields’: (‘slug’, ‘uuid’, ‘created’, ‘modified’)}))

## Mixins

Admin mixin enhancements

class building_blocks.admin.mixins.EnhancedHasSlugModelAdminMixin

  Bases: `EditReadonlyAdminMixin`

  Admin mixin to make the slug field edit readonly

  Parameters

    edit_readonly_fields – (SLUG,)

class building_blocks.admin.mixins.EnhancedSluggedKaosModelAdminMixin

  Bases: `PrepopulateSlugAdminMixin`, `EnhancedHasSlugModelAdminMixin`

  Admin mixin for SluggedModels so their slug is prepopulated from slug_source (by default name), slug field is marked as edit readonly and slug is unrequired in the from so to allow being auto set.

  Parameters

    slug_source – NAME

## Models

Model admins for Kaos Models

class building_blocks.admin.models.KaosModelAdmin(model, admin_site)

  Bases: `BaseKaosModelAdmin`, `ModelAdmin`

  Model admin for KaosModel

  Parameters

    - search_fields – (UUID, NAME)

    - list_display – (NAME,)

class building_blocks.admin.models.KaosModelAdminExtra(model, admin_site)

  Bases: `BaseKaosModelAdminExtra`, `KaosModelAdmin`

  KaosModelAdmin with extra admin fields (modified)

  Parameters

    fieldsets – ((None, {‘fields’: ((‘name’,),)}), (‘Admin’, {‘fields’: (‘uuid’, ‘created’, ‘modified’)}))

class building_blocks.admin.models.BasicSluggedKaosModelAdmin(model, admin_site)

  Bases: `BaseBasicSluggedKaosModelAdmin`, `KaosModelAdmin`

  Model admin for SluggedKaosModel

  Parameters

    - search_fields – (UUID, SLUG, NAME)

    - list_display_extra – (SLUG,)

class building_blocks.admin.models.BasicSluggedKaosModelAdminExtra(model, admin_site)

  Bases: `BaseBasicSluggedKaosModelAdminExtra`, `BasicSluggedKaosModelAdmin`

  BasicSluggedKaosModelAdmin with extra admin fields (modified)

class building_blocks.admin.models.SluggedKaosModelAdmin(model, admin_site)

  Bases: `EnhancedSluggedKaosModelAdminMixin`, `BasicSluggedKaosModelAdmin`

  BasicSluggedKaosModelAdmin enhanced with EnhancedSluggedKaosModelAdminMixin

class building_blocks.admin.models.SluggedKaosModelAdminExtra(model, admin_site)

  Bases: `EnhancedSluggedKaosModelAdminMixin`, `BasicSluggedKaosModelAdminExtra`

  BasicSluggedKaosModelAdminExtra enhanced with EnhancedSluggedKaosModelAdminMixin (with extra admin fields (modified))

## Utils

Set of utilities for building_blocks.admin

building_blocks.admin.utils.combine_admin_blocks_factory(*admin_block_classes: Type[AdminBlock])

  Combine an arbitrary number of AdminBlock classes and return a composite class. Fields from the resulting class are a combination of fields from the consitutent classes

  Parameters

    admin_block_classes – spread argument with AdminBlock classes to be combined

  Returns

    combination of all classes in admin_block_classes

building_blocks.admin.utils.make_fieldset_collapsible(admin_fieldset)

  Given an admin fieldset definition (just one fieldset/section), make it collapsible.

  Parameters

    admin_fieldset – one admin fieldset

  Returns

    the fieldset but collapsible