45
Django Advanced Reports Documentation Release 2.3.0 Jef Geskens, Ingo Berben and contributors Feb 10, 2018

Release 2.3.0 Jef Geskens, Ingo Berben and contributors

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced ReportsDocumentation

Release 2.3.0

Jef Geskens, Ingo Berben and contributors

Feb 10, 2018

Page 2: Release 2.3.0 Jef Geskens, Ingo Berben and contributors
Page 3: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Contents

1 The Reports 31.1 Tutorial: Your first report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 AdvancedReport and Action reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 The Backoffice 132.1 Backoffice and AngularJS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.2 Backoffice Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.3 Backoffice Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202.4 Backoffice Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

3 Changelog 313.1 0.9.2 (2015-02-20) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313.2 0.9.3 (2015-02-27) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313.3 0.9.4 (2015-02-27) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313.4 0.9.5 (2015-03-03) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313.5 0.9.6 (2015-03-04) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323.6 0.9.7 (2015-03-05) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323.7 0.9.8 (2015-03-10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323.8 0.9.9 (2015-09-07) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

4 Indices and tables 33

Python Module Index 35

i

Page 4: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

ii

Page 5: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

Contents:

Contents 1

Page 6: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

2 Contents

Page 7: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

CHAPTER 1

The Reports

This section of the documentation covers the reports part of Django Advanced Reports.

Topics:

1.1 Tutorial: Your first report

This section needs to be elaborated. For now, to see some examples, visit the examples page.

You need to login with admin as the username and admin as the password.

1.2 AdvancedReport and Action reference

1.2.1 AdvancedReport

class advanced_reports.defaults.AdvancedReport(*args, **kwargs)

slug = 'advanced'Required. A unique url-friendly name for your Advanced Report

request = NoneThe request. A new AdvancedReport instance is created on each request. This request will be savedto this property, so you can access it anywhere you need it.

filter_fields = ()A list of fields that can be filtered.

tabbed_filter_fields = ()Optional. A dictionary with fields that will be shown as tabs. 1st dict field has to be the field to filter on.2nd dict field is a dict with options:

• types: types to filter on.

3

Page 8: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

• images (optional): default will be used for all other fields, use same name as defined in types toprovide a type specific image.

value_selection_filter_fields = ()Optional.

filter_values = {}Optional. A mapping of filter fields to their list of values.

help_text = NoneOptional. Some text to explain the purpose of the report and some extra info.

items_per_page = 20The maximum number of items shown on one page. When you have more than this number of items, yourreport will be paginated. By default this is 20.

links = ()Optional. A tuple of link tuples. You can define some top level links for your report. A link tuplemust contain two items, the name of the link and the href location. Optionally you can show some moreinformation if you add a third item to the link tuple with a short explanation. This will be shown next orbelow the button, or a tooltip, as the templates can vary. Example:

links = ((u'Print this page', 'javascript:printPage();', u'Click here to print

→˓this page'),(u'Refresh', '.'),

)

template = 'advanced_reports/default.html'The default global template for rendering a report. This is only used when using the server-side Djangoview-based version.

item_template = 'advanced_reports/item_row.html'The default item template. This template will be used to render an individual item. When an actionperforms an operation on a report item, this template will be used to re-render that particular item.

internal_template = ''This template is used when you want your view-based report to be shown in the middle of an existing page.

decorate_views = FalseRequired when using get_decorator. True indicates that Advanced Reports should use the implementationof the get_decorator method.

multiple_actions = FalseOptional. Puts checkboxes before each item and puts a combobox with group actions on your report. Onlysimple (as in, not using a form) actions can be performed on multiple items.

You can implement your own special action method for multiple items. See the documenation forFOO_multiple below.

urlname = NoneOptional. Use this if you have a custom urlname for your report. Advanced Reports then knows how toreach your report.

date_range = NoneOptional. If a date field name is assigned to this, you can filter on date ranges.

animation = FalseOptional. True allows animation, but that does not work with table rows.

4 Chapter 1. The Reports

Page 9: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

empty_text = NoneOptional. The text displayed when no items are shown on your report. By default this is: There are no<verbose_name_plural> to display.

header_visible = TrueControls the visibility of the table header.

report_header_visible = TrueControls the visibility of the report header

show_actions_separator = TrueShows the separator between actions.

action_list_type = 'links'How to display the actions.

show_actions_only_on_hover = TrueShow the actions of an item only when the user hovers over the item. This only works when your templateor report rendering implementation knows about this attribute.

internal_mode = FalseDetermines if the advanced report should display a only single items. Used when you want to display toreport in an other template

compact = FalseWhether the report should be rendered in a more compact way. This controls for example if the rows arerendered using <tbody> with two rows or just normal direct <tr> tags. Also the show details / hide detailslink will disappear.

show_row_limit_selection = FalseShows an optional row limit selection box

models = NoneOptional, and not needed if model is specified. A tuple of model classes. See the documentation for themodel attribute.

model = NoneOptional, but strongly advised to use it. A model class. An AdvancedReport can infer a lot of stufffrom your model, including but not limited to the field verbose names, sortable fields, . . . This is a shortcutto the models attribute.

verbose_name = NoneRequired if no model specified. A name for an individual item. For example _('user')

verbose_name_plural = NoneRequired if no model specified. A plural name for individual items. For example _('users')

title = NoneRequired if no model specified. The human-friendly title of your report.

fields = NoneOptional when model or models is specified. A list of fields that must be displayed on the report.

search_fields = NoneA list of fields that are searchable. When specified or inferred from a given model

sortable_fields = NoneA list of sortable fields. You can sort on multiple fields at the same time using the comma (,) separator.The __ lookup syntax is also supported.

item_actions = ()Deprecated. A tuple of available actions for your report. Please use the actions as a decorator instead.

1.2. AdvancedReport and Action reference 5

Page 10: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

queryset()The primary source of the data you will want to manage.

get_FOO_verbose_name()Implement this function to specify the column header for the field FOO.

get_FOO_html()Implement this function to specify the HTML representation for the field FOO.

get_FOO_decorator()Implement this function to specify a decorator function for the field FOO. Return a function that acceptsone parameter and returns the decorated html.

filter_FOO(qs, value)Implement this function to specify a filter for the field FOO. This is useful for fields that are not a part ofa model, but aggregated.

Returns a filtered queryset

verify_action_group(item, group)Implement this function to verify if the given group currently applies to the given item.

For example, if the item is a paid purchase and the group is “paid”, we must return True. To turn of filteringof actions by groups, just don’t specify the group when creating an action and just leave this function alone.

set_request(request)Set the request for this report.

get_item_id(item)Advanced Reports expects each item to have a unique ID. By default this is the primary key of a modelinstance, but this can be anything you want, as long it is a unicode string.

get_item_for_id(item_id)Advanced Reports also expects each item to be found by its unique ID. By default it does a lookup of theprimary key of a model.

Returns None if the item does not exist.

get_decorator()To be used in tandem with decorate_views. Set it to True when you want to implement this function. Hereyou can return a decorator. That decorator will be used to decorate the Advanced Report views. This wayyou can easily add some permission restrictions to your reports.

FOO(item, form=None)The implementation of the FOO action method.

FOO_view(item, form=None)The implementation of the FOO action method that can return a HttpResponse

FOO_multiple(items)The implementation of the FOO action method with multiple items. This may return a HttpResponseobject or just None.

get_FOO_form(item, prefix, data=None)Instead of specifying the form attribute for an action, you can also construct your action form instancedynamically by implementing this method in your report. :param item: the item for which to construct theaction form :param prefix: the prefix that the form should use :param data: the data that should be passedto the form for validation :return: a form instance

get_item_class(item)Implement this to get some extra CSS classes for the item. Separate them with spaces.

6 Chapter 1. The Reports

Page 11: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

get_FOO_class(item)Implement this to get some extra CSS classes for the field FOO. Separate them with spaces.

get_extra_information(item)Implement this to get some extra information about an item. This will be shown right below a data rowand above the actions.

Ajax loading of information

You can specify some “lazy divs” that are only loaded when an action row expands. You must define ahidden item action with a method name that ends with ‘_view’.

Example:

def get_extra_information(self, item):return u'<div class="lazy" data-method="credit_view"></div>'

item_actions = (action(method='credit_view', verbose_name=u'', group='mygroup',

→˓hidden=True),)

def credit_view(self, item):balance = get_credit_balance(item)return render_to_response('credit_template.html', {'balance': balance})

get_FOO_style()Implement this to apply some CSS to the FOO td table cell. For example, you can define a fixed widthhere.

report_action_allowed(action)Implement this to control whether a report action (global action) should be shown.

auto_complete(request, partial, params)Implement this to support auto completion of certain fields.

Parameters

• request – the HTTPRequest asking for the completion

• partial – the partial string that must be completed

• params – optional parameters

Returns a list of possible completions. Keep this list short, all data returned will be displayed.

enrich_list(items)Implement this to attach some extra information to each item of the given items list.

Use self.assign_attr(item, attr_name, value) to do that, it automatically detects dicts.

Example usage: adding state information to each item to prevent multiple queries to the State model.

get_item_count()Implement this if you don’t use Django model instances. Returns the number of items in the report.

get_template()Get the template that needs to be rendered

extra_context()(deprecated) Implement this to define some extra context for your template.

extra_context_request(request=None)Implement this to define some extra context for your template, based on the request.

1.2. AdvancedReport and Action reference 7

Page 12: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

get_filter_form()Ugly way to generate generic form for filters- but I can’t see better idea, how to do this

get_tabbed_filter_links()Example:

configured in report:

tabbed_filter_fields = ({

'card': {'images': {

'default': 'default.png','2FF': '2ff-image.img',

},'types': [

'2FF', '2FF/3FF', '2/3/4FF', '4FF']

}})

will result in (keys are slugified, so 2FF/3FF will be 2ff3ff):

['card': [

{'2FF': '2ff-image.png'},{'2FF/3FF', 'default.png'},

],]

Returns a dict for links with optional images.

get_filters_from_request(request)Return a dict used as argument to Model.objects.filter() function. But we need to be sure that we can filteron these fields so we check if there is no filter_* function defined in advanced report definition

get_object_list(request, ids=None)Returns all the objects in the report.

A second return value is extra context for rendering the template.

get_html_for_value(value)Override this method to generate HTML for specific values.

enrich_object(o, list=True, request=None)This method adds extra metadata to an item. When the list argument is True, enrich_list will be called onthe item. When calling this method multiple times, it is inefficient to call enrich_list, as it can be run onceon the whole list, so in this case set list to False. If supplied, the request will be attached to the item so thatyou can use this in your actions.

enrich_generic_relation(items, our_model, foreign_model, attr_name, fallback)This is a utility method that can be used to prefetch backwards generic foreign key relations. Use this ifyou have a lot of lookups of this kind when generating the report.

Parameters:

• items: a iterable of items where we want to attach the backwards relation object.

• our_model: the type of items where the generic foreign key points to.

• foreign_model: the type of items that have a generic foreign relation to our_model.

8 Chapter 1. The Reports

Page 13: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

• attr_name: specifies name of the attribute that will contain an instance of foreign_model.

• fallback: a function that will be called when the backwards relation was not found. It must accepta our_model instance and must return a foreign_model instance.

enrich_backward_relation(items, foreign_model, field_name, related_name, our_index=None,our_foreign_index=None, select_related=None, many=True)

This is a utility method that can be used to pretech backward relations. For instance, you can add subscrip-tion lists to each user using only one line of code.

Parameters:

• items: a iterable of items where we want to attach the backwards relation object.

• foreign_model: the type of items that have a foreign relation to our_model.

• field_name: the field name of foreign_model that points to our_model.

• related_name: specifies name of the attribute that will contain (a list of) instances of for-eign_model.

• our_index: a callable that gets the id of an instance of our_model.

• our_foreign_index: a callable that gets the id of our instance from foreign_model.

• select_related: performs a select_related on the query on foreign_model.

• many: if set to False, a single item will be assigned instead of a list. When the list is empty, Nonewill be assigned.

assign_attr(object, attr_name, value)Assigns a value to an attribute. When the given object is a dict, the value will be assigned as a key-valuepair.

1.2.2 action

class advanced_reports.defaults.action(title=None, **kwargs)

method = NoneRequired when not using the decorator. This is a string with the method name of your AdvancedReportsubclass. This method must accept an item instance. If you choose to use a form, it gets an item and abound form. If something goes wrong in your action, raise an ActionException with a message to displayto the user.

verbose_name = NoneRequired. This is what the user will see in the frontend. If your action is simple (as in, it has no form), thiswill be the name of the web link. If your action uses a form, this will be a title that will be placed beforeit. If you don’t want to display that, just use u’‘.

success = NoneOptional. This will be used as the success message when your action has successfully executed.

confirm = NoneOptional. When filled in, a confirmation dialog will be displayed using this attribute as the prompt.

group = NoneOptional. When used together with a override of verify_action_group, you can define on a per-item basis which action will be shown or not. This is useful when your items have a certain state onlyallowing for actions directly related to that state.

1.2. AdvancedReport and Action reference 9

Page 14: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

form = NoneOptional. A Django form class that should be used together with this action. Make sure your action methodhas a signature like this: def my_action(self, item, form):.

Actions support the use of Django forms. When assigning a form class to this action, the behavior ofactions will be altered in the following ways:

• A form will be presented to the user, most likely in a pop-up (if form_via_ajax is True, this isthe default when using the @action decorator version). The submit button of the form will have thesubmit attribute of this action as the caption.

• When using a ModelForm, the current item instance (if available) will be used as the form’sinstance. keyword argument.

• Upon submission of this form, Advanced Reports will try to validate the form. If the form is notvalid, the form errors are automatically displayed to the frontend, instead of executing the underlyingaction. If the form does pass the validation, the underlying action is called with the validated formas an extra argument. If you are using a ModelForm, you can just perform a form.save() in theaction method body.

form_via_ajax = FalseDetermines whether the action form should be shown as a pop-up dialog in the frontend or not. The defaultvalue is False, but if you are using the @action decorator version, the default is True. This strange defaultbehavior is merely for backwards compatibility.

prefetch_ajax_form = FalseDetermines whether the action form should be rendered at the time of the report items generation. Bydefault this is False, but inline action forms (when form_via_ajax is False) will always be prefetched,as they are directly visible.

link_via_ajax = FalseIf True, the link behind the action will be loaded in a pop-up. This only works if the template supportsthis. An alternative system for showing pop-ups is just returning the html for this pop-up in the body ofthe action method. This is implemented in the AngularJS version.

submit = u'Submit'Required when using form. This is the value of your submit button when using forms.

show_submit = TrueOptional. If True, the submit button will be shown. The hiding of the submit button only works when thetemplate supports this.

collapse_form = FalseOptional. Only used when the template supports this.

form_template = NoneIf a template path is assigned to this attribute, this template will be rendered instead of the output of {{form }}. The template receives form and item as context variables.

form_instance = NoneOptional. If set, this instance will be used to pass to a ModelForm. You can also supply a callable. Thekwargs are: instance and optionally param.

next_on_success = FalseOptional. If True, when an action was executed successfully, the current row will be collapsed and the nextrow will be expanded, and the first field of the first form gets the input focus.

hidden = FalseMakes the action invisible. If you want to use this action somewhere else, you can use the {% url ‘ad-vanced_reports_action’ report_slug action_method item_id %} to execute the action.

10 Chapter 1. The Reports

Page 15: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

css_class = NoneOptional. A custom css class for this action.

individual_display = TrueWhether the action is shown on individual items. It could be that an action is only designed to work on abulk items. When setting to False, you remove them from the individual items.

multiple_display = TrueEnable the use of actions than can execute on multiple items. If you want to implement bulkmethods operating directly on a list or queryset (if applicable), you can implement an extra defFOO_multiple(self, items, form=None): where FOO is the method name of your action.If not, it will just loop through your items and execute your action on each item one after another.

has_file_upload = FalseIf the form of the action has a file upload, set this to True. Then the enctype=”multipart/form-data” will beadded to the <form> tag.

permission = NoneOptional. The permission required for this action.

regular_view = FalseWhether the action method acts like a regular Django view.

is_report_action = FalseWhether the action is report-wide or not. Report-wide actions methods do not receive an argument con-taining the item. Only a form will be given if applicable. Report-wide actions are ideal for adding newitems or links to another web page.

is_new_style = FalseWhether the action is defined by the new style method (as a decorator) or not. The advantage is that newcool stuff that should not be backwards compatible can be enabled when this attribute is True.

1.2. AdvancedReport and Action reference 11

Page 16: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

12 Chapter 1. The Reports

Page 17: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

CHAPTER 2

The Backoffice

The Backoffice is a backoffice/backend website framework where you can easily add functionality in a clean way.

Topics:

13

Page 18: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

2.1 Backoffice and AngularJS

Note: The Backoffice website framework makes use of AngularJS for its web frontend. However, this does not meanthat you have to learn all the dirty details. You can choose yourself how much of AngularJS you actually want to use.

It is advised that you have a quick look a the homepage to grasp the examples illustrated there, so you have an ideawhat for example ng-show means.

2.1.1 BackOfficeApp module

Inside backoffice.js, found in the static folder, the angular.module('BackOfficeApp') can befound. Below is a list of everything included with this module.

2.1.2 boApi service

The boApi service exposes some function which make it easy to communicate to the backoffice_api.

• configure(url): configure the boApi service instance with the given url.

• get(method, params): perform an AJAX GET request to the configured url plus the method. Theparams will be converted to a querystring. Hence, nesting of objects is not supported here, only simpleparameters. Returns a $q.promise object, which resolves to the response data.

• post(method, data, url_suffix=''): perform an AJAX POST request to the configured url plusthe method and url_suffix. The data will be converted to JSON and be put in the request body. Hence,this is much more flexible than the get() call. Returns a $q.promise object, which resolves to the responsedata.

• post_form(method, data): The same as post() except that the data is encoded using theapplication/x-www-form-urlencoded scheme instead of put as JSON in the request body. Returns a$q.promise object, which resolves to the response data.

• link(method, params): Returns a web link based on the configured url plus the method. The paramswill be encoded as a querystring. This is useful for some API endpoints returning for example normal web pagesor downloadable content.

2.1.3 MainController controller

The main controller governing the Backoffice website. Some useful functions exposed to the $scope:

• isLoading(): Returns a boolean whether the boApi service is currently performing web requests. Can beuseful to temporarily disable some submit buttons, to prevent accidental double submissions:

<input type="submit" ng-disabled="isLoading()">

• fetchModel(force): Refetches the model object, causing practically the whole page to refresh. See theThe model object section for more details on the contents of the model object.

• action(method, params): Calls the method method on the BackOfficeModel subclass and re-freshes the tab using fetchModel(true). See also The JavaScript side from the Backoffice Views section.

• call(method, params): The same as action() but without the refreshing. Returns a $q.promiseobject.

14 Chapter 2. The Backoffice

Page 19: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

• goto(route): Returns a function which goes to the given route. Handy to attach to a $q.promise fromthe call() function:

<form ng-submit="call('edit', {data: form.data}).then(goto(model.parents[0].→˓route))">

...</form>

• get_url(route, extra_routing_info={}): Returns a web link using the given route. It is pos-sible to inject some extra routing information, for example if you have a route object to a model, but you wantto navigate directly to a specific tab. Then you would call it like this: get_url(model.route, {tab:'details'}).

2.1.4 boReverser service

The boReverser service takes a route object and creates a web link from it. It does this in a generic way.

• configure(hierarchy, prefix='#/'): Configures this boReverser instance with the givenhierarchy, which is a list of named path components. The MainController controller, which depends onboReverser, uses this configuration:

boReverser.configure(['model', 'id', 'tab', 'detail']);

• reverse(route): Returns a web link based on the given route object, which is just a simple key/valuepair. Keys which are one of the configured hierarchy list, will render as a path delimited by slashes (/).Other keys are rendered as a querystring behind the path. Also, if there are hierarchy keys missing in theroute object, the rendered result depends on the current browser location and how far to the right that themissing key is on the hierarchy. Some examples based on the configuration above make this hopefully a bitclearer:

// Current path is: '#/'boReverser.reverse({model: 'user'})// Returns: '#/user/'

// Current path is: '#/'boReverser.reverse({model: 'user', id: 5})// Returns: '#/user/5/'

// Current path is: '#/user/5/'boReverser.reverse({tab: 'details'})// Returns: '#/user/5/details/'

// Current path is: '#/user/5/details/'boReverser.reverse({model: 'comment', id: 55})// Returns: '#/comment/55/'

// Current path is: '#/user/5/'boReverser.reverse({report: 'myreport'})// Returns: '#/user/5/?report=myreport'

As you can see, this small utility is quite powerful and covers most use cases for URL generation inside yourapplication.

2.1. Backoffice and AngularJS 15

Page 20: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

2.1.5 compile directive

Warning: Only use this during the development phase! This can be very dangerous on production and will easilyallow XSS attacks!

Use this directive like this:

<textarea ng-model="code" cols="80" rows="25"></textarea><div compile="code"></div>

Then you will have a <textarea> where you can try out some functionality, and the result will be displayedimmediately in the <div> below.

2.1.6 view directive

See also:

See also the Backoffice Views section.

<div view="myview" params="{a: 5, b: 3}" c="mystring" eval-d="5+3" instance="myview1">→˓</div>

The view directive renders a Backoffice View defined by a BackOfficeView subclass.

Attributes:

• view: The slug of the BackOfficeView subclass.

• params: An object with key/value pairs of parameters.

• *: An attribute that is passed as string (not evaluated). This will be added to the parameters.

• eval-*: An attribute that is passed as a calculated value. This will be added to the parameters.

• instance: (Optional) The name under which to expose the view object to the current $scope. By default,this is the slug. This is useful if you have multiple instances of views with the same slug and want to talk toone of them from the outside.

Functions and attributes exposed to the $scope of the view template:

• view.params: An object containing the parameters of the view.

• view.fetch(): Refetches the initial view template (calls get())

2.2 Backoffice Views

A Backoffice View is a combination of:

• A Django template

• A subclass of BackOfficeView which renders the template

• Optionally a piece of extra JavaScript used by the template

They provide a basis for extremely pluggable components that can be placed anywhere on the Backoffice.

16 Chapter 2. The Backoffice

Page 21: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

2.2.1 The Python side

A BackOfficeView subclass can be registered to a BackOfficeBase subclass instance using theregister_view() method.

One of the most important methods of the BackOfficeView base class is:

def get(self, request):return render(request, self.template, self.get_context(request))

The default implementation just returns a HttpResponse with the rendered self.template.

To add some extra context, implement get_extra_context:

def get_extra_context(self, request):return {}

A very simple view would then look like this:

from advanced_reports.backoffice.base import BackOfficeView

class SimpleView(BackOfficeView):template = 'my_simple_view.html'

def get_extra_context(self, request):return {'simple': True}

Defining a slug is not required. It will take by default the lowercase version of the class name minus the View-suffix.In this case, the slug would be "simple".

2.2.2 The Django Template side

Nothing special here, you can write any HTML you like including Django template tags. You have access to thecontext like you would expect.

2.2.3 The JavaScript side

See also:

See the Backoffice and AngularJS section

Warning: Because we are mixing AngularJS templates with Django templates, it is discouraged to use the {{}} interpolations from AngularJS. You can easily work around them by using ng-bind. If you really do require theinterpolations, you can always use the {% verbatim %} and {% endverbatim %} template tags. By doingthis, you can clearly see which parts of your template is rendered by the browser and the server.

Now things become interesting. As you already know, the Backoffice makes use of AngularJS for its web frontend.There is a view-directive exposed that you can use. This directive is used like this:

<div view="simple" params="{simpleness: 5}"></div>

What will happen is that the underlying get()-method gets called and the Django template will be rendered insidethis <div>. You have access to the params using request.view_params, which is a dict-like object you canquery.

2.2. Backoffice Views 17

Page 22: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

Not only that, your template itself has access to a special view object available in the $scope.

This object exposes the following API:

• view.fetch(): retrieve the template again (calls the get() again)

• view.action('method_name', {param1: 'lol'}): calls the method method_name on theBackOfficeView subclass and refreshes the view using view.fetch().

• view.call('method_name', {param1: 'lol'}): the same as view.action() but without therefreshing. Returns a promise object.

The method_name-method can look like this in Python:

class SimpleView(BackOfficeView):...

def method_name(self, request):param1 = request.action_params.get('param1')messages.success(request, 'successful happyness!')return {'happy': True, 'data': 3}

It is that easy to communicate from your JavaScript frontend to your Python code. Notice that you can use the Djangomessages framework. They show up in the Backoffice website! Make sure that you only use simple objects in thecommunication, as they will be converted to JSON behind the scenes.

2.2.4 Full example

This example illustrates how this simple view is constructed:

18 Chapter 2. The Backoffice

Page 23: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

simple.html

<div class="panel panel-default"><div class="panel-heading">

<h2>View Example: &lt;div view="simple"<span ng-show="view.params.extra=='true→˓'"> extra="true"</span>&gt;&lt;/div&gt;</h2>

</div>

<div class="panel-body"><p>

My view slug according to my Django context is: {{ view_slug }}</p>

<form class="form"><button class="btn btn-default" ng-click="ip=view.call('get_ip', {})">Get

→˓IP</button><input class="form-control" type="text" ng-model="ip" disabled>

</form>

<table class="table" ng-init="items=view.call('get_items', {})"><thead>

<tr><th>Key</th><th>Value</th></tr></thead><tbody>

<tr ng-repeat="(key, value) in items">

2.2. Backoffice Views 19

Page 24: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

<td ng-bind="key"></td><td ng-bind="value"></td>

</tr></tbody>

</table>

<div ng-show="view.params.extra == 'true'">Showing this paragraph because <pre>extra="true"</pre> is being used.

</div></div>

</div>

views.py

from advanced_reports.backoffice.base import BackOfficeView

class SimpleView(BackOfficeView):template = 'simple.html'

def get_ip(self, request):return request.META['REMOTE_ADDR']

def get_items(self, request):return {'a': 5, 'b': 3, 'c': 4}

definitions.py

...

backoffice_instance.register_view(SimpleView)

...

anywhere.html

<div view="simple" extra="true"></div>

2.3 Backoffice Models

A Backoffice Model is a combination of:

• A Django model

• A subclass of BackOfficeModel

• Templates for the tabs defined in the BackOfficeModel subclass

When you attach a Django model to a BackOfficeModel, and register it to a BackOfficeBase subclass, it willbecome a part of the Backoffice website.

20 Chapter 2. The Backoffice

Page 25: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

2.3.1 Creating a BackOfficeModel

Let’s have a look at a fairly minimal example which exposes the Django User model.

definitions.py

class UserModel(BackOfficeModel):model = User

tabs = (BackOfficeTab('details', u'Details', 'user-details.html'),)

def get_title(self, instance):return u'%s (%s)' % (instance.username, instance.get_full_name())

def search_index(self, instance):return u' '.join((instance.username, instance.get_full_name(), instance.

→˓email))

...

backoffice_instance.register_model(UserModel)

...

As you can see, we just say that we want to use the User model, and that we want to show only one tab for it, called“Details”, rendered by a template “user-details.html”:

<div view="user" params="{pk: model.id}"></div>

As you can see, this is a simple invocation of the “user” view. This is what will be rendered when the end users selectsthe “Details” tab.

Note: If you don’t know what is meant by a “view” here, refer to the Backoffice Views section.

2.3.2 The model object

What stands out in this view invocation is the {pk: model.id} parameter. In your BackOfficeTab template,you have access to a model object in the current AngularJS $scope. This object represents an instance of yourmodel. In our example, this represents a single user. Thanks to this model object, the view knows which user todisplay.

In this case, this is what the model object contains:

{"title": "jef (Jef Geskens)","tabs": {"details": {

"shadow": null,"slug": "details","template": "...","title": "Details"

}},

2.3. Backoffice Models 21

Page 26: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

"route": {"model": "user","id": 1

},"id": 1,"meta": {"tabs": [

{"shadow": null,"slug": "details","title": "Details"

}],"show_in_parent": false,"collapsed": true,"verbose_name_plural": "users","has_header": true,"verbose_name": "user","slug": "user","is_meta": true

},"parents": [],"is_object": true,"model": "user","children": [],"header_template": "..."

}

This looks like a lot of information, but apart from the basic meta information about your model, we add extra infor-mation related to parents, children, relationships, tabs, headers and routes. Most of this extra stuff will probably notdirectly be useful for you, but it helps the Backoffice website render the tabs, menu items, parent links, child links andheaders.

Note: Using this information, you could write your own frontend with your technology of choice to implement thesame Backoffice functionality. Or, you could extend or replace existing functionality.

Let’s go over the most useful parts:

• "title": This comes directly from your get_title() implementation.

• "model": This is the model slug.

• "id": This is the primary key value of your model instance.

• "route": This object can be directly passed to the $scope.get_url() function in the AngularJS environ-ment. It looks redundant but it is guaranteed to only contain route-related components.

This list can be extended using the serialize() method.

See also:

The boReverser service

2.4 Backoffice Reference

BackOfficeBase is the base class and entry point for the backoffice website. It defines the base urls and views for

22 Chapter 2. The Backoffice

Page 27: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

logging in, and the core REST-like API implementation which serves as a basis for extensions.

BackOfficeBase is extended by a few mixins:

• ModelMixin

• SearchMixin

• ViewMixin

advanced_reports.backoffice.base.random_token()

advanced_reports.backoffice.base.check_permission(request, permission)Checks whether the current request has access to the given permission. If the permission argument is None,and the request is of a logged in user, we return True.

Parameters

• HttpRequest (request) – The current request

• str (permission) – The permission as a string of ‘<app name>.<permission code-name>’.

Return bool True if the request has access to the given permission.

class advanced_reports.backoffice.base.AutoSlug(remove_suffix=None)

class advanced_reports.backoffice.base.AutoTemplate(directory, remove_suffix=None)

class advanced_reports.backoffice.base.BackOfficeTab(slug, title, template=None, per-mission=None, shadow=None,context=None)

A tab that will be shown for a BackOfficeModel. A BackOfficeModel can have some tabs associatedwith it. Each tab is represented by:

• slug: The unique (inside a model) slug for a tab. Used for navigation in the URL.

• title: A human title that will pe used as the caption for a tab.

2.4. Backoffice Reference 23

Page 28: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

• template: The path to a template that must be rendered inside the tab. This template is given theinstance context variable, which contains the current model instance.

slug = None

title = None

template = None

permission = None

get_serialized_meta()

get_serialized(request, instance)

class advanced_reports.backoffice.base.BackOfficeModelThe base class for a BackOfficeModel implementation. Implement this class and register your own Djangomodels to a backoffice.

slug = 'backoffice'A unique slug to identify a model (‘user’, ‘sim’, . . . )

model = NoneThe actual Django model that is being used

parent_field = None(optional) The name of a ForeignKey that points to a parent object. If this parent is registered with thesame backoffice, they are shown as a parent/child relation.

parent_fields = None(optional) The plural version of parent_field.

verbose_name = NoneVerbose name for displaying purposes. Should be lowercase. E.g. ‘user’

verbose_name_plural = NonePlural verbose name for displaying purposes. Should be lowercase. E.g. ‘users’

siblings = NoneInclude siblings of specified parent slug in serialization.

priority = 999Define a priority that will be used for displaying purposes. Can also be used as a way to sort models bykind, if used uniquely.

has_header = TrueFor displaying purposes. Will probably change, so leave alone.

collapsed = TrueFor displaying purposes. Will probably change, so leave alone.

show_in_parent = FalseWhether we want to appear as a menu of children in the parent view

header_template = NoneAn optional template path to render a header for a model instance above the tabs.

tabs = ()A tuple of BackOfficeTab instances. These tabs can contain templates which in turn can display extrainformation about this model.

permission = NoneAn optional string containing a permission which has to be checked against the request that queries thismodel. If the permission is not satisfied, the model will not show up in search results and will never display.

24 Chapter 2. The Backoffice

Page 29: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

children = NoneA mapping of slugs to BackOfficeModel implementation instances to represent kinds of children. Thisproperty will be automatically filled when you register your parent and child models with a BackOfficeBaseimplementation instance.

child_to_accessor = None

parents = NoneA mapping of slugs to BackOfficeModel implementation instances to represent kinds of parents. Thisproperty will be automatically filled when you register your parent and child models with a BackOfficeBaseimplementation instance.

parent_to_accessor = None

search_index_dependencies = NoneWhen you have overridden search_index and included child objects in your search index (e.g. com-ments on a user) you can define these child models to trigger a reindex when a child changes. Example:{Comment: (lambda c: c.content_object, User)}. In the value of this dictionary youdefine a tuple with a function which knows how to find the parent object and a model type to make surewe are getting the right argument to our search_index implementation.

get_title(instance)A textual representation of a model instance to be used as a title.

serialize(instance)Override this to add extra information to be exposed to the Angular side of your tab templates.

render_template(request, instance)

get_parent_model_slug_for_field(parent_field)

get_parent_accessor_to_myself(parent_field)

get_parent_accessor_from_myself(parent_field)

get_route(instance)

get_serialized(request, instance, children=False, parents=False, siblings=False, tem-plates=False)

parent_fields_list

get_children_by_model(request, instance, bo_model)

get_serialized_children_by_model(request, instance, bo_model, exclude_meta=False)

get_parent_by_model(request, instance, bo_model)

get_serialized_parent_by_model(request, instance, bo_model)

serialize_meta(request)

get_children(request, instance)

get_parents(request, instance)

reindex(instance, backoffice_instance)

delete_index(instance, backoffice_instance)

search_index(instance)

class advanced_reports.backoffice.base.ModelMixinThis mixin implements support for BackOfficeModels.

Requires that self.name is available.

2.4. Backoffice Reference 25

Page 30: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

model_to_bo_model = NoneA mapping between Django models and BackOfficeModel implementation instances.

slug_to_bo_model = NoneA mapping between the slug of a BackOfficeModel implementation and BackOfficeModel im-plementation instances. This is where slugs will be resolved to their actual BackOfficeModel instance.

search_index_dependency_to_dependants = {}A mapping between Django models and lists of BackOfficeModel instances that depend on the Djangomodels for their search_index.

register_model(bo_model)Register a BackOfficeModel implementation class with this backoffice.

Parameters bo_model – a BackOfficeModel implementation class

get_model(slug=None, model=None)Gets a registered BackOfficeModel implementation instance either by slug or Django model.

serialize_model_instance(request, instance, include_children=False)Serializes an Django model instance that is registered with this backoffice using theirBackOfficeModel implementation.

Parameters

• instance – a Django model instance

• include_children – whether to include children in the

serialization :return: a simple Python object that is JSON serializable

serialize_model_instances(request, instances, include_children=False)Serializes multiple Django model instances using serialize_model_instance.

Parameters instances – an iterable containing registered Django model

instances registered with this backoffice. :param include_children: whether to include children in theserialization :return: a list of simple Python objects that are JSON serializable.

link_relationship(bo_model)Links parent BackOfficeModel implementations with their parents and children. The parent will geta children attribute containing a mapping between the children slugs and child BackOfficeModelimplementations.

Parameters bo_model – a child BackOfficeModel implementation instance

that wants to link with its parent.

api_get_model(request)API call to retrieve a serialized Django model instance using his BackOfficeModel implementation.

Parameters request – request.view_params with 'model_slug' and 'pk'

Returns a serialized Django model instance using his

BackOfficeModel implementation.

api_post_model_action(request)Performs an action to a given view.

Parameters request – request.view_params with 'method', 'params'and 'view_params'

Returns the results of the called view method.

26 Chapter 2. The Backoffice

Page 31: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

class advanced_reports.backoffice.base.SearchMixinThis mixin implements support for searching through BackOfficeModels.

serialize_search_result(request, index)Transforms a SearchIndex instance to a serialized BackOfficeModel including metadata.

count_by_model(request, indices)Given an iterable of SearchIndex instances, return a report of counts by model_slug, and theirserialized BackOfficeModel metadata.

Parameters indices – an iterable of SearchIndex instances

Returns [{'meta': {'slug': 'user', ...}, 'count': 15}, ...]

serialize_search_results(request, indices)Transforms SearchIndex instances to a list of serialized BackOfficeModel including metadata.

search(request, query, filter_on_model_slug=None, page=1, page_size=20, include_counts=True)Performs a search on Django models registered with this backoffice.

Parameters

• query – The search query.

• filter_on_model_slug – (optional) a BackOfficeModel slug

to filter on :param page: (optional) the page of the search results to show. By default 1. :parampage_size: (optional) the page size. By default 20. :param include_counts: (optional) whetherto include the counts. :return: {'results': [self.serialize_search_results()],'model_counts': [self.count_by_model()]}

reindex_all_models()

api_get_search(request)API call implementation for self.search(). It passes on q, page and filter_model from therequest.view_params.

Parameters request – a HttpRequest containing view_params.

Returns the results of self.search().

api_get_search_preview(request)API call to perform a search preview. It passes on q, page and filter_model. It uses a page_sizeof 5.

Parameters request – a HttpRequest containing view_params.

Returns the results of self.search(page_size=5).

api_get_reindex(request)

class advanced_reports.backoffice.base.BackOfficeViewA BackOfficeView is a combination of Python/Django code with the view AngularJS Directive. Whenregistered to a BackOfficeBase subclass instance, this will be shown by the view directive when calledwith the correct slug.

slug = 'backoffice'The slug of the view. If not explicitly filled in, the “View” suffix will be stripped off the subclass nameand the remaining prefix will be converted to lowercase. For example, a UserView subclass will getautomatically the slug 'user'.

template = u'advanced_reports/backoffice/views/backoffice.html'The template for the view. If not explicitly filled in, it will default to, for example when the subclass hasthe name UserView, 'advanced_reports/backoffice/views/user.html'.

2.4. Backoffice Reference 27

Page 32: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

permission = NoneWhen filled in, this permission will be checked against the currently logged in user. If the user does nothave this permission, nothing of this view will be exposed to this user.

serialize(content, extra_context=None)Serializes the given content to a format that is easy to encode to JSON.

serialize_view_result(request, result)

get_serialized(request)

get_serialized_post(request)

get_context(request)

get_extra_context(request)

get(request)

post(request)

FOO(request)

class advanced_reports.backoffice.base.ViewMixinThis mixin implements support for BackOfficeViews.

slug_to_bo_view = NoneThe internal view registration dict

register_view(bo_view)Registers a BackOfficeView implementation class with this backoffice.

Parameters bo_view – a BackOfficeView implementation class

get_view(slug)Gets a registered BackOfficeView implementation instance by slug.

api_get_view(request)Retrieves a BackOfficeView implementation based on the given slug and calls theget_serialized() method on it, whose contents are returned.

Parameters request – request.view_params with 'view_slug'

Returns a serialized view content

api_post_view(request)Retrieves a BackOfficeView implementation based on the given slug and calls theget_serialized_post() method on it, whose contents are returned.

Parameters request – request.view_params with 'view_slug'

Returns a serialized view content

api_post_view_action(request)Performs an action to a given view.

Parameters request – request.view_params with 'method', 'params'and 'view_params'

Returns the results of the called view method.

api_get_view_view(request)Calls a regular Django view on the given BackOffice view.

Parameters request – request.view_params with 'method' and'view_slug'

28 Chapter 2. The Backoffice

Page 33: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

Returns the HttpResponse from the BackOffice method with the name inside ‘method’

api_post_view_view(request)Alias to api_get_view_view to support POST requests as well.

class advanced_reports.backoffice.base.BackOfficeBase(name=’backoffice’,app_name=’backoffice’)

The base class of a Back Office application. Inherit from this class and define your own custom backoffice!

title = 'Untitled Backoffice'The title of the BackOffice application. This is used on pages that inherit from the model_template.

model_template = 'advanced_reports/backoffice/model-base.html'The template file that will be used to show models. It has to define an ng-view inside of it. Please extendthe default template if you want to specify your own navigation (which you will probably want to do) andput your own template here.

login_template = 'advanced_reports/backoffice/login.html'The template file that will be used to show the login form.

logout_template = 'advanced_reports/backoffice/logout.html'The template file that will be used as the logout confirmation page.

define_urls()Implement this to add some custom url patterns to a backoffice. They will automatically get the propernamespacing. For example, if your backoffice is called “helpdesk” and your url is called “stats”, you mustuse {% url 'helpdesk:stats' %} in your templates.

Returns a tuple/list of url patterns (not using patterns()!)

urlsThe actual url patterns for this backoffice. You can include these in your main urlconf.

Returns url patterns

decorate(view)Implement this to add some custom decoration for the internal Django views for this backoffice.

Parameters view – the view to decorate

Returns the decorated view

default_context()Default template context values for internal backoffice page.

Returns context dict

logout(request, *args, **kwargs)Calls django.contrib.auth.views.logout with a custom template and extra context.

home(request)The main Django view for this backoffice.

login_as(request, user_id)

end_login_as(request)

api(request, method=None)A very simple REST-like API implementation which just passes requests on to the right functions.

An instance of advanced_reports.backoffice.api_utils.ViewRequestParameterswill be assigned to the request as view_params.

Parameters

• request – A HTTP request where view_params will be attached to.

2.4. Backoffice Reference 29

Page 34: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

• method – The actual instance method of this backoffice class that will

be called. :return: a JSONResponse

handle(request)

30 Chapter 2. The Backoffice

Page 35: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

CHAPTER 3

Changelog

3.1 0.9.2 (2015-02-20)

• First release on PyPI.

3.2 0.9.3 (2015-02-27)

• Add api for reindexing the search index

• Small bugfixes related to sorting querysets in reports

• Extra unit tests for report sorting

• Remove redundant AutoSlug for BackOfficeTab

3.3 0.9.4 (2015-02-27)

• Fix issue where the translation system could be triggered too soon

3.4 0.9.5 (2015-03-03)

• Add possibility to add report-wide actions using is_report_action=True.

• Add full CRUD example to examples page on demo website

• Small bugfix concerning the confirmation dialog

31

Page 36: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

3.5 0.9.6 (2015-03-04)

• Escape AdvancedReport field values by default for security

• Add link_to HTML decorator possibility by providing the BackOfficeReportMixin

• Small cleanups and fix MANIFEST.in

• Fix setup.py and add changelog to docs

• Converted README to reST format

3.6 0.9.7 (2015-03-05)

• 2691ba3 Fix report form error styling issue <Jef Geskens>

• 31ee2e5 Add example of link_to HTML decorator <Jef Geskens>

• 086ec98 Fix enriched queryset ordering issue <Jakub Paczkowski>

• 3a47616 Add tests for the enriched queryset ordering issue fix <Jakub Paczkowski>

• 521a257 Add default ordering to the enriched queryset <Jakub Paczkowski>

3.7 0.9.8 (2015-03-10)

• 7e4adf4 Expose fetch_report so it can be called from outside <Jef Geskens>

• ca38578 Fix styling issue for new compact view <Jef Geskens>

• 5406d7b Extra examples for new compact property <Jef Geskens>

• 8118733 Introduce compact mode and inline action buttons <Jef Geskens>

3.8 0.9.9 (2015-09-07)

• ced26b2 deduplicate call <Daniel Borzecki>

• 61f032d ensure request is present when executing multiple actions <Daniel Borzecki>

• 961c1d0 enable row limit choice in reports’ pages <Alexandros Ntavelos>

• a92567e re-arrange if/else conditions <Alexandros Ntavelos>

• d51a6b7 fix for tests <Jakub Paczkowski>

• 7ed1664 add comment <Jakub Paczkowski>

• 2890472 fix generation of large csv’s <Jakub Paczkowski>

• 8685a81 optimize generation of csv <Jakub Paczkowski>

32 Chapter 3. Changelog

Page 37: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

CHAPTER 4

Indices and tables

• genindex

• modindex

• search

33

Page 38: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

34 Chapter 4. Indices and tables

Page 39: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Python Module Index

aadvanced_reports.backoffice.base, 23

35

Page 40: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

36 Python Module Index

Page 41: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Index

Aaction (class in advanced_reports.defaults), 9action_list_type (advanced_reports.defaults.AdvancedReport

attribute), 5advanced_reports.backoffice.base (module), 23AdvancedReport (class in advanced_reports.defaults), 3animation (advanced_reports.defaults.AdvancedReport

attribute), 4api() (advanced_reports.backoffice.base.BackOfficeBase

method), 29api_get_model() (advanced_reports.backoffice.base.ModelMixin

method), 26api_get_reindex() (advanced_reports.backoffice.base.SearchMixin

method), 27api_get_search() (advanced_reports.backoffice.base.SearchMixin

method), 27api_get_search_preview() (ad-

vanced_reports.backoffice.base.SearchMixinmethod), 27

api_get_view() (advanced_reports.backoffice.base.ViewMixinmethod), 28

api_get_view_view() (ad-vanced_reports.backoffice.base.ViewMixinmethod), 28

api_post_model_action() (ad-vanced_reports.backoffice.base.ModelMixinmethod), 26

api_post_view() (advanced_reports.backoffice.base.ViewMixinmethod), 28

api_post_view_action() (ad-vanced_reports.backoffice.base.ViewMixinmethod), 28

api_post_view_view() (ad-vanced_reports.backoffice.base.ViewMixinmethod), 29

assign_attr() (advanced_reports.defaults.AdvancedReportmethod), 9

auto_complete() (advanced_reports.defaults.AdvancedReportmethod), 7

AutoSlug (class in advanced_reports.backoffice.base), 23AutoTemplate (class in ad-

vanced_reports.backoffice.base), 23

BBackOfficeBase (class in ad-

vanced_reports.backoffice.base), 29BackOfficeModel (class in ad-

vanced_reports.backoffice.base), 24BackOfficeTab (class in ad-

vanced_reports.backoffice.base), 23BackOfficeView (class in ad-

vanced_reports.backoffice.base), 27

Ccheck_permission() (in module ad-

vanced_reports.backoffice.base), 23child_to_accessor (advanced_reports.backoffice.base.BackOfficeModel

attribute), 25children (advanced_reports.backoffice.base.BackOfficeModel

attribute), 24collapse_form (advanced_reports.defaults.action at-

tribute), 10collapsed (advanced_reports.backoffice.base.BackOfficeModel

attribute), 24compact (advanced_reports.defaults.AdvancedReport at-

tribute), 5confirm (advanced_reports.defaults.action attribute), 9count_by_model() (advanced_reports.backoffice.base.SearchMixin

method), 27css_class (advanced_reports.defaults.action attribute), 10

Ddate_range (advanced_reports.defaults.AdvancedReport

attribute), 4decorate() (advanced_reports.backoffice.base.BackOfficeBase

method), 29decorate_views (advanced_reports.defaults.AdvancedReport

attribute), 4

37

Page 42: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

default_context() (advanced_reports.backoffice.base.BackOfficeBasemethod), 29

define_urls() (advanced_reports.backoffice.base.BackOfficeBasemethod), 29

delete_index() (advanced_reports.backoffice.base.BackOfficeModelmethod), 25

Eempty_text (advanced_reports.defaults.AdvancedReport

attribute), 4end_login_as() (advanced_reports.backoffice.base.BackOfficeBase

method), 29enrich_backward_relation() (ad-

vanced_reports.defaults.AdvancedReportmethod), 9

enrich_generic_relation() (ad-vanced_reports.defaults.AdvancedReportmethod), 8

enrich_list() (advanced_reports.defaults.AdvancedReportmethod), 7

enrich_object() (advanced_reports.defaults.AdvancedReportmethod), 8

extra_context() (advanced_reports.defaults.AdvancedReportmethod), 7

extra_context_request() (ad-vanced_reports.defaults.AdvancedReportmethod), 7

Ffields (advanced_reports.defaults.AdvancedReport

attribute), 5filter_fields (advanced_reports.defaults.AdvancedReport

attribute), 3filter_FOO() (advanced_reports.defaults.AdvancedReport

method), 6filter_values (advanced_reports.defaults.AdvancedReport

attribute), 4FOO() (advanced_reports.backoffice.base.BackOfficeView

method), 28FOO() (advanced_reports.defaults.AdvancedReport

method), 6FOO_multiple() (advanced_reports.defaults.AdvancedReport

method), 6FOO_view() (advanced_reports.defaults.AdvancedReport

method), 6form (advanced_reports.defaults.action attribute), 9form_instance (advanced_reports.defaults.action at-

tribute), 10form_template (advanced_reports.defaults.action at-

tribute), 10form_via_ajax (advanced_reports.defaults.action at-

tribute), 10

Gget() (advanced_reports.backoffice.base.BackOfficeView

method), 28get_children() (advanced_reports.backoffice.base.BackOfficeModel

method), 25get_children_by_model() (ad-

vanced_reports.backoffice.base.BackOfficeModelmethod), 25

get_context() (advanced_reports.backoffice.base.BackOfficeViewmethod), 28

get_decorator() (advanced_reports.defaults.AdvancedReportmethod), 6

get_extra_context() (ad-vanced_reports.backoffice.base.BackOfficeViewmethod), 28

get_extra_information() (ad-vanced_reports.defaults.AdvancedReportmethod), 7

get_filter_form() (advanced_reports.defaults.AdvancedReportmethod), 7

get_filters_from_request() (ad-vanced_reports.defaults.AdvancedReportmethod), 8

get_FOO_class() (advanced_reports.defaults.AdvancedReportmethod), 6

get_FOO_decorator() (ad-vanced_reports.defaults.AdvancedReportmethod), 6

get_FOO_form() (advanced_reports.defaults.AdvancedReportmethod), 6

get_FOO_html() (advanced_reports.defaults.AdvancedReportmethod), 6

get_FOO_style() (advanced_reports.defaults.AdvancedReportmethod), 7

get_FOO_verbose_name() (ad-vanced_reports.defaults.AdvancedReportmethod), 6

get_html_for_value() (ad-vanced_reports.defaults.AdvancedReportmethod), 8

get_item_class() (advanced_reports.defaults.AdvancedReportmethod), 6

get_item_count() (advanced_reports.defaults.AdvancedReportmethod), 7

get_item_for_id() (advanced_reports.defaults.AdvancedReportmethod), 6

get_item_id() (advanced_reports.defaults.AdvancedReportmethod), 6

get_model() (advanced_reports.backoffice.base.ModelMixinmethod), 26

get_object_list() (advanced_reports.defaults.AdvancedReportmethod), 8

get_parent_accessor_from_myself() (ad-vanced_reports.backoffice.base.BackOfficeModel

38 Index

Page 43: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

method), 25get_parent_accessor_to_myself() (ad-

vanced_reports.backoffice.base.BackOfficeModelmethod), 25

get_parent_by_model() (ad-vanced_reports.backoffice.base.BackOfficeModelmethod), 25

get_parent_model_slug_for_field() (ad-vanced_reports.backoffice.base.BackOfficeModelmethod), 25

get_parents() (advanced_reports.backoffice.base.BackOfficeModelmethod), 25

get_route() (advanced_reports.backoffice.base.BackOfficeModelmethod), 25

get_serialized() (advanced_reports.backoffice.base.BackOfficeModelmethod), 25

get_serialized() (advanced_reports.backoffice.base.BackOfficeTabmethod), 24

get_serialized() (advanced_reports.backoffice.base.BackOfficeViewmethod), 28

get_serialized_children_by_model() (ad-vanced_reports.backoffice.base.BackOfficeModelmethod), 25

get_serialized_meta() (ad-vanced_reports.backoffice.base.BackOfficeTabmethod), 24

get_serialized_parent_by_model() (ad-vanced_reports.backoffice.base.BackOfficeModelmethod), 25

get_serialized_post() (ad-vanced_reports.backoffice.base.BackOfficeViewmethod), 28

get_tabbed_filter_links() (ad-vanced_reports.defaults.AdvancedReportmethod), 8

get_template() (advanced_reports.defaults.AdvancedReportmethod), 7

get_title() (advanced_reports.backoffice.base.BackOfficeModelmethod), 25

get_view() (advanced_reports.backoffice.base.ViewMixinmethod), 28

group (advanced_reports.defaults.action attribute), 9

Hhandle() (advanced_reports.backoffice.base.BackOfficeBase

method), 30has_file_upload (advanced_reports.defaults.action at-

tribute), 11has_header (advanced_reports.backoffice.base.BackOfficeModel

attribute), 24header_template (advanced_reports.backoffice.base.BackOfficeModel

attribute), 24header_visible (advanced_reports.defaults.AdvancedReport

attribute), 5

help_text (advanced_reports.defaults.AdvancedReport at-tribute), 4

hidden (advanced_reports.defaults.action attribute), 10home() (advanced_reports.backoffice.base.BackOfficeBase

method), 29

Iindividual_display (advanced_reports.defaults.action at-

tribute), 11internal_mode (advanced_reports.defaults.AdvancedReport

attribute), 5internal_template (advanced_reports.defaults.AdvancedReport

attribute), 4is_new_style (advanced_reports.defaults.action attribute),

11is_report_action (advanced_reports.defaults.action

attribute), 11item_actions (advanced_reports.defaults.AdvancedReport

attribute), 5item_template (advanced_reports.defaults.AdvancedReport

attribute), 4items_per_page (advanced_reports.defaults.AdvancedReport

attribute), 4

Llink_relationship() (ad-

vanced_reports.backoffice.base.ModelMixinmethod), 26

link_via_ajax (advanced_reports.defaults.action at-tribute), 10

links (advanced_reports.defaults.AdvancedReport at-tribute), 4

login_as() (advanced_reports.backoffice.base.BackOfficeBasemethod), 29

login_template (advanced_reports.backoffice.base.BackOfficeBaseattribute), 29

logout() (advanced_reports.backoffice.base.BackOfficeBasemethod), 29

logout_template (advanced_reports.backoffice.base.BackOfficeBaseattribute), 29

Mmethod (advanced_reports.defaults.action attribute), 9model (advanced_reports.backoffice.base.BackOfficeModel

attribute), 24model (advanced_reports.defaults.AdvancedReport at-

tribute), 5model_template (advanced_reports.backoffice.base.BackOfficeBase

attribute), 29model_to_bo_model (ad-

vanced_reports.backoffice.base.ModelMixinattribute), 25

ModelMixin (class in advanced_reports.backoffice.base),25

Index 39

Page 44: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

models (advanced_reports.defaults.AdvancedReport at-tribute), 5

multiple_actions (advanced_reports.defaults.AdvancedReportattribute), 4

multiple_display (advanced_reports.defaults.action at-tribute), 11

Nnext_on_success (advanced_reports.defaults.action at-

tribute), 10

Pparent_field (advanced_reports.backoffice.base.BackOfficeModel

attribute), 24parent_fields (advanced_reports.backoffice.base.BackOfficeModel

attribute), 24parent_fields_list (advanced_reports.backoffice.base.BackOfficeModel

attribute), 25parent_to_accessor (ad-

vanced_reports.backoffice.base.BackOfficeModelattribute), 25

parents (advanced_reports.backoffice.base.BackOfficeModelattribute), 25

permission (advanced_reports.backoffice.base.BackOfficeModelattribute), 24

permission (advanced_reports.backoffice.base.BackOfficeTabattribute), 24

permission (advanced_reports.backoffice.base.BackOfficeViewattribute), 27

permission (advanced_reports.defaults.action attribute),11

post() (advanced_reports.backoffice.base.BackOfficeViewmethod), 28

prefetch_ajax_form (advanced_reports.defaults.action at-tribute), 10

priority (advanced_reports.backoffice.base.BackOfficeModelattribute), 24

Qqueryset() (advanced_reports.defaults.AdvancedReport

method), 5

Rrandom_token() (in module ad-

vanced_reports.backoffice.base), 23register_model() (advanced_reports.backoffice.base.ModelMixin

method), 26register_view() (advanced_reports.backoffice.base.ViewMixin

method), 28regular_view (advanced_reports.defaults.action attribute),

11reindex() (advanced_reports.backoffice.base.BackOfficeModel

method), 25

reindex_all_models() (ad-vanced_reports.backoffice.base.SearchMixinmethod), 27

render_template() (advanced_reports.backoffice.base.BackOfficeModelmethod), 25

report_action_allowed() (ad-vanced_reports.defaults.AdvancedReportmethod), 7

report_header_visible (ad-vanced_reports.defaults.AdvancedReportattribute), 5

request (advanced_reports.defaults.AdvancedReport at-tribute), 3

Ssearch() (advanced_reports.backoffice.base.SearchMixin

method), 27search_fields (advanced_reports.defaults.AdvancedReport

attribute), 5search_index() (advanced_reports.backoffice.base.BackOfficeModel

method), 25search_index_dependencies (ad-

vanced_reports.backoffice.base.BackOfficeModelattribute), 25

search_index_dependency_to_dependants (ad-vanced_reports.backoffice.base.ModelMixinattribute), 26

SearchMixin (class in advanced_reports.backoffice.base),26

serialize() (advanced_reports.backoffice.base.BackOfficeModelmethod), 25

serialize() (advanced_reports.backoffice.base.BackOfficeViewmethod), 28

serialize_meta() (advanced_reports.backoffice.base.BackOfficeModelmethod), 25

serialize_model_instance() (ad-vanced_reports.backoffice.base.ModelMixinmethod), 26

serialize_model_instances() (ad-vanced_reports.backoffice.base.ModelMixinmethod), 26

serialize_search_result() (ad-vanced_reports.backoffice.base.SearchMixinmethod), 27

serialize_search_results() (ad-vanced_reports.backoffice.base.SearchMixinmethod), 27

serialize_view_result() (ad-vanced_reports.backoffice.base.BackOfficeViewmethod), 28

set_request() (advanced_reports.defaults.AdvancedReportmethod), 6

show_actions_only_on_hover (ad-vanced_reports.defaults.AdvancedReport

40 Index

Page 45: Release 2.3.0 Jef Geskens, Ingo Berben and contributors

Django Advanced Reports Documentation, Release 2.3.0

attribute), 5show_actions_separator (ad-

vanced_reports.defaults.AdvancedReportattribute), 5

show_in_parent (advanced_reports.backoffice.base.BackOfficeModelattribute), 24

show_row_limit_selection (ad-vanced_reports.defaults.AdvancedReportattribute), 5

show_submit (advanced_reports.defaults.action at-tribute), 10

siblings (advanced_reports.backoffice.base.BackOfficeModelattribute), 24

slug (advanced_reports.backoffice.base.BackOfficeModelattribute), 24

slug (advanced_reports.backoffice.base.BackOfficeTabattribute), 24

slug (advanced_reports.backoffice.base.BackOfficeViewattribute), 27

slug (advanced_reports.defaults.AdvancedReport at-tribute), 3

slug_to_bo_model (ad-vanced_reports.backoffice.base.ModelMixinattribute), 26

slug_to_bo_view (advanced_reports.backoffice.base.ViewMixinattribute), 28

sortable_fields (advanced_reports.defaults.AdvancedReportattribute), 5

submit (advanced_reports.defaults.action attribute), 10success (advanced_reports.defaults.action attribute), 9

Ttabbed_filter_fields (ad-

vanced_reports.defaults.AdvancedReportattribute), 3

tabs (advanced_reports.backoffice.base.BackOfficeModelattribute), 24

template (advanced_reports.backoffice.base.BackOfficeTabattribute), 24

template (advanced_reports.backoffice.base.BackOfficeViewattribute), 27

template (advanced_reports.defaults.AdvancedReport at-tribute), 4

title (advanced_reports.backoffice.base.BackOfficeBaseattribute), 29

title (advanced_reports.backoffice.base.BackOfficeTabattribute), 24

title (advanced_reports.defaults.AdvancedReport at-tribute), 5

Uurlname (advanced_reports.defaults.AdvancedReport at-

tribute), 4

urls (advanced_reports.backoffice.base.BackOfficeBaseattribute), 29

Vvalue_selection_filter_fields (ad-

vanced_reports.defaults.AdvancedReportattribute), 4

verbose_name (advanced_reports.backoffice.base.BackOfficeModelattribute), 24

verbose_name (advanced_reports.defaults.action at-tribute), 9

verbose_name (advanced_reports.defaults.AdvancedReportattribute), 5

verbose_name_plural (ad-vanced_reports.backoffice.base.BackOfficeModelattribute), 24

verbose_name_plural (ad-vanced_reports.defaults.AdvancedReportattribute), 5

verify_action_group() (ad-vanced_reports.defaults.AdvancedReportmethod), 6

ViewMixin (class in advanced_reports.backoffice.base),28

Index 41