fairdm.contrib.collections.views#

Tabular listing view for the registered sample and measurement types.

Module Contents#

Classes#

DataTableView

Display the published records of one Sample or Measurement sub-type as a filterable table.

API#

class DataTableView(**kwargs)#

Bases: fairdm.views.FairDMTableView

Display the published records of one Sample or Measurement sub-type as a filterable table.

Attributes: template_name_suffix: Suffix appended to the model name when resolving a template. template_name: The listing template. model_config: The registry configuration for the listed model, set per route by get_urls.

Initialization

template_name_suffix#

‘_table’

template_name#

‘collections/listing.html’

model_config#

None

property toolbar_filters: list[str]#

Draw the search and the status in the toolbar, wherever the filter set has them.

get_filterset_class() → type[django_filters.filterset.FilterSet] | None#

Return the type’s filter set with publication scoping applied last.

get_queryset()#

Limit to published records with related objects loaded, chaining from the parent queryset.

Measurements carry effective_location for the viewer, which the table’s latitude and longitude read.

get_context_data(**kwargs)#

Add the registry, the sample and measurement switcher entries and the page title.

get_listing_entries(models)#

Build the switcher entries for samples or measurements.

Args: models: The registered model classes of one kind.

Returns: One {name, url, is_current} dict per model with a <slug>-list route.

get_table_class()#

Return the table class from the model configuration.

get_table_kwargs()#

Exclude bookkeeping columns and set the empty-state text.

get_empty_state_heading()#

Return an empty-state heading naming the listed type.

get_empty_state_message()#

Return an empty-state message naming the listed type.

classmethod get_urls(**kwargs)#

Build one listing route per registered sample and measurement type.

Args: **kwargs: Extra keyword arguments passed to as_view.

Returns: A (urlpatterns, app_name) pair, with an empty list and no namespace when nothing is registered. Two models that resolve to the same listing address raise ImproperlyConfigured.