shuup.admin.dashboard package

Submodules

shuup.admin.dashboard.blocks module

class shuup.admin.dashboard.blocks.DashboardBlock(id, size=None, color=None, sort_order=0)[source]

Bases: object

type = None
SIZES = ('small', 'normal', 'medium', 'large', 'full')
default_size = 'normal'
sort_order = 0
class shuup.admin.dashboard.blocks.DashboardContentBlock(id, content, size='normal')[source]

Bases: shuup.admin.dashboard.blocks.DashboardBlock

type = 'normal'
classmethod by_rendering_template(id, request, template_name, context)[source]
class shuup.admin.dashboard.blocks.DashboardValueBlock(id, value, title, **kwargs)[source]

Bases: shuup.admin.dashboard.blocks.DashboardBlock

type = 'value'
default_size = 'small'
class shuup.admin.dashboard.blocks.DashboardNumberBlock(id, value, title, **kwargs)[source]

Bases: shuup.admin.dashboard.blocks.DashboardValueBlock

class shuup.admin.dashboard.blocks.DashboardMoneyBlock(id, value, title, currency, **kwargs)[source]

Bases: shuup.admin.dashboard.blocks.DashboardValueBlock

class shuup.admin.dashboard.blocks.DashboardChartBlock(id, size='normal')[source]

Bases: shuup.admin.dashboard.blocks.DashboardBlock

type = 'chart'
default_size = 'medium'
BLOCK_TEMPLATE = '\n <div class="color-block block-purple">\n <h2 class="block-title">%(title)s</h2>\n <div class="block-content">\n <canvas id="chart-%(id)s" height="250"></canvas>\n </div>\n </div>\n <script>\n window.CHART_CONFIGS = window.CHART_CONFIGS || {};\n window.CHART_CONFIGS["%(id)s"] = %(config)s;\n </script>\n '
get_chart()[source]

Get the actual chart instance for this block.

Returns:The chart (or None, if it can’t be rendered)
Return type:shuup.admin.dashboard.charts.Chart|None

shuup.admin.dashboard.charts module

class shuup.admin.dashboard.charts.ChartType[source]

Bases: object

Type of a chart

BAR = 'bar'
LINE = 'line'
class shuup.admin.dashboard.charts.ChartDataType[source]

Bases: object

Data type of datasets

NUMBER = 'number'
CURRENCY = 'currency'
PERCENT = 'percent'
class shuup.admin.dashboard.charts.Chart(title, data_type='number', locale=None, currency=None, options=None)[source]

Bases: object

Parameters:
  • title (str) – the title of the chart
  • data_type (ChartDataType) – the data type of values The chart will format the output labels according to this parameter
  • locale (str) – the locale to render values If not set, the locale will be fetched from Babel
  • currency (str) – the ISO-4217 code for the currency This is necessary when the data_type is CURRENCY
  • options (dict) – a dicionaty with options for Chartjs
supported_chart_types = []
get_config()[source]

Get a JSONable dictionary of configuration data for this chart. This is passed on as CHART_CONFIGS in the JS environment and eventually processed by dashboard-charts.js.

Returns:Dict of configuration
Return type:dict
get_config_json()[source]
add_data(name, data, chart_type)[source]

Add data to this chart.

Parameters:
  • name (str) – the name of the dataset
  • data (list[int|float|Decimal]) – the list of data
  • chart_type (ChartType) – the chart type - tells how data should be rendered. This data type must be available in the supported_chart_type attribute of this instance
class shuup.admin.dashboard.charts.BarChart(title, labels, data_type='number', **kwargs)[source]

Bases: shuup.admin.dashboard.charts.Chart

supported_chart_types = ['bar']
get_config()[source]
class shuup.admin.dashboard.charts.MixedChart(title, labels, data_type='number', **kwargs)[source]

Bases: shuup.admin.dashboard.charts.Chart

This chart supports both Bars and Lines.

supported_chart_types = ['bar', 'line']
get_config()[source]

shuup.admin.dashboard.utils module

shuup.admin.dashboard.utils.get_activity(request, n_entries=30, cutoff_hours=10)[source]

Get Activity objects from all modules as a list in latest-first order.

Parameters:
  • request (django.http.request.HttpRequest) – Request context
  • n_entries (int) – Number of entries to return in total.
  • cutoff_hours (float) – Calculate cutoff datetime so the oldest entry should be at most this old
Returns:

List of Activity objects

Return type:

list[Activity]

Module contents

class shuup.admin.dashboard.BarChart(title, labels, data_type='number', **kwargs)[source]

Bases: shuup.admin.dashboard.charts.Chart

get_config()[source]
supported_chart_types = ['bar']
class shuup.admin.dashboard.MixedChart(title, labels, data_type='number', **kwargs)[source]

Bases: shuup.admin.dashboard.charts.Chart

This chart supports both Bars and Lines.

get_config()[source]
supported_chart_types = ['bar', 'line']
class shuup.admin.dashboard.ChartType[source]

Bases: object

Type of a chart

BAR = 'bar'
LINE = 'line'
class shuup.admin.dashboard.ChartDataType[source]

Bases: object

Data type of datasets

CURRENCY = 'currency'
NUMBER = 'number'
PERCENT = 'percent'
class shuup.admin.dashboard.DashboardBlock(id, size=None, color=None, sort_order=0)[source]

Bases: object

SIZES = ('small', 'normal', 'medium', 'large', 'full')
default_size = 'normal'
sort_order = 0
type = None
class shuup.admin.dashboard.DashboardChartBlock(id, size='normal')[source]

Bases: shuup.admin.dashboard.blocks.DashboardBlock

BLOCK_TEMPLATE = '\n <div class="color-block block-purple">\n <h2 class="block-title">%(title)s</h2>\n <div class="block-content">\n <canvas id="chart-%(id)s" height="250"></canvas>\n </div>\n </div>\n <script>\n window.CHART_CONFIGS = window.CHART_CONFIGS || {};\n window.CHART_CONFIGS["%(id)s"] = %(config)s;\n </script>\n '
default_size = 'medium'
get_chart()[source]

Get the actual chart instance for this block.

Returns:The chart (or None, if it can’t be rendered)
Return type:shuup.admin.dashboard.charts.Chart|None
type = 'chart'
class shuup.admin.dashboard.DashboardContentBlock(id, content, size='normal')[source]

Bases: shuup.admin.dashboard.blocks.DashboardBlock

classmethod by_rendering_template(id, request, template_name, context)[source]
type = 'normal'
class shuup.admin.dashboard.DashboardMoneyBlock(id, value, title, currency, **kwargs)[source]

Bases: shuup.admin.dashboard.blocks.DashboardValueBlock

class shuup.admin.dashboard.DashboardNumberBlock(id, value, title, **kwargs)[source]

Bases: shuup.admin.dashboard.blocks.DashboardValueBlock

class shuup.admin.dashboard.DashboardValueBlock(id, value, title, **kwargs)[source]

Bases: shuup.admin.dashboard.blocks.DashboardBlock

default_size = 'small'
type = 'value'
shuup.admin.dashboard.get_activity(request, n_entries=30, cutoff_hours=10)[source]

Get Activity objects from all modules as a list in latest-first order.

Parameters:
  • request (django.http.request.HttpRequest) – Request context
  • n_entries (int) – Number of entries to return in total.
  • cutoff_hours (float) – Calculate cutoff datetime so the oldest entry should be at most this old
Returns:

List of Activity objects

Return type:

list[Activity]