shuup.reports package

Submodules

shuup.reports.apps module

class shuup.reports.apps.AppConfig(*args, **kwargs)[source]

Bases: shuup.apps.AppConfig

name = 'shuup.reports'
provides = {'report_writer_populator': ['shuup.reports.writer.populate_default_writers'], 'admin_module': ['shuup.reports.admin_module:ReportsAdminModule']}

shuup.reports.forms module

class shuup.reports.forms.DateRangeChoices[source]

Bases: enumfields.enums.Enum

An enumeration.

CUSTOM = <DateRangeChoices.CUSTOM: 'custom'>
TODAY = <DateRangeChoices.TODAY: 'today'>
RUNNING_WEEK = <DateRangeChoices.RUNNING_WEEK: 'running_week'>
RUNNING_MONTH = <DateRangeChoices.RUNNING_MONTH: 'running_month'>
THIS_MONTH = <DateRangeChoices.THIS_MONTH: 'this_month'>
THIS_YEAR = <DateRangeChoices.THIS_YEAR: 'this_year'>
ALL_TIME = <DateRangeChoices.ALL_TIME: 'all_time'>
class shuup.reports.forms.BaseReportForm(*args, **kwargs)[source]

Bases: django.forms.forms.Form

clean()[source]
get_report_instance()[source]
Return type:shuup.reports.reporter.base.ShuupReportBase
base_fields = OrderedDict([('report', <django.forms.fields.CharField object at 0x7fabc7d2d0f0>), ('shop', <django.forms.fields.ChoiceField object at 0x7fabc7dc0160>), ('date_range', <enumfields.forms.EnumChoiceField object at 0x7fabc7dbcb70>), ('start_date', <django.forms.fields.DateField object at 0x7fabc7dc6b70>), ('end_date', <django.forms.fields.DateField object at 0x7fabc7dc6c88>), ('writer', <django.forms.fields.ChoiceField object at 0x7fabc7dc6748>), ('force_download', <django.forms.fields.BooleanField object at 0x7fabc7dc6550>)])
declared_fields = OrderedDict([('report', <django.forms.fields.CharField object at 0x7fabc7d2d0f0>), ('shop', <django.forms.fields.ChoiceField object at 0x7fabc7dc0160>), ('date_range', <enumfields.forms.EnumChoiceField object at 0x7fabc7dbcb70>), ('start_date', <django.forms.fields.DateField object at 0x7fabc7dc6b70>), ('end_date', <django.forms.fields.DateField object at 0x7fabc7dc6c88>), ('writer', <django.forms.fields.ChoiceField object at 0x7fabc7dc6748>), ('force_download', <django.forms.fields.BooleanField object at 0x7fabc7dc6550>)])
media

shuup.reports.report module

class shuup.reports.report.ShuupReportBase(**kwargs)[source]

Bases: object

filename_template = None
icon = 'fa-money'
form_class

alias of BaseReportForm

classmethod get_name()[source]
classmethod get_title()[source]
ensure_texts()[source]

Ensure that lazy objects are forced as texts

get_return_data(data, has_totals=True)[source]
dict_getter(c, datum)[source]
cls_getter(c, datum)[source]
read_datum(datum)[source]
get_totals(data)[source]
shuup.reports.report.get_report_class(name)[source]
shuup.reports.report.get_report_classes()[source]

shuup.reports.utils module

shuup.reports.utils.get_empty_data(schema, data, message)[source]
shuup.reports.utils.get_error_data(schema, sales_data)[source]
shuup.reports.utils.parse_date_range_preset(value)[source]
shuup.reports.utils.parse_date_range(value)[source]

shuup.reports.writer module

class shuup.reports.writer.ReportWriter[source]

Bases: object

content_type = None
extension = None
inline = False
writer_type = 'base'
write_heading(text)[source]
write_text(text)[source]
write_data_table(report, report_data, has_totals=True)[source]
write_template(template_name, env)[source]
next_page()[source]
get_rendered_output()[source]
render_report(report, inline=False)[source]

Renders given report

Parameters:report
Returns:
Return type:
get_response(report)[source]

Returns downloadable file response

Parameters:report
Returns:
Return type:
get_filename(report)[source]
class shuup.reports.writer.ExcelReportWriter[source]

Bases: shuup.reports.writer.ReportWriter

content_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
extension = '.xlsx'
writer_type = 'excel'
next_page()[source]
write_data_table(report, report_data, has_totals=True)[source]
write_page_heading(text)[source]
write_heading(text)[source]
write_text(text)[source]
get_rendered_output()[source]
class shuup.reports.writer.HTMLReportWriter[source]

Bases: shuup.reports.writer.ReportWriter

content_type = 'text/html; charset=UTF-8'
extension = '.html'
writer_type = 'html'
INLINE_TEMPLATE = '<style type="text/css">%(style)s</style>\n %(body)s'
TEMPLATE = '<html>\n<head>\n<meta charset="UTF-8">\n<title>%(title)s</title>\n%(extrahead)s\n</head><style type="text/css">%(style)s</style>\n %(body)s</html>'
styles = '@page { prince-shrink-to-fit: auto }'
extra_header = ''
next_page()[source]
write_data_table(report, report_data, has_totals=True)[source]
write_page_heading(text)[source]
write_heading(text)[source]
write_text(text)[source]
write_tag(tag, text)[source]
get_rendered_output()[source]
set_extra(extrastring)[source]
set_style(stylestring)[source]
write_template(template_name, env)[source]
class shuup.reports.writer.PDFReportWriter[source]

Bases: shuup.reports.writer.HTMLReportWriter

content_type = 'application/pdf'
extension = '.pdf'
writer_type = 'pdf'
get_rendered_output()[source]
class shuup.reports.writer.JSONReportWriter[source]

Bases: shuup.reports.writer.ReportWriter

content_type = 'application/json'
extension = '.json'
writer_type = 'json'
write_data_table(report, report_data, has_totals=True)[source]
write_heading(text)[source]
write_text(text)[source]
get_rendered_output()[source]
class shuup.reports.writer.PprintReportWriter[source]

Bases: shuup.reports.writer.JSONReportWriter

content_type = 'text/plain'
extension = '.txt'
writer_type = 'pprint'
get_rendered_output()[source]
class shuup.reports.writer.ReportWriterPopulator[source]

Bases: object

A class which populates the report writers map

report_writers_map = {'excel': <class 'shuup.reports.writer.ExcelReportWriter'>, 'pdf': <class 'shuup.reports.writer.PDFReportWriter'>, 'pprint': <class 'shuup.reports.writer.PprintReportWriter'>, 'json': <class 'shuup.reports.writer.JSONReportWriter'>, 'html': <class 'shuup.reports.writer.HTMLReportWriter'>}
populate()[source]

Iterate over all report_writer_populator provides to fill/update the report writer map

register(writer_name, writer_class)[source]

Register a report writer for use.

If a writer with same name already exists, it will be overwriten.

Parameters:
  • writer_name (str) – the unique name of the writer
  • writer_class (ReportWriter) – the report writer class
populated_map

Returns the populated map

shuup.reports.writer.get_writer_names()[source]

Get the registered writer names

shuup.reports.writer.get_writer_instance(writer_name)[source]

Get a report writer instance by name :type writer_name: str :param writer_name: the name of the report writer :rtype: ReportWriter

shuup.reports.writer.populate_default_writers(writer_populator)[source]

Populate the default report writers :type writer_populator: ReportWriterPopulator

Module contents