Views
More information about views coming soon...
Class Reference
-
class canary.views.BasicReport
Very basic base class that inlcudes the metaclass and sets the default
template_name.
Add additional media to the view.
- Args:
- extra_css: A dictionary with CSS info, such as:
- {
- ‘css/extra_styles.css’: {‘media’: ‘screen, projection’},
‘css/more_styles.css’: None
}
- extra_js: An iterable of iterables with JS info, such as:
- {
- ‘js/extra_scripty_magics.js’: None,
‘js/more_scripters.js’: None
}
- js_context: A dictionary of JSON strings, such as:
- {
- ‘editableURL’: ‘/canary/edit_column/’,
}
The extra data you want to include is then available to your
included JS scripts, from canary.editableURL.
- Sets:
- extra_css: Adds to existing extra_css.
extra_js: Adds to existing extra_js.
js_context: Adds to existing js_context.
Return the dictionary with default parameters set.
- Returns:
- A dictionary, such as:
- {
- ‘css/extra_styles.css’: {‘media’: ‘screen, projection’, ‘type’: ‘text/css’, ‘rel’: ‘stylesheet’},
‘css/more_styles.css’: {‘type’: ‘text/css’, ‘rel’: ‘stylesheet’},
}
Return the dictionary with default parameters set.
- Returns:
- A dictionary, such as:
- {
- ‘js/extra_scripty_magics.js’: {‘type’: ‘text/javascript’},
‘js/more_scripters.js’: {‘type’: ‘text/javascript’}
}
-
class canary.views.QueryReport(*args, **kwargs)
Build a report using a provided queryset, along with column definitions.
-
filter_queryset(request)
Your second chance to affect the queryset, with filters.
You can override this method to change the way filters are handled,
or even just to add a final filter onto your query.
-
get(request, *args, **kwargs)
Handle a GET request.
-
get_app_label()
Return the app label from the queryset.
-
get_model_name()
Return the model name from the queryset.
-
get_post(request, *args, **kwargs)
Handle any request.
-
get_row(obj)
Given the current object from the QuerySet, return a list for the row.
-
get_rows()
Get a list of row lists from the QuerySet.
-
iter_rows()
Iterate over the QuerySet, returning a row list on each iteration.
-
limit_queryset(request)
Limit/paginate the QuerySet.
- Args:
- request: The Django request object.
- Sets:
- _meta.queryset: The Django QuerySet.
-
load_aggregates(request)
Load all aggregates from all columns.
- Args:
- request: The Django request object.
- Sets:
- aggregates: A dictionary of aggregates.
-
load_filters(request)
Load all filters from all columns.
- Args:
- request: The Django request object.
- Sets:
- filters: A dictionary of filters.
order_by: A list of columns, in order of sort preference.
Load all headers. Headers include filters and sorts, so those must
already be loaded.
- Args:
- request: The Django request object.
- Sets:
- headers: A list of ColumnHeader objects.
-
load_queryset(request)
Your first chance to affect the queryset.
- Args:
- request: The Django request object.
- Sets:
- queryset: A Django QuerySet.
- Raises:
- AttributeError: QueryReport.Meta.queryset isn’t defined.
-
load_sort_manager(request)
Create the SortManager.
- Args:
- request: The Django request.
- Sets:
- _meta.sort_manager: SortManager instance.
-
post(request, *args, **kwargs)
Handle a POST request.
-
resolve_text(obj, attr, default=None)
Resolve the given attribute from the given object or the current view.
- Args:
- obj: The object from the QuerySet.
attr: The attribute to resolve.
default: The value to return if the attribute can’t be found.
- Returns:
- The resolved value or default.
-
sort_queryset(request)
Your last chance to affect the queryset.
Expected to apply an order_by to the QuerySet.
TODO: implement multi-column sort.
- Args:
- request: The Django request object.
- Sets:
- _meta.queryset: A Django QuerySet.
-
class canary.views.ModelReport(*args, **kwargs)
An extension of QueryReport that builds a report from a given model.
-
load_columns()
Load columns from the model and create canary columns for each.
- Sets:
- _meta.columns: An OrderedDict of column.
-
load_queryset(request)
Load the QuerySet. First try to load from a given QuerySet
(defined as QuerySet.Meta.queryset). If none was provided, load a
QuerySet of all objects for the model.
- Args:
- request: The Django request object.
- Sets:
- _meta.queryset: A Django QuerySet.