fluent_dashboard.items

Additional menu items.

The CmsModelList class

class fluent_dashboard.items.CmsModelList(title=None, models=None, exclude=None, **kwargs)

A custom ModelList that displays menu items for each model. It has a strong bias towards sorting CMS apps on top.

init_with_context(context)

Initialize the menu.

is_item_visible(model, perms)

Return whether the model should be displayed in the menu. By default it checks for the perms['change'] value; only items with change permission will be displayed. This function can be extended to support “view permissions” for example.

Parameters:
  • model – The model class
  • perms – The permissions from ModelAdmin.get_model_perms().

The ReturnToSiteItem class

class fluent_dashboard.items.ReturnToSiteItem(title=None, url=None, **kwargs)

A “Return to site” button for the menu. It redirects the user back to the frontend pages.

By default, it attempts to find the current frontend URL that corresponds with the model that’s being edited in the admin ‘change’ page. If this is not possible, the default URL (/) will be used instead.

The menu item has a custom returntosite CSS class to be distinguishable between the other menu items.

get_edited_object(request)

Return the object which is currently being edited. Returns None if the match could not be made.

get_object_by_natural_key(app_label, model_name, object_id)

Return a model based on a natural key. This is a utility function for get_edited_object().

init_with_context(context)

Find the current URL based on the context. It uses get_edited_object() to find the model, and calls get_absolute_url() to get the frontend URL.

title = 'Return to site'

Set the default title

url = '/'

Set the default URL