Bases: django.contrib.admin.options.ModelAdmin
Dashboard entry admin.
Bases: django.contrib.admin.options.ModelAdmin
Dashboard plugin admin.
Bases: django.contrib.admin.options.ModelAdmin
Dashboard plugin admin.
Bases: django.contrib.admin.options.ModelAdmin
Dashboard workspace admin.
All uids are supposed to be pythonic function names (see PEP http://www.python.org/dev/peps/pep-0008/#function-names).
Bases: object
Base layout.
Layouts consist of placeholders.
Properties : |
|
---|
Collects the widget media files.
Parameters: | dashboard_entries (iterable) – Iterable of dash.models.DashboardEntry instances. |
---|---|
Return list: |
Gets placeholder specific css.
Parameters: | placeholders (iterable) – Iterable of dash.base.BaseDashboardPlaceholder subclassed instances. |
---|---|
Return string: |
Gets dashboard entries grouped by placeholder.
Parameters: | dashboard_entries (iterable) – Iterable of dash.models.DashboardEntry objects. |
---|---|
Return list: |
Gets placeholder instances.
Parameters: |
|
---|---|
Return list: | List of dash.base.BaseDashboardPlaceholder subclassed instances. |
Gets the list of placeholder uids.
Parameters: | request (django.http.HttpRequest) – |
---|---|
Return list: |
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. |
Renders the layout.
NOTE: This is not used at the moment. You most likely want the dash.views.edit_dashboard view.
Parameters: |
|
---|---|
Return string: |
Renders the layout.
NOTE: This is not used at the moment. You most likely want the dash.views.dashboard view.
Parameters: |
|
---|---|
Return string: |
Bases: object
Base placeholder.
Properties : |
|
---|
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 : |
} |
---|---|
Return string: |
Feed the dashboard entries to the layout for rendering later.
Parameters: | dashboard_entries (iterable) – Iterable of dash.models.DashboardEntry objects. |
---|
Renders the placeholder for edit mode.
Parameters: |
|
---|---|
Return string: |
Bases: object
Base dashboard plugin from which every plugin should inherit.
Properties : |
|
---|
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.
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. |
Used dash.views.add_dashboard_entry view to gets initialised form for object to be created.
Same as get_initialised_create_form but raises django.http.Http404 on errors.
Used in dash.views.edit_dashboard_entry view.
Same as get_initialised_edit_form but raises django.http.Http404 on errors.
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.
Gets the exact position of the plugin widget in the placeholder (row number, col number).
Return tuple: | Tuple of row and col numbers. |
---|
Gets the plugin widget.
Parameters: |
|
---|---|
Return mixed: | Subclass of dash.base.BaseDashboardPluginWidget or instance of subclassed dash.base.BaseDashboardPluginWidget object. |
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.
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. |
---|
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).
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).
Renders the plugin HTML (for dashboard workspace).
Parameters: | request (django.http.HttpRequest) – |
---|---|
Return string: |
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. |
---|
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.
Gets widget size.
Parameters: |
|
---|---|
Return tuple: |
Gets a list of registered plugins in a form if tuple (plugin name, plugin description). If not yet autodiscovered, autodiscovers them.
Return list: |
---|
Gets a list of registered plugin uids as a list . If not yet autodiscovered, autodiscovers them.
Return list: |
---|
Validates the plugin uid.
Parameters: | plugin_uid (string) – |
---|---|
Return bool: |
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. |
Validates the placeholder.
Parameters: |
|
---|---|
Return bool: |
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)
>>> )
|
Data that would be saved in the plugin_data field of the dash.models.DashboardEntry subclassed model.
Parameters: | request (django.http.HttpRequest) – |
---|
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. |
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: |
|
---|---|
Returns: | Setting value. |
Checks for the permissions given based on the strategy chosen.
Parameters: |
|
---|---|
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
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
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
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
Bases: exceptions.ValueError
Raised when an attempt is made to register an item in the registry which does not have a proper type.
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.
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’
]
Bases: django.forms.models.ModelForm
Dashboard workspace form.
Bases: django.db.models.base.Model
Dashboard settings.
Properties : |
|
---|
Bases: django.core.exceptions.ObjectDoesNotExist
Bases: django.core.exceptions.MultipleObjectsReturned
Bases: django.db.models.base.Model
Dashboard workspace.
Properties : |
|
---|
Bases: django.core.exceptions.ObjectDoesNotExist
Bases: django.core.exceptions.MultipleObjectsReturned
Absolute URL, which goes to the dashboard workspace page.
Return string: |
---|
Gets all dashboard entries for user given.
Parameters: | user (django.contrib.auth.models.User) – |
---|---|
Return iterable: | |
Bases: django.db.models.base.Model
Dashboard entry (widget).
Since workspace can be nullable (default), we duplicate the layout_uid.
Properties : |
|
---|
Bases: django.core.exceptions.ObjectDoesNotExist
Bases: django.core.exceptions.MultipleObjectsReturned
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. |
Bases: django.db.models.base.Model
Dashboard plugin. Used when dash.settings.RESTRICT_PLUGIN_ACCESS is set to True.
Properties : |
|
---|
Bases: django.core.exceptions.ObjectDoesNotExist
Bases: django.core.exceptions.MultipleObjectsReturned
Flat list (comma separated string) of groups allowed to use the dashboard plugin. Used in Django admin.
Return string: |
---|
Bases: django.test.testcases.LiveServerTestCase
django-dash browser tests.
TODO: At the moment is done for admin only. Normal users shall be tested as well for plugin security workflow (permissions system used).
Bases: django.test.testcases.TestCase
Tests of django-dash core functionality.
Gets allowed plugins uids for user given.
Parameters: | import User (django.contrib.auth.models) – |
---|---|
Return list: |
Gets a list of user plugins in a form if tuple (plugin name, plugin description). If not yet autodiscovered, autodiscovers them.
Return list: |
---|
Gets a list of user plugin uids as a list . If not yet autodiscovered, autodiscovers them.
Return list: |
---|
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: |
|
---|---|
Return list: |
Updates the plugin data for all dashboard entries of all users. Rules for update are specified in the plugin itself.
Syncs the registered plugin list with data in dash.models.DashboardPlugin.
Gets previous, current, next and and a queryset of all workspaces.
Parameters: |
|
---|---|
Return dict: |
Builds the cells matrix.
Parameters: |
|
---|---|
Return list: | List of cells occupied. |
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. |
Add dashboard entry.
Parameters: |
|
---|---|
Return django.http.HttpResponse: | |
Create dashboard workspace.
Parameters: |
|
---|---|
Return django.http.HttpResponse: | |
Dashboard.
Parameters: |
|
---|---|
Return django.http.HttpResponse: | |
Workspaces list.
Parameters: |
|
---|---|
Return django.http.HttpResponse: | |
Remove dashboard entry.
Parameters: |
|
---|---|
Return django.http.HttpResponse: | |
Delete dashboard workspace.
Parameters: |
|
---|---|
Return django.http.HttpResponse: | |
Edit dashboard.
Parameters: |
|
---|---|
Return django.http.HttpResponse: | |
Edit dashboard entry.
Parameters: |
|
---|---|
Return django.http.HttpResponse: | |
Edit dashboard settings.
Parameters: |
|
---|---|
Return django.http.HttpResponse: | |
Edit dashboard workspace.
Parameters: |
|
---|---|
Return django.http.HttpResponse: | |
Plugin widgets view. Lists all the widgets for the placeholder and workspace given.
Parameters: |
|
---|---|
Return django.http.HttpResponse: | |