dash package¶
Subpackages¶
- dash.contrib package
- Subpackages
- dash.contrib.apps package
- dash.contrib.layouts package
- Subpackages
- dash.contrib.layouts.android package
- dash.contrib.layouts.bootstrap2 package
- Submodules
- dash.contrib.layouts.bootstrap2.apps module
- dash.contrib.layouts.bootstrap2.conf module
- dash.contrib.layouts.bootstrap2.dash_layouts module
- dash.contrib.layouts.bootstrap2.dash_plugins module
- dash.contrib.layouts.bootstrap2.dash_widgets module
- dash.contrib.layouts.bootstrap2.defaults module
- dash.contrib.layouts.bootstrap2.forms module
- dash.contrib.layouts.bootstrap2.settings module
- Module contents
- dash.contrib.layouts.windows8 package
- Module contents
- Subpackages
- dash.contrib.plugins package
- Subpackages
- dash.contrib.plugins.dummy package
- dash.contrib.plugins.image package
- Submodules
- dash.contrib.plugins.image.apps module
- dash.contrib.plugins.image.conf module
- dash.contrib.plugins.image.dash_plugins module
- dash.contrib.plugins.image.dash_widgets module
- dash.contrib.plugins.image.defaults module
- dash.contrib.plugins.image.forms module
- dash.contrib.plugins.image.helpers module
- dash.contrib.plugins.image.settings module
- Module contents
- dash.contrib.plugins.memo package
- dash.contrib.plugins.rss_feed package
- Subpackages
- Submodules
- dash.contrib.plugins.rss_feed.apps module
- dash.contrib.plugins.rss_feed.dash_plugins module
- dash.contrib.plugins.rss_feed.dash_widgets module
- dash.contrib.plugins.rss_feed.defaults module
- dash.contrib.plugins.rss_feed.forms module
- dash.contrib.plugins.rss_feed.helpers module
- dash.contrib.plugins.rss_feed.urls module
- dash.contrib.plugins.rss_feed.views module
- Module contents
- dash.contrib.plugins.url package
- Submodules
- dash.contrib.plugins.url.admin module
- dash.contrib.plugins.url.apps module
- dash.contrib.plugins.url.conf module
- dash.contrib.plugins.url.dash_plugins module
- dash.contrib.plugins.url.dash_widgets module
- dash.contrib.plugins.url.defaults module
- dash.contrib.plugins.url.forms module
- dash.contrib.plugins.url.models module
- dash.contrib.plugins.url.settings module
- Module contents
- dash.contrib.plugins.video package
- dash.contrib.plugins.weather package
- Submodules
- dash.contrib.plugins.weather.apps module
- dash.contrib.plugins.weather.conf module
- dash.contrib.plugins.weather.dash_plugins module
- dash.contrib.plugins.weather.dash_widgets module
- dash.contrib.plugins.weather.defaults module
- dash.contrib.plugins.weather.forms module
- dash.contrib.plugins.weather.settings module
- Module contents
- Module contents
- Subpackages
- Module contents
- Subpackages
- dash.lib package
- dash.management package
- dash.templatetags package
Submodules¶
dash.admin module¶
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): Template used to render the layout (view).
- edit_template_name (string): Template used to render the layout (edit).
- plugin_widgets_template_name_ajax (string): Template used to render the plugin widgets popup.
- 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.
-
add_dashboard_entry_ajax_template_name
= None¶
-
add_dashboard_entry_template_name
= None¶
-
cell_units
= None¶
-
collect_widget_media
(dashboard_entries)[source]¶ Collect the widget media files.
Parameters: dashboard_entries (iterable) – Iterable of dash.models.DashboardEntry
instances.Return list:
-
create_dashboard_workspace_ajax_template_name
= None¶
-
create_dashboard_workspace_template_name
= None¶
-
description
= None¶
-
edit_dashboard_entry_ajax_template_name
= None¶
-
edit_dashboard_entry_template_name
= None¶
-
edit_dashboard_workspace_ajax_template_name
= None¶
-
edit_dashboard_workspace_template_name
= None¶
-
edit_template_name
= None¶
-
edit_template_name_ajax
= None¶
-
form_snippet_template_name
= 'dash/snippets/generic_form_snippet.html'¶
-
get_css
(placeholders)[source]¶ Get placeholder specific css.
Parameters: placeholders (iterable) – Iterable of dash.base.BaseDashboardPlaceholder
subclassed instances.Return string:
-
get_grouped_dashboard_entries
(dashboard_entries)[source]¶ Get dashboard entries grouped by placeholder.
Parameters: dashboard_entries (iterable) – Iterable of dash.models.DashboardEntry
objects.Return list:
-
get_placeholder_instances
(dashboard_entries=None, workspace=None, request=None)[source]¶ Get placeholder instances.
Parameters: - dashboard_entries (iterable) – Iterable of
dash.models.DashboardEntry
objects. - workspace (str) –
- request (django.http.HttpRequest) –
Return list: List of dash.base.BaseDashboardPlaceholder subclassed instances.
- dashboard_entries (iterable) – Iterable of
-
get_placeholder_uids
(request=None)[source]¶ Get the list of placeholder uids.
Parameters: request (django.http.HttpRequest) – Return list:
-
get_placeholders
(request=None)[source]¶ Get the list of placeholders registered for the layout.
Parameters: request (django.http.HttpRequest) – Return iterable: List of placeholder classes. Override in your layout if you need a custom behaviour.
-
get_view_template_name
(request=None, origin=None)[source]¶ Get 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
¶ Class used in the HTML.
Return string:
-
html_classes
= []¶
-
media_css
= []¶
-
media_js
= []¶
-
name
= None¶
-
placeholders
= []¶
-
plugin_widgets_template_name_ajax
= 'dash/plugin_widgets_ajax.html'¶
-
primary_html_class
¶
-
render_for_edit
(dashboard_entries=None, workspace=None, request=None)[source]¶ Render 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]¶ Render 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
¶ Cell units.
-
cell_width
= None¶
-
cols
= None¶
-
css
¶ 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 render 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
= ''¶
-
html_class
¶ Class used in the HTML.
Return string:
-
html_classes
= []¶
-
html_id
¶ ID (unique) used in the HTML.
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
¶ Primary HTML class.
-
rows
= None¶
-
uid
= None¶
-
view_template_name
= ''¶
-
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 description (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
. anddash.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¶
-
clone_plugin_data
(dashboard_entry)[source]¶ Clone plugin data.
Used when copying entries. If any objects or files are created by plugin, they should be cloned.
Parameters: dashboard_entry (dash.models.DashboardEntry) – Instance of dash.models.DashboardEntry
.Return string: JSON dumped string of the cloned plugin data. The returned value would be inserted as is into the dash.models.DashboardEntry.plugin_data
field.
-
delete_plugin_data
()[source]¶ Delete plugin data.
Used in
dash.views.delete_dashboard_entry
. Fired automatically, whendash.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_cloned_plugin_data
(update={})[source]¶ Get the cloned plugin data and returns it in a JSON dumped format.
Parameters: update (dict) – Return string: JSON dumped string of the cloned plugin data. Example: In the
get_cloned_plugin_data
method of your plugin, do as follows:>>> def clone_plugin_data(self, dashboard_entry): >>> cloned_image = clone_file(self.data.image, relative_path=True) >>> return self.get_cloned_plugin_data( >>> update={'image': cloned_image} >>> )
-
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 theform
attribute defined in your plugin.Return django.forms.Form|django.forms.ModelForm: Subclass of django.forms.Form
ordjango.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]¶ Get initialised create form or 404.
Same as
get_initialised_create_form
but raisesdjango.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.utils.ErrorList'>, label_suffix=':', empty_permitted=False, instance=None)[source]¶ Get initialised edit form.
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.utils.ErrorList'>, label_suffix=':', empty_permitted=False)[source]¶ Get initialised edit form or 404.
Same as
get_initialised_edit_form
but raisesdjango.http.Http404
on errors.
-
get_plugin_form_data
()[source]¶ Get plugin form data.
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]¶ Get the exact position of the plugin widget in the placeholder (row number, col number).
Return tuple: Tuple of row and col numbers.
-
get_updated_plugin_data
(update={})[source]¶ Get the plugin data and returns it in a JSON dumped format.
Parameters: update (dict) – Return string: JSON dumped string of the cloned plugin data.
-
get_widget
(request=None, as_instance=False)[source]¶ Get the plugin widget.
Parameters: - request (django.http.HttpRequest) –
- as_instance (bool) –
Return mixed: Subclass of
dash.base.BaseDashboardPluginWidget
or instance of subclasseddash.base.BaseDashboardPluginWidget
object.
-
group
¶
-
help_text
= None¶
-
html_class
¶ HTML class.
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
¶ HTML id.
-
load_plugin_data
(plugin_data)[source]¶ Load 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]¶ Post-process data.
Redefine in your subclassed plugin when necessary.
Post process plugin data here (before rendering). This method 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]¶ Pre-process data.
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).
-
render
(request=None)[source]¶ Render the plugin HTML (for dashboard workspace).
Parameters: request (django.http.HttpRequest) – Return string:
-
save_plugin_data
(dashboard_entry, plugin_data)[source]¶ Save plugin data.
Used in bulk update plugin data.
Parameters: - dashboard_entry (dash.models.DashboardEntry) –
- plugin_data (dict) –
Return bool: True if all went well.
-
uid
= None¶
-
update_plugin_data
(dashboard_entry)[source]¶ Update plugin data.
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 ofdash.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 rundash_update_plugin_data
management command (seedash.management.commands.dash_update_plugin_data
module).Parameters: dashboard_entry (dash.models.DashboardEntry) – Instance of dash.models.DashboardEntry
.Return dict: Should return a dictionary containing data of fields to be updated.
-
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, whether 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_size
(delta_width=0, delta_height=0)[source]¶ Get widget size.
Parameters: - delta_width (int) –
- delta_height (int) –
Return tuple:
-
html_class
= ''¶
-
html_classes
= []¶
-
layout_uid
= None¶
-
media_css
= []¶
-
media_js
= []¶
-
placeholder_uid
= None¶
-
plugin_uid
= None¶
-
rows
= 1¶
-
-
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 thesave_plugin_data
method and make them serializable there. Seedash.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 thedash.models.DashboardEntry
subclassed model.Parameters: request (django.http.HttpRequest) –
-
plugin_data_fields
= None¶
-
-
class
dash.base.
PluginWidgetRegistry
[source]¶ Bases:
object
Registry of dash plugins widgets (renderers).
-
get
(uid, default=None)[source]¶ Get the given entry from the registry.
Parameters: - uid (string) –
- default (mixed) –
:return mixed.
-
register
(cls, force=False)[source]¶ Register the plugin renderer in the registry.
Parameters: cls (dash.base.BasePluginRenderer) – Subclass of dash.base.BasePluginRenderer
.
-
type
¶ alias of
BaseDashboardPluginWidget
-
-
dash.base.
collect_widget_media
(dashboard_entries)[source]¶ Collect 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.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.
get_registered_plugin_uids
()[source]¶ Gets a list of registered plugin uids as a list .
If not yet auto-discovered, auto-discovers them.
Return list:
-
dash.base.
get_registered_plugins
()[source]¶ Get a list of registered plugins in a form if tuple.
Get a list of registered plugins in a form if tuple (plugin name, plugin description). If not yet auto-discovered, auto-discovers them.
Return list:
dash.clipboard module¶
dash.compat module¶
dash.conf module¶
-
dash.conf.
get_setting
(setting, override=None)[source]¶ Get setting.
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.constants module¶
dash.decorators module¶
-
dash.decorators.
all_permissions_required
(perms, login_url=None, raise_exception=False)[source]¶ All permissions required.
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]¶ Any permission required.
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]¶ Check if user has permissions to edit dashboard.
Simply, check is successful 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.decorators.
permissions_required
(perms, satisfy='all', login_url=None, raise_exception=False)[source]¶ Check 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.
use_clipboard_permission_required
(login_url=None, raise_exception=False)[source]¶ Check if user has permissions to use clipboard.
Simply, check is successful if all of the following permission checks are satisfied:
- Can add dashboard entry
- Can delete dashboard entry
Example: >>> @login_required >>> @use_clipboard_permission_required() # Do not forget the brackets! >>> def cut_dashboard_entry(request): >>> # your code
dash.defaults module¶
dash.discover module¶
dash.exceptions module¶
-
exception
dash.exceptions.
ImproperlyConfigured
[source]¶ Bases:
dash.exceptions.BaseException
Raised when
django-dash
is somehow improperly configured.
-
exception
dash.exceptions.
InvalidRegistryItemType
[source]¶ Bases:
ValueError
Raised when an attempt is made to register an item of improper type.
Raised when an attempt is made to register an item of improper type in the registry .
-
exception
dash.exceptions.
LayoutDoesNotExist
[source]¶ Bases:
dash.exceptions.BaseException
Raised when layout does not exist.
-
exception
dash.exceptions.
NoActiveLayoutChosen
[source]¶ Bases:
dash.exceptions.BaseException
Raised when no active layout is chosen.
-
exception
dash.exceptions.
PluginWidgetOutOfPlaceholderBoundaries
[source]¶ Bases:
dash.exceptions.BaseException
Raised when plugin widget is out of placeholder boundaries.
dash.factory module¶
-
dash.factory.
plugin_factory
(base_class, plugin_uid_prefix, sizes=[])[source]¶ Plugin factory.
Parameters: - base_class (class) – Subclass of.
- base_class –
- plugin_uid_prefix (string) –
- sizes (iterable) –
- sizes – Iterable of tuples.
Example: >>> from dash.contrib.plugins.image.dash_plugins import BaseImagePlugin >>> plugin_factory( >>> BaseImagePlugin, 'image', zip(range(6, 10), range(6, 10)) >>> )
The example above will update the plugin registry with the following dictionary: >>> { >>> ‘image_6x6’: dash.factory.Plugin, >>> ‘image_7x7’: dash.factory.Plugin, >>> ‘image_8x8’: dash.factory.Plugin, >>> ‘image_9x9’: dash.factory.Plugin, >>> }
The generated class (one of them), would look as follows:
>>> class Plugin(BaseImagePlugin): >>> uid = 'image_6x6'
The
uid
property is generated automatically.
-
dash.factory.
plugin_widget_factory
(base_class, layout_uid, placeholder_uid, plugin_uid_prefix, sizes=[])[source]¶ Plugin widget factory.
Parameters: - base_class (dash.base.BaseDashboardWidget) – Subclass of.
- layout_uid (string) – Layout UID, for which widgets are generated.
- placeholder_uid (string) – Placeholder UID, for which widgets are generated.
- plugin_uid_prefix (string) – Prefix of the plugin UID.
- sizes (iterable) – Iterable of tuples.
Example: >>> from dash.contrib.plugins.image.dash_widgets import BaseImageWidget >>> plugin_widget_factory( >>> BaseImageWidget, >>> 'android', >>> 'main', >>> 'image', >>> zip(range(6, 10), range(6, 10)) >>> )
The example above will update the plugin widget registry with the following dictionary:
>>> { >>> 'android.main.image_6x6': dash.factory.Widget, >>> 'android.main.image_7x7': dash.factory.Widget, >>> 'android.main.image_8x8': dash.factory.Widget, >>> 'android.main.image_9x9': dash.factory.Widget, >>> }
The generated class (one of them), would look as follows:
>>> class Widget(BaseImageWidget): >>> layout_uid = 'android' >>> placeholder_uid = 'main' >>> plugin_uid = 'image_6x6' >>> cols = 6 >>> rows = 6
The
layout_uid
,placeholder_uid
,plugin_uid
,cols
androws
properties are generated automatically.
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'>, editable=True, serialize=True, unique_for_date=None, unique_for_month=None, unique_for_year=None, choices=None, help_text='', db_column=None, db_tablespace=None, auto_created=False, validators=(), error_messages=None)[source]¶ Bases:
django.db.models.fields.IntegerField
OrderField.
@author http://djangosnippets.org/users/zenx/ @source http://djangosnippets.org/snippets/1861/
OrderField for models from //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' >>> ]
dash.forms module¶
dash.helpers module¶
-
dash.helpers.
clean_plugin_data
(dashboard_entries, request=None)[source]¶ Clean up the plugin data.
Clean up the plugin data (database, files) for the dashboard_entries given.
Parameters: - dashboard_entries (iterable) –
- request (django.http.HttpRequest) –
Return bool: Boolean True if no errors occurred and False otherwise.
-
dash.helpers.
clone_plugin_data
(dashboard_entry, request=None)[source]¶ Clone plugin data of a dashboard entry.
-
dash.helpers.
iterable_to_dict
(items, key_attr_name)[source]¶ Convert iterable of certain objects to dict.
Parameters: - items (iterable) –
- key_attr_name (string) – Attribute to use as a dictionary key.
Return dict:
dash.json_package module¶
dash.models module¶
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 (bool)