API Reference

ScaffoldReport

class scaffold_report.report.ScaffoldReport[source]

Bases: object

Base class for any actual scaffold reports A scaffold report is named after UI effects for moving various filters and previews into the report building screen. All reports require customized options set by the programmer.

name = ''

Unique name of report.

name_verbose = None

Verbose name of report to show users.

model = None

Base model for this report’s queryset.

preview_fields = ['id']

Array of field names to show on previews.

num_preview = 3

How many objects in the queryset should be show in preview.

filters = []

Filters that can be applied to the report.

report_buttons = []

Buttons will show in sidebar area. These can be premade reports and give the user more options than just clicking submit

permissions_required = []

Report is only viewable to those with these permissions. Will default to the model’s change permission if not set

appy_template = None

A statically defined template. Could override get_template instead.

get_appy_template()[source]

Return a appy template This could be hard coded or perhaps get report_context from a filter.

check_permissions(request)[source]

Return true is user has permission to view page

get_name

Return name_verbose if it has been set; otherwise return name. Replaces all spaces with underscores.

get_queryset()[source]

Return a queryset of the model filtering any active filters

get_appy_context()[source]

Return a context dict for use in an appy template Acts a like context in Django template rendering.

report_to_list(user, preview=False)[source]

Convert to python list

class scaffold_report.report.ReportButton[source]

Bases: object

An alternative way to submit a report. Could be used for one off reports that behave differently.

name = ''

For button name attr

value = ''

For button value attr

accepts_queryset = True

When true the queryset is processed first (so filters will run) and passed to get_report

get_name

Return name_verbose if it has been set; otherwise return name. Replaces all spaces with underscores.

get_report(context=None)[source]

This function will call to generate the actual report Should return a valid response

scaffold_report.report.autodiscover()[source]

Auto-discover INSTALLED_APPS report.py modules and fail silently when not present. Borrowed form django.contrib.admin

class scaffold_report.report.ScaffoldReportClassManager[source]

Bases: object

Class to handle registered reports class. Borrowed from django-model-report Thanks!

Filters

class scaffold_report.filters.Filter(**kwargs)[source]

Bases: object

A customized filter for querysets

name = None

Unique name of filter

verbose_name = None

Human readable name of filter

template_name = None

If set the filter will render using this django template If not set the filter will render using scaffold_report/filter.html

fields = None

Define fields here that will be appended together to make a generic form

form_class = None

Optional form class to use.

form = None

Optional form. If not set, an instance of the form_class will be used

raw_form_data = None

uncleaned_form data from the post

add_fields = []

Add these fields to the preview and spreadsheet reports

default = False

Show this filter as on by default

can_remove = True

User is able to delete this filter. Should be used with default = True.

can_add = True

User is able to add this filter

queryset_filter(queryset, report_context=None, form=None)[source]

Allow custom handeling of queryset Must return the queryset.

render_form()[source]

Render the form using a template Only called if template_name is defined

get_add_fields()[source]

Returns the fields to add to previews and spreadsheet reports

process_filter(queryset, report_context=None)[source]

Run the actual filter based on client data

get_template_context()[source]

Get the context to be shown when rendering a template just for this filter

get_report_context(report_context)[source]

Process any data that needs set for an entire report

build_form()[source]

Construct form out of fields or form

get_name()[source]

return unique name of this filter

class scaffold_report.filters.DecimalCompareFilter(**kwargs)[source]

Bases: scaffold_report.filters.Filter

X greater, less, etc than decimal field

class scaffold_report.filters.ModelChoiceFilter(**kwargs)[source]

Bases: scaffold_report.filters.Filter

Select object from a queryset

compare_field_string = None

String used in the Django orm filter function. See queryset_filter()

model = None

Model used for queryset. Set this for any object of such model.

queryset = None

queryset that populates the widget. Model is not needed if this is set.

get_queryset()[source]

Get the queryset that will populare the widget

class scaffold_report.filters.ModelMultipleChoiceFilter(**kwargs)[source]

Bases: scaffold_report.filters.ModelChoiceFilter

Select multiple objects from a queryset

class scaffold_report.filters.IntCompareFilter(**kwargs)[source]

Bases: scaffold_report.filters.DecimalCompareFilter

x greater, less, etc than int field

Fields

class scaffold_report.fields.SimpleCompareField(**kwargs)[source]

Bases: django.forms.fields.ChoiceField

Field for selecting a comparison. Includes django synxtax and verbose choices

Hey, Read the Docs!