dash package

Subpackages

Submodules

dash.admin module

class dash.admin.DashboardEntryAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

Dashboard entry admin.

class Meta[source]
app_label = <django.utils.functional.__proxy__ object at 0x421f490>
DashboardEntryAdmin.fieldsets = ((None, {'fields': ('plugin_uid', 'plugin_data', 'layout_uid', 'placeholder_uid', 'position', 'workspace')}), (<django.utils.functional.__proxy__ object at 0x421f410>, {'fields': ('user',)}))
DashboardEntryAdmin.list_display = ('plugin_uid', 'plugin_uid_code', 'plugin_data', 'layout_uid', 'placeholder_uid', 'position', 'workspace', 'user')
DashboardEntryAdmin.list_editable = ('position',)
DashboardEntryAdmin.list_filter = ('user', 'workspace', 'layout_uid', 'placeholder_uid', 'plugin_uid')
DashboardEntryAdmin.media
DashboardEntryAdmin.queryset(request)[source]
DashboardEntryAdmin.readonly_fields = ('plugin_uid_code',)
class dash.admin.DashboardPluginAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

Dashboard plugin admin.

class Meta[source]
app_label = <django.utils.functional.__proxy__ object at 0x421f550>
DashboardPluginAdmin.fieldsets = ((None, {'fields': ('plugin_uid', 'users', 'groups')}),)
DashboardPluginAdmin.filter_horizontal = ('users', 'groups')
DashboardPluginAdmin.list_display = ('plugin_uid_admin', 'users_list', 'groups_list')
DashboardPluginAdmin.media
DashboardPluginAdmin.queryset(request)[source]
DashboardPluginAdmin.readonly_fields = ('plugin_uid', 'plugin_uid_admin')
class dash.admin.DashboardSettingsAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

Dashboard plugin admin.

class Meta[source]
app_label = <django.utils.functional.__proxy__ object at 0x421f6d0>
DashboardSettingsAdmin.fieldsets = ((None, {'fields': ('title', 'user', 'layout_uid', 'is_public')}),)
DashboardSettingsAdmin.list_display = ('title', 'user', 'layout_uid', 'is_public')
DashboardSettingsAdmin.media
DashboardSettingsAdmin.queryset(request)[source]
class dash.admin.DashboardWorkspaceAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

Dashboard workspace admin.

class Meta[source]
app_label = <django.utils.functional.__proxy__ object at 0x421f250>
DashboardWorkspaceAdmin.fieldsets = ((None, {'fields': ('name', 'position', 'is_public')}), (<django.utils.functional.__proxy__ object at 0x407bf90>, {'fields': ('user',)}), (<django.utils.functional.__proxy__ object at 0x421f210>, {'fields': ('slug',), 'classes': ('collapse',)}))
DashboardWorkspaceAdmin.list_display = ('name', 'slug', 'layout_uid', 'position', 'user', 'is_public')
DashboardWorkspaceAdmin.list_editable = ('position',)
DashboardWorkspaceAdmin.list_filter = ('layout_uid', 'is_public')
DashboardWorkspaceAdmin.media
DashboardWorkspaceAdmin.readonly_fields = ('slug',)

dash.base module

All uids are supposed to be pythonic function names (see PEP http://www.python.org/dev/peps/pep-0008/#function-names).

class dash.base.BaseDashboardLayout(user=None)[source]

Bases: object

Base layout.

Layouts consist of placeholders.

Properties :
  • uid (string): Layout unique identifier (globally).

  • name (string): Layout name.

  • description (string): Layout description.

  • placeholders (iterable): Iterable (list, tuple or set) of dash.base.BaseDashboardPlaceholder

    subclasses.

  • view_template_name (string): Temlate used to render the layout (view).

  • edit_template_name (string): Template used to render the layout (edit).

  • form_snippet_template_name (string): Template used to render the forms.

  • html_classes (string): Extra HTML class that layout should get.

  • cell_units (string):

  • media_css (list): List all specific stylesheets.

  • media_js (list): List all specific javascripts.

cell_units = None
collect_widget_media(dashboard_entries)[source]

Collects the widget media files.

Parameters:dashboard_entries (iterable) – Iterable of dash.models.DashboardEntry instances.
Return list:
description = None
edit_template_name = None
edit_template_name_ajax = None
form_snippet_template_name = 'dash/snippets/generic_form_snippet.html'
get_css(placeholders)[source]

Gets placeholder specific css.

Parameters:placeholders (iterable) – Iterable of dash.base.BaseDashboardPlaceholder subclassed instances.
Return string:
get_edit_template_name(request=None)[source]
get_grouped_dashboard_entries(dashboard_entries)[source]

Gets dashboard entries grouped by placeholder.

Parameters:dashboard_entries (iterable) – Iterable of dash.models.DashboardEntry objects.
Return list:
get_media_css()[source]

Gets all CSS media files (for the layout + plugins).

Return list:
get_media_js()[source]

Gets all JavaScript media files (for the layout + plugins).

Return list:
get_placeholder(uid, default=None)[source]
get_placeholder_instances(dashboard_entries=None, workspace=None, request=None)[source]

Gets placeholder instances.

Parameters:
  • dashboard_entries (iterable) – Iterable of dash.models.DashboardEntry objects.
  • request (django.http.HttpRequest) –
Return list:

List of dash.base.BaseDashboardPlaceholder subclassed instances.

get_placeholder_uids(request=None)[source]

Gets the list of placeholder uids.

Parameters:request (django.http.HttpRequest) –
Return list:
get_placeholders(request=None)[source]

Gets the list of placeholders registered for the layout.

Parameters:request (django.http.HttpRequest) –
Return itetable:
 List of placeholder classes. Override in your layout if you need a custom behaviour.
get_view_template_name(request=None, origin=None)[source]

Gets the view template name.

Parameters:
  • request (django.http.HttpRequest) –
  • origin (string) – Origin of the request. Hook to provide custom templates for apps. Example value: ‘public_dashboard’. Take the public_dashboard app as example.
html_class[source]

Class used in the HTML.

Return string:
html_classes = []
media_css = []
media_js = []
name = None
placeholders = []
primary_html_class[source]
render_for_edit(dashboard_entries=None, workspace=None, request=None)[source]

Renders the layout.

NOTE: This is not used at the moment. You most likely want the dash.views.edit_dashboard view.

Parameters:
  • dashboard_entries (iterable) –
  • workspace (string) – Current workspace.
  • request (django.http.HttpRequest) –
Return string:
render_for_view(dashboard_entries=None, workspace=None, request=None)[source]

Renders the layout.

NOTE: This is not used at the moment. You most likely want the dash.views.dashboard view.

Parameters:
  • dashboard_entries (iterable) –
  • workspace (string) – Current workspace.
  • request (django.http.HttpRequest) –
Return string:
uid = None
view_template_name = None
view_template_name_ajax = None
class dash.base.BaseDashboardPlaceholder(layout)[source]

Bases: object

Base placeholder.

Properties :
  • uid (string): Unique identifier (shouldn’t repeat within a single layout).
  • cols (int): Number of cols in the placeholder.
  • rows (int): Number of rows in the placeholder.
  • cell_width (int): Single cell (1x1) width.
  • cell_height (int): Single cell (1x1) height.
  • cell_margin_top (int): Top margin of a single cell.
  • cell_margin_right (int): Right margin of a single cell.
  • cell_margin_bottom (int): Bottom margin of a single cell.
  • cell_margin_left (int): Left margin of a single cell.
  • view_template_name (string): Template to be used for rendering the placeholder in view mode.
  • edit_template_name (string): Template to be used for rendering the placeholder in edit mode.
  • html_classes (string): Extra HTML class that layout should get.
cell_height = None
cell_margin_bottom = 0
cell_margin_left = 0
cell_margin_right = 0
cell_margin_top = 0
cell_units[source]
cell_width = None
cols = None
css[source]

CSS styles for the placeholders and plugins. The placeholder dimensions as well as columns sizes, should be handled here. Since we are in a placeholder and a placeholder has a defined number of rows and columns and each reneder has just a fixed amount of rows and columns defined, we can render the top left corners generic css classes.

Cells do NOT have margins or paddings. This is essential (since all the plugins are positioned absolutely). If you want to have padding in your plugin widget, specify the plugin-content-wrapper class style in your specific layout/theme.

Example :
.placeholder .plugin .plugin-content-wrapper {

padding: 5px;

}

Return string:
edit_template_name = ''
get_cell_height()[source]

Gets a single cell height, with respect to margins.

Return int:
get_cell_width()[source]

Gets a single cell width, with respect to margins.

Return int:
get_edit_template_name()[source]
get_view_template_name()[source]
html_class[source]

Class used in the HTML.

Return string:
html_classes = []
html_id[source]

ID used in the HTML. Unique.

Return string:
load_dashboard_entries(dashboard_entries=None)[source]

Feed the dashboard entries to the layout for rendering later.

Parameters:dashboard_entries (iterable) – Iterable of dash.models.DashboardEntry objects.
primary_html_class[source]
render_for_edit()[source]

Renders the placeholder for edit mode.

Parameters:
  • workspace (string) – Current workspace slug.
  • request (django.http.HttpRequest) –
Return string:
render_for_view()[source]

Renders the placeholder for view mode.

Return string:
rows = None
uid = None
view_template_name = ''
widget_inner_height(rows)[source]

The inner height of the widget to be rendered.

Return int:
widget_inner_width(cols)[source]

The inner width of the widget to be rendered.

class dash.base.BaseDashboardPlugin(layout_uid, placeholder_uid, workspace=None, user=None, position=None)[source]

Bases: object

Base dashboard plugin from which every plugin should inherit.

Properties :
  • uid (string): Plugin uid (obligatory). Example value: ‘dummy’, ‘wysiwyg’, ‘news’.

  • name (string): Plugin name (obligatory). Example value: ‘Dummy plugin’, ‘WYSIWYG’, ‘Latest news’.

  • description (string): Plugin decription (optional). Example value: ‘Dummy plugin used just for testing’.

  • help_text (string): Plugin help text (optional). This text would be shown in

    dash.views.add_dashboard_entry and dash.views.edit_dashboard_entry views.

  • form: Plugin form (optional). A subclass of django.forms.Form. Should be given in case plugin is configurable.

  • add_form_template (str) (optional): Add form template (optional). If given, overrides the dash.views.add_dashboard_entry default template.

  • edit_form_template (string): Edit form template (optional). If given, overrides the dash.views.edit_dashboard_entry default template.

  • html_classes (list): List of extra HTML classes for the plugin.

  • group (string): Plugin are grouped under the specified group. Override in your plugin if necessary.

add_form_template = None
delete_plugin_data()[source]

Used in dash.views.delete_dashboard_entry. Fired automatically, when dash.models.DashboardEntry object is about to be deleted. Make use of it if your plugin creates database records or files that are not monitored externally but by dash only.

description = None
edit_form_template = None
form = None
get_form()[source]

Get the plugin form class. Override this method in your subclassed dash.base.DashboardPlugin class when you need your plugin setup to vary depending on the placeholder, workspace, user or request given. By default returns the value of the form attribute defined in your plugin.

Return django.forms.Form|django.forms.ModelForm:
 Subclass of django.forms.Form or django.forms.ModelForm.
get_initialised_create_form(data=None, files=None)[source]

Used dash.views.add_dashboard_entry view to gets initialised form for object to be created.

get_initialised_create_form_or_404(data=None, files=None)[source]

Same as get_initialised_create_form but raises django.http.Http404 on errors.

get_initialised_edit_form(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.util.ErrorList'>, label_suffix=':', empty_permitted=False, instance=None)[source]

Used in dash.views.edit_dashboard_entry view.

get_initialised_edit_form_or_404(data=None, files=None, auto_id='id_%s', prefix=None, error_class=<class 'django.forms.util.ErrorList'>, label_suffix=':', empty_permitted=False)[source]

Same as get_initialised_edit_form but raises django.http.Http404 on errors.

get_instance()[source]
get_plugin_form_data()[source]

Fed as initial argument to the plugin form when initialising the instance for adding or editing the plugin. Override in your plugin class if you need customisations.

get_position()[source]

Gets the exact position of the plugin widget in the placeholder (row number, col number).

Return tuple:Tuple of row and col numbers.
get_widget(request=None, as_instance=False)[source]

Gets the plugin widget.

Parameters:
  • request (django.http.HttpRequest) –
  • as_instance (bool) –
Return mixed:

Subclass of dash.base.BaseDashboardPluginWidget or instance of subclassed dash.base.BaseDashboardPluginWidget object.

group = 'General'
help_text = None
html_class[source]

A massive work on positioning the plugin and having it to be displayed in a given width is done here. We should be getting the plugin widget for the plugin given and based on its’ properties (static!) as well as on plugin position (which we have from model), we can show the plugin with the exact class.

html_classes = []
html_id[source]
load_plugin_data(plugin_data)[source]

Loads the plugin data saved in dash.models.DashboardEntry. Plugin data is saved in JSON string.

Parameters:plugin_data (string) – JSON string with plugin data.
name = None
post_processor()[source]

Redefine in your subclassed plugin when necessary.

Post process plugin data here (before rendering). This methid is being called after the data has been loaded into the plugin.

Note, that request (django.http.HttpRequest) is available (self.request).

pre_processor()[source]

Redefine in your subclassed plugin when necessary.

Pre process plugin data (before rendering). This method is being called before the data has been loaded into the plugin.

Note, that request (django.http.HttpRequest) is available (self.request).

process(plugin_data=None, fetch_related_data=False)[source]

Init plugin with data.

process_plugin_data(fetch_related_data=False)[source]

Processes the plugin data.

render(request=None)[source]

Renders the plugin HTML (for dashboard workspace).

Parameters:request (django.http.HttpRequest) –
Return string:
uid = None
update_plugin_data(dashboard_entry)[source]

Used in dash.management.commands.dash_update_plugin_data.

Some plugins would contain data fetched from various sources (models, remote data). Since dashboard entries are by definition loaded extremely much, you are advised to store as much data as possible in plugin_data field of dash.models.DashboardEntry. Some externally fetched data becomes invalid after some time and needs updating. For that purpose, in case if your plugin needs that, redefine this method in your plugin. If you need your data to be periodically updated, add a cron-job which would run dash_update_plugin_data management command (see dash.management.commands.dash_update_plugin_data module).

Parameters:dash.models.DashboardEntry – Instance of dash.models.DashboardEntry.
class dash.base.BaseDashboardPluginWidget(plugin)[source]

Bases: object

Base plugin widget.

So, if we would want to register a plugin widget (renderer) for some layout, we would first define the plugin widget and then just write:

>>> plugin_widget_registry.register(DummyPluginWidget)

Plugin widget is always being registered for a placeholder. Placeholder in its’ turn has number of rows and columns. Since we register each widget for a (layout, placeholder, plugin) combination separately, it fits the needs and requirements perfectly. In that way we are able to tell, wheither plugin has a widget available and actually valid (qua dimensions) for the placeholder. Plugin is just data. Nothing more. Widget operates with that data. Thus, widget has number of rows and columns it occupies in the placeholder registered. By default, number of rows and columns is set to 1, which means that a plugin occupies just 1 cell. But, certainly, there can be plugins that occupy more space in a placeholder.

cols = 1
get_height()[source]

Gets widget height.

Return int:
get_size(delta_width=0, delta_height=0)[source]

Gets widget size.

Parameters:
  • delta_width (int) –
  • delta_height (int) –
Return tuple:
get_width()[source]

Gets widget width.

Return int:
html_class = ''[source]
html_classes = []
layout_uid = None
media_css = []
media_js = []
placeholder_uid = None
plugin_uid = None
render(request=None)[source]
rows = 1
dash.base.get_registered_plugins()[source]

Gets a list of registered plugins in a form if tuple (plugin name, plugin description). If not yet autodiscovered, autodiscovers them.

Return list:
dash.base.get_registered_plugin_uids()[source]

Gets a list of registered plugin uids as a list . If not yet autodiscovered, autodiscovers them.

Return list:
dash.base.validate_plugin_uid(plugin_uid)[source]

Validates the plugin uid.

Parameters:plugin_uid (string) –
Return bool:
dash.base.get_registered_layouts()[source]

Gets registered layouts.

dash.base.get_registered_layout_uids()[source]

Gets uids of registered layouts.

dash.base.get_layout(layout_uid=None, as_instance=False)[source]

Gets the layout by layout_uid given. If left empty, takes the default one chosen in settings.

Raises a dash.exceptions.NoActiveLayoutChosen when no default layout could be found.

Return dash.base.BaseDashboardLayout:
 Sublcass of dash.base.BaseDashboardLayout.
dash.base.validate_placeholder_uid(layout, placeholder_uid)[source]

Validates the placeholder.

Parameters:
  • layout_uid (string) –
  • placeholder_uid (string) –
Return bool:
dash.base.ensure_autodiscover()[source]

Ensures that plugins are autodiscovered.

class dash.base.DashboardPluginFormBase[source]

Bases: object

Not a form actually. Defined for magic only.

Property iterable plugin_data_fields:
 

Fields to get when calling the get_plugin_data method. These field will be JSON serialized. All other fields, even if they are part of the form, won’t be. Make sure all fields are serializable. If some of them aren’t, override the save_plugin_data method and make them serializable there. See dash.contrib.plugins.image.forms as a good example.

Example :
>>> plugin_data_fields = (
>>>    ('name', ''),
>>>    ('active': False)
>>> )
get_plugin_data(request=None)[source]

Data that would be saved in the plugin_data field of the dash.models.DashboardEntry subclassed model.

Parameters:request (django.http.HttpRequest) –
plugin_data_fields = None
save_plugin_data(request=None)[source]

Dummy, but necessary.

dash.base.collect_widget_media(dashboard_entries)[source]

Collects the widget media for dashboard entries given.

Parameters:dashboard_entries (iterable) – Iterable of dash.models.DashboardEntry instances.
Return dict:Returns a dict containing the ‘js’ and ‘css’ keys. Correspondent values of those keys are lists containing paths to the CSS and JS media files.

dash.conf module

dash.conf.get_setting(setting, override=None)[source]

Get a setting from dash conf module, falling back to the default.

If override is not None, it will be used instead of the setting.

Parameters:
  • setting – String with setting name
  • override – Value to use when no setting is available. Defaults to None.
Returns:

Setting value.

dash.decorators module

dash.decorators.permissions_required(perms, satisfy='all', login_url=None, raise_exception=False)[source]

Checks for the permissions given based on the strategy chosen.

Parameters:
  • perms (iterable) –
  • satisfy (string) – Allowed values are “all” and “any”.
  • login_url (string) –
  • raise_exception (bool) – If set to True, the PermissionDenied exception is raised on failures.
Return bool:
Example :
>>> @login_required
>>> @permissions_required(satisfy='any', perms=[
>>>     'dash.add_dashboardentry', 'dash.change_dashboardentry', 'dash.delete_dashboardentry',
>>>     'dash.add_dashboardworkspace', 'dash.change_dashboardworkspace', 'dash.delete_dashboardworkspace',
>>>     'dash.add_dashboardsettings', 'dash.change_dashboardsettings', 'dash.delete_dashboardsettings',
>>> ])
>>> def edit_dashboard(request):
>>>     # your code
dash.decorators.all_permissions_required(perms, login_url=None, raise_exception=False)[source]
Example :
>>> @login_required
>>> @all_permissions_required([
>>>     'dash.add_dashboardentry', 'dash.change_dashboardentry', 'dash.delete_dashboardentry',
>>>     'dash.add_dashboardworkspace', 'dash.change_dashboardworkspace', 'dash.delete_dashboardworkspace',
>>>     'dash.add_dashboardsettings', 'dash.change_dashboardsettings', 'dash.delete_dashboardsettings',
>>> ])
>>> def edit_dashboard(request):
>>>     # your code
dash.decorators.any_permission_required(perms, login_url=None, raise_exception=False)[source]
Example :
>>> @login_required
>>> @any_permission_required([
>>>     'dash.add_dashboardentry', 'dash.change_dashboardentry', 'dash.delete_dashboardentry',
>>>     'dash.add_dashboardworkspace', 'dash.change_dashboardworkspace', 'dash.delete_dashboardworkspace',
>>>     'dash.add_dashboardsettings', 'dash.change_dashboardsettings', 'dash.delete_dashboardsettings',
>>> ])
>>> def edit_dashboard(request):
>>>     # your code
dash.decorators.edit_dashboard_permission_required(login_url=None, raise_exception=False)[source]

Checks if user has permissions to edit dashboard. Simply, check is successfull if any of the following permission checks are satisfied:

  • Can add dashboard entry
  • Can change dashboard entry
  • Can delete dashboard entry
  • Can add dashboard workspace
  • Can change dashboard workspace
  • Can delete dashboard workspace
  • Can add dashboard settings
  • Can change dashboard settings
  • Can delete dashboard settings
Example :
>>> @login_required
>>> @edit_dashboard_permission_required() # Do not forget the brackets!
>>> def edit_dashboard(request):
>>>     # your code

dash.defaults module

dash.discover module

dash.discover.autodiscover()[source]

Autodiscovers files that should be found by dash.

dash.exceptions module

exception dash.exceptions.InvalidRegistryItemType[source]

Bases: exceptions.ValueError

Raised when an attempt is made to register an item in the registry which does not have a proper type.

exception dash.exceptions.LayoutDoesNotExist[source]

Bases: exceptions.Exception

Raised when layout does not exist.

exception dash.exceptions.PluginWidgetOutOfPlaceholderBoundaries[source]

Bases: exceptions.Exception

Raised when plugin widget is out of placeholder boundaries.

dash.fields module

class dash.fields.OrderField(verbose_name=None, name=None, primary_key=False, max_length=None, unique=False, blank=False, null=False, db_index=False, rel=None, default=<class django.db.models.fields.NOT_PROVIDED at 0x3dc1a10>, editable=True, serialize=True, unique_for_date=None, unique_for_month=None, unique_for_year=None, choices=None, help_text=u'', db_column=None, db_tablespace=None, auto_created=False, validators=[], error_messages=None)[source]

Bases: django.db.models.fields.IntegerField

@author http://djangosnippets.org/users/zenx/ @source http://djangosnippets.org/snippets/1861/

OrderField for models from http://ianonpython.blogspot.com/2008/08/orderfield-for-django-models.html and updated to use a django aggregation function. This field sets a default value as an auto-increment of the maximum value of the field +1.

Ignores the incoming value and instead gets the maximum plus one of the field.

This works really well in combination with “sortable_list.js”. There are several things you should know:
  • order field shall be null=True, blank=True
  • order field shall not be unique

If above mentioned is True, you can use jQuery drag-n-drop widget in your Django-admin. See the following example:

class Media: # This belongs to your Admin class (admin.ModelAdmin)
js = [
‘/media/js/jquery-1.6.2.min.js’, ‘/media/js/jquery-ui-1.8.16.custom.min.js’, ‘/media/js/sortable_list.js’

]

formfield_(**kwargs)[source]
pre_save(model_instance, value)[source]

dash.forms module

class dash.forms.DashboardWorkspaceForm(*args, **kwargs)[source]

Bases: django.forms.models.ModelForm

Dashboard workspace form.

class Meta[source]
exclude = ('position', 'layout_uid')
model

alias of DashboardWorkspace

DashboardWorkspaceForm.base_fields = {'user': <django.forms.models.ModelChoiceField object at 0x49534d0>, 'name': <django.forms.fields.CharField object at 0x504bd10>, 'is_public': <django.forms.fields.BooleanField object at 0x505b110>}
DashboardWorkspaceForm.declared_fields = {}
DashboardWorkspaceForm.media

dash.helpers module

dash.helpers.slugify_workspace(s)
dash.helpers.lists_overlap(sub, main)[source]
dash.helpers.iterable_to_dict(items, key_attr_name)[source]

Converts iterable of certain objects to dict.

Parameters:
  • items (iterable) –
  • key_attr_name (string) – Attribute to use as a dictionary key.
Return dict:

dash.models module

class dash.models.DashboardSettings(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Dashboard settings.

Properties :
  • user (django.contrib.auth.models.User: User owning the plugin.
  • layout_uid (str): Users’ preferred layout.
  • title (str): Dashboard title.
  • is_public (bool): If set to True, available as public (read-only mode).
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception DashboardSettings.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

DashboardSettings.objects = <django.db.models.manager.Manager object at 0x4217250>
DashboardSettings.user
class dash.models.DashboardWorkspace(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Dashboard workspace.

Properties :
  • user (django.contrib.auth.models.User: User owning the plugin.
  • layout_uid (str): Layout to which the entry belongs to.
  • name (str): Dashboard name.
  • slug (str): Dashboard slug.
  • position (int): Dashboard position.
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception DashboardWorkspace.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

DashboardWorkspace.dashboardentry_set
DashboardWorkspace.get_absolute_url(*moreargs, **morekwargs)[source]

Absolute URL, which goes to the dashboard workspace page.

Return string:
DashboardWorkspace.get_entries(user)[source]

Gets all dashboard entries for user given.

Parameters:user (django.contrib.auth.models.User) –
Return iterable:
 
DashboardWorkspace.objects = <django.db.models.manager.Manager object at 0x4217c50>
DashboardWorkspace.user
class dash.models.DashboardEntry(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Dashboard entry (widget).

Since workspace can be nullable (default), we duplicate the layout_uid.

Properties :
  • user (django.contrib.auth.models.User: User owning the plugin.
  • workspace (dash.models.DashboardWorkspace): Workspace to which the plugin belongs to. If left blank, entry belongs to default workspace.
  • layout_uid (str): Layout to which the entry belongs to.
  • placeholder_uid (str): Placeholder to which the entry belongs to.
  • plugin_uid (str): Plugin name.
  • plugin_data (str): JSON formatted string with plugin data.
  • position (int): Entry position.
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception DashboardEntry.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

DashboardEntry.get_plugin(fetch_related_data=False, request=None)[source]

Gets the plugin class (by plugin_name property), makes an instance of it, serves the data stored in plugin_data field (if available). Once all is done, plugin is ready to be rendered.

Parameters:fetch_related_data (bool) – When set to True, plugin is told to re-fetch all related data (stored in models or other sources).
Return dash.base.DashboardPlugin:
 Subclass of dash.base.DashboardPlugin.
DashboardEntry.objects = <dash.models.DashboardEntryManager object at 0x4218390>
DashboardEntry.plugin_uid_code()[source]

Mainly used in admin.

DashboardEntry.user
DashboardEntry.workspace
class dash.models.DashboardPlugin(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Dashboard plugin. Used when dash.settings.RESTRICT_PLUGIN_ACCESS is set to True.

Properties :
  • plugin_uid (str): Plugin UID.
  • users (django.contrib.auth.models.User): White list of the users allowed to use the dashboard plugin.
  • groups (django.contrib.auth.models.Group): White list of the user groups allowed to use the dashboard plugin.
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception DashboardPlugin.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

DashboardPlugin.groups
DashboardPlugin.groups_list()[source]

Flat list (comma separated string) of groups allowed to use the dashboard plugin. Used in Django admin.

Return string:
DashboardPlugin.objects = <dash.models.DashboardPluginManager object at 0x4218dd0>
DashboardPlugin.plugin_uid_admin()[source]

Mainly used in admin.

DashboardPlugin.plugin_uid_code()[source]

Mainly used in admin.

DashboardPlugin.users
DashboardPlugin.users_list()[source]

Flat list (comma separated string) of users allowed to use the dashboard plugin. Used in Django admin.

Return string:

dash.settings module

  • RESTRICT_PLUGIN_ACCESS (bool): If set to True, (Django) permission system for dash plugins is enabled.
  • PLUGINS_MODULE_NAME (str): Name of the module to placed in the (external) apps in which the dash plugin code should be implemented and registered.
  • ACTIVE_LAYOUT (str): Active layout UID.
  • LAYOUTS_MODULE_NAME (str): Name of the python module to be placed in (external) apps in which the dash layouts should be implemented and registered.
  • DEFAULT_WORKSPACE_NAME (str): Name of the default workspace.
  • DEFAULT_PLACEHOLDER_VIEW_TEMPLATE_NAME (str): Default template name for the placeholder view.
  • DEFAULT_PLACEHOLDER_EDIT_TEMPLATE_NAME (str): Default template name for the placeholder edit.
  • LAYOUT_CELL_UNITS (str): Layout cell units. Allowed values are em, px, pt, %.
  • DISPLAY_AUTH_LINK (bool): If set to True, the log in or log out link is shown in the Dash drop-down menu.
  • DEBUG

dash.tests module

dash.urls module

dash.utils module

dash.utils.get_allowed_plugin_uids(user)[source]

Gets allowed plugins uids for user given.

Parameters:import User (django.contrib.auth.models) –
Return list:
dash.utils.get_user_plugins(user)[source]

Gets a list of user plugins in a form if tuple (plugin name, plugin description). If not yet autodiscovered, autodiscovers them.

Return list:
dash.utils.get_user_plugin_uids()[source]

Gets a list of user plugin uids as a list . If not yet autodiscovered, autodiscovers them.

Return list:
dash.utils.get_widgets(layout, placeholder, user=None, workspace=None, position=None, occupied_cells=[])[source]

Gets widgets. In case if in restricted mode (RESTRICT_PLUGIN_ACCESS is set to True), user argument should be provided. Based on it, the list of plugins is returned. Restrictions are bypassed in case if RESTRICT_PLUGIN_ACCESS is set to False or user given is a superuser.

Placeholders are validated already. We don’t need to have validation here.

Parameters:
  • layout (dash.base.BaseDashLayout) – Layout object.
  • placeholder_uid (string) – Placeholder uid.
  • user (django.contrib.auth.models.User) –
  • workspace (string) – Workspace slug.
  • position (int) – Plugin position.
  • occupied_cells (list) – List of already occupied cells.
Return list:
dash.utils.update_plugin_data()[source]

Updates the plugin data for all dashboard entries of all users. Rules for update are specified in the plugin itself.

dash.utils.sync_plugins()[source]

Syncs the registered plugin list with data in dash.models.DashboardPlugin.

dash.utils.get_workspaces(user, layout_uid=None, workspace=None, public=False)[source]

Gets previous, current, next and and a queryset of all workspaces.

Parameters:
  • workspace (string) –
  • django.contrib.auth.models.User
Return dict:
dash.utils.build_cells_matrix(user, layout, placeholder, workspace=None)[source]

Builds the cells matrix.

Parameters:
  • user (django.contrib.auth.models.User) –
  • placeholder_uid (string) –
  • workspace (string) – Workspace slug.
Return list:

List of cells occupied.

dash.utils.get_or_create_dashboard_settings(user)[source]

Gets dashboard settings for the user given. If no settings found, creates default settings.

Parameters:django.contrib.auth.models.User
Return dash.models.DashboardSettings:
 Returns dash.models.DashboardSettings instance.
dash.utils.get_dashboard_settings(username)[source]

Gets dashboard settings for the user given. If no settings found, creates default settings.

Parameters:username (string) –
Return dash.models.DashboardSettings:
 Returns dash.models.DashboardSettings instance.
dash.utils.get_public_dashboard_url(dashboard_settings)[source]

Gets resolved public dashboard URL (if public dashboard app is installed == present in the global urls module of the project).

Parameters:dash.models.DashboardSettings – Instance of dash.models.DashboardSettings.
Return string:

dash.views module

dash.views.add_dashboard_entry(request, *args, **kwargs)[source]

Add dashboard entry.

Parameters:
  • request (django.http.HttpRequest) –
  • placeholder_uid (string) – Placeholder UID.
  • plugin_uid (string) – Plugin UID.
  • workspace (string) – Workspace slug.
  • position (int) – If given, provided as position for the plugin (conflict resolution should take place).
  • template_name (string) –
  • template_name_ajax (string) – Template used for AJAX requests.
Return django.http.HttpResponse:
 
dash.views.create_dashboard_workspace(request, *args, **kwargs)[source]

Create dashboard workspace.

Parameters:
  • request (django.http.HttpRequest) –
  • template_name (string) –
  • template_name_ajax (string) – Template used for AJAX calls.
Return django.http.HttpResponse:
 
dash.views.dashboard(request, *args, **kwargs)[source]

Dashboard.

Parameters:
  • request (django.http.HttpRequest) –
  • workspace (string) – Workspace slug. If given, the workspace loaded. Otherwise we deal with no workspace.
Return django.http.HttpResponse:
 
dash.views.dashboard_workspaces(request, *args, **kwargs)[source]

Workspaces list.

Parameters:
  • request (django.http.HttpRequest) –
  • workspace (string) – Workspace slug.
  • template_name (string) –
  • template_name_ajax (string) – Tempalte used for AJAX requests.
Return django.http.HttpResponse:
 
dash.views.delete_dashboard_entry(request, *args, **kwargs)[source]

Remove dashboard entry.

Parameters:
  • request (django.http.HttpRequest) –
  • entry_id (int) – ID of the dashboard entry to delete.
Return django.http.HttpResponse:
 
dash.views.delete_dashboard_workspace(request, *args, **kwargs)[source]

Delete dashboard workspace.

Parameters:
  • request (django.http.HttpRequest) –
  • workspace_id (int) – DashboardWorkspace id.
  • template_name (string) –
  • template_name_ajax (string) – Template used for AJAX calls.
Return django.http.HttpResponse:
 
dash.views.edit_dashboard(request, *args, **kwargs)[source]

Edit dashboard.

Parameters:
  • request (django.http.HttpRequest) –
  • workspace (string) – Workspace slug. If given, the workspace loaded. Otherwise we deal with no workspace.
Return django.http.HttpResponse:
 
dash.views.edit_dashboard_entry(request, *args, **kwargs)[source]

Edit dashboard entry.

Parameters:
  • request (django.http.HttpRequest) –
  • entry_id (int) – ID of the dashboard entry to edit.
  • template_name (string) –
  • template_name_ajax (string) – Tempalte used for AJAX requests.
Return django.http.HttpResponse:
 
dash.views.edit_dashboard_settings(request, *args, **kwargs)[source]

Edit dashboard settings.

Parameters:
  • request (django.http.HttpRequest) –
  • template_name (string) –
  • template_name_ajax (string) – Template used for AJAX calls.
Return django.http.HttpResponse:
 
dash.views.edit_dashboard_workspace(request, *args, **kwargs)[source]

Edit dashboard workspace.

Parameters:
  • request (django.http.HttpRequest) –
  • workspace_id (int) – DashboardWorkspace ID.
  • template_name (string) –
  • template_name_ajax (string) – Template used for AJAX calls.
Return django.http.HttpResponse:
 
dash.views.plugin_widgets(request, *args, **kwargs)[source]

Plugin widgets view. Lists all the widgets for the placeholder and workspace given.

Parameters:
  • request (django.http.HttpRequest) –
  • placeholder_uid (string) – Placeholder UID.
  • position (int) – Position on the dashboard to which the widget is to be added.
  • template_name (string) –
  • template_name_ajax (string) – Tempalte used for AJAX requests.
Return django.http.HttpResponse:
 

dash.widgets module

class dash.widgets.BooleanRadioSelect(*args, **kwargs)[source]

Bases: django.forms.widgets.RadioSelect

Boolean radio select for Django.

Example :
>>> class DummyForm(forms.Form):
>>>     agree = forms.BooleanField(label=_("Agree?"), required=False, widget=BooleanRadioSelect)
media

Module contents

Read the Docs v: 0.3.2
Versions
latest
0.3.2
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.