fairdm.core.measurement.admin#

Django admin configuration for measurements.

Module Contents#

Classes#

MeasurementDatasetListFilter

A dataset list filter offering every dataset, private ones included.

MeasurementDescriptionInline

Inline admin for measurement descriptions, capped at one row per vocabulary type.

MeasurementDateInline

Inline admin for measurement dates, capped at one row per vocabulary type.

MeasurementIdentifierInline

Inline admin for measurement identifiers, capped at one row per vocabulary type.

MeasurementContributionInline

Inline admin for measurement contributions, uncapped because each row credits a contributor.

MeasurementChildAdmin

Base admin for measurement child models, with inlines for their related records.

MeasurementParentAdmin

Polymorphic parent admin registered for Measurement.

API#

class MeasurementDatasetListFilter(field, request, params, model, model_admin, field_path)#

Bases: django.contrib.admin.RelatedFieldListFilter

A dataset list filter offering every dataset, private ones included.

Dataset’s default manager excludes private datasets and the built-in filter draws its choices from it, so filtering by a private dataset would otherwise be unavailable. The admin needs to see everything, as in DatasetAdmin.get_queryset.

Initialization

field_choices(field, request, model_admin)#

List every dataset as a choice, using all_objects to include private ones.

class MeasurementDescriptionInline(parent_model, admin_site)#

Bases: django.contrib.admin.StackedInline

Inline admin for measurement descriptions, capped at one row per vocabulary type.

Initialization

model#

None

extra#

0

get_max_num(request, obj=None, **kwargs)#

Allow one row for each type the collection offers.

class MeasurementDateInline(parent_model, admin_site)#

Bases: django.contrib.admin.StackedInline

Inline admin for measurement dates, capped at one row per vocabulary type.

Initialization

model#

None

extra#

0

get_max_num(request, obj=None, **kwargs)#

Allow one row for each type the collection offers.

class MeasurementIdentifierInline(parent_model, admin_site)#

Bases: django.contrib.admin.StackedInline

Inline admin for measurement identifiers, capped at one row per vocabulary type.

Initialization

model#

None

extra#

0

get_max_num(request, obj=None, **kwargs)#

Allow one row for each type the collection offers.

class MeasurementContributionInline(parent_model, admin_site)#

Bases: django.contrib.contenttypes.admin.GenericTabularInline

Inline admin for measurement contributions, uncapped because each row credits a contributor.

Initialization

model#

None

extra#

0

ct_field#

‘content_type’

ct_fk_field#

‘object_id’

class MeasurementChildAdmin(model: type[polymorphic.admin.childadmin._ModelT], admin_site: Any, *args: Any, **kwargs: Any)#

Bases: polymorphic.admin.PolymorphicChildModelAdmin

Base admin for measurement child models, with inlines for their related records.

Subclass it for each measurement type and set base_model. Declare base_fieldsets rather than fieldsets so the polymorphic admin can add the subclass’s own fields. See docs/developers/how-to/add-a-measurement-type.md.

Initialization

list_display#

[‘name’, ‘sample’, ‘dataset’, ‘measurement_type’, ‘added’, ‘modified’]

list_filter#

[(‘dataset’,), ‘sample’, ‘added’]

search_fields#

[‘name’, ‘uuid’]

readonly_fields#

[‘uuid’, ‘added’, ‘modified’]

autocomplete_fields#

[‘dataset’, ‘sample’]

inlines#

None

base_fieldsets#

((None,), (‘Metadata’,))

measurement_type(obj)#

Return the verbose name of the measurement’s concrete class.

class MeasurementParentAdmin(model: type[polymorphic.admin.parentadmin._ModelT], admin_site: Any, *args: Any, **kwargs: Any)#

Bases: polymorphic.admin.PolymorphicParentModelAdmin

Polymorphic parent admin registered for Measurement.

It offers the type selection when adding a measurement and routes to the child admin of each registered subclass for editing. See docs/portal-administration/managing-measurements.md.

Initialization

base_model#

None

list_display#

[‘name’, ‘sample’, ‘dataset’, ‘measurement_type’, ‘added’, ‘modified’]

list_filter#

None

search_fields#

[‘name’, ‘uuid’]

measurement_type(obj)#

Return the verbose name of the measurement’s concrete class.

get_child_models()#

Return every registered Measurement subclass.