fluent_contents.admin¶
The admin classes of fluent_contents provide the necessary integration with existing admin interfaces.
The placeholder interfaces are implemented by model admin inlines, so they can be added to almost any admin interface. To assist in configuring the admin interface properly, there are a few base classes:
- For models with a
PlaceholderField
, use thePlaceholderFieldAdmin
as base class. - For CMS models, use the
PlaceholderEditorAdmin
as base class.
Both classes ensure the placeholders and inlines are properly setup.
The PlaceholderEditorAdmin
class¶
-
class
fluent_contents.admin.
PlaceholderEditorAdmin
(model, admin_site)¶ The base functionality for
ModelAdmin
dialogs to display a placeholder editor with plugins. It loads the inlines usingget_extra_inlines()
.It loads the
PlaceholderEditorInline
, which displays each placeholder in separate tabs:-
get_extra_inlines
()¶ Return the extra inlines for the placeholder editor. It loads the
placeholder_inline
first, followed by the inlines for theContentItem
classes.
-
get_inline_instances
(request, *args, **kwargs)¶ Create the inlines for the admin, including the placeholder and contentitem inlines.
-
get_placeholder_data_view
(request, object_id)¶ Return the placeholder data as dictionary. This is used in the client for the “copy” functionality.
-
placeholder_inline
¶ alias of
PlaceholderEditorInline
-
save_formset
(request, form, formset, change)¶ Given an inline formset save it to the database.
-
The PlaceholderFieldAdmin
class¶
-
class
fluent_contents.admin.
PlaceholderFieldAdmin
(model, admin_site)¶ The base functionality for
ModelAdmin
dialogs to display placeholder fields.This class loads the
ContentItem
inlines, and initializes the frontend editor for thePlaceholderField
. The placeholder will be displayed in the admin:-
formfield_for_dbfield
(db_field, request=None, **kwargs)¶ Hook for specifying the form Field instance for a given database Field instance.
If kwargs are given, they’re passed to the form Field’s constructor.
-
get_all_allowed_plugins
()¶ Return which plugins are allowed by the placeholder fields.
-
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.
-
get_placeholder_data
(request, obj=None)¶ Return the data of the placeholder fields.
-
placeholder_inline
¶ alias of
PlaceholderFieldInline
-
The PlaceholderEditorBaseMixin
class¶
-
class
fluent_contents.admin.
PlaceholderEditorBaseMixin
¶ Base interface/mixin for a
ModelAdmin
to provide thePlaceholderEditorInline
with initial data. This class is implemented by thePlaceholderEditorAdmin
andPlaceholderFieldAdmin
classes.-
get_all_allowed_plugins
()¶ Return all plugin categories which can be used by placeholder content. By default, all plugins are allowed. Individual slot names may further limit the plugin set.
Return type: list of ContentPlugin
-
get_placeholder_data
(request, obj=None)¶ Return the placeholders that the editor should initially display. The function should return a list of
PlaceholderData
classes. These classes can either be instantiated manually, or read from a template using the fluent_contents.analyzer module for example.
-
The PlaceholderEditorInline
class¶
-
class
fluent_contents.admin.
PlaceholderEditorInline
(parent_model, admin_site)¶ The placeholder editor, implemented as an admin inline. It displays tabs for each inline placeholder, and displays
ContentItem
plugins in the tabs.It should be inserted in the
ModelAdmin.inlines
before the inlines that theget_content_item_inlines()
function generates. The ContentItem inlines look for thePlaceholder
object that was created just before their invocation.To fetch the initial data, the inline will attempt to find the parent model, and call
get_placeholder_data()
. When the admin models inherit fromPlaceholderEditorAdmin
orPlaceholderFieldAdmin
this will be setup already.-
formset
¶ alias of
PlaceholderInlineFormSet
-
get_all_allowed_plugins
()¶ Return all plugin categories which can be used by placeholder content. This is the sum of all allowed plugins by the various slots on the page. It accesses the parent
PlaceholderEditorBaseMixin
by default to request the information. This field is used in the template.
-
get_formset
(request, obj=None, **kwargs)¶ Pre-populate formset with the initial placeholders to display.
-
model
¶ alias of
fluent_contents.models.db.Placeholder
-
The get_content_item_inlines
function¶
-
fluent_contents.admin.
get_content_item_inlines
(plugins=None, base=<class 'fluent_contents.admin.contentitems.BaseContentItemInline'>)¶ Dynamically generate genuine django inlines for all registered content item types. When the plugins parameter is
None
, all plugin inlines are returned.