fairdm.core.measurement.forms#
Forms for creating and editing measurements.
Module Contents#
Classes#
Mixin giving measurement model forms autocomplete fields for dataset and sample, and the location input. |
|
Base form for measurements, which refuses to create a bare |
API#
- class MeasurementFormMixin(*args, **kwargs)#
Bases:
fairdm.utils.location.forms.LocationFormMixin,fairdm.core.forms.ManagerOnlyFieldsMixinMixin giving measurement model forms autocomplete fields for dataset and sample, and the location input.
Use it with the
ModelFormof a concrete measurement type. The dataset choices are limited to the datasets the requesting user may edit. For a measurement that already exists the dataset is offered only to someone who can manage the measurement. The location input is there only when the type’s fields listlocation. See docs/developers/how-to/add-a-measurement-type.md.Args: *args: Positional arguments passed to
ModelForm. **kwargs: Keyword arguments passed toModelForm.requestis removed first and is used to limit the dataset choices.Example: ```python class XRFMeasurementForm(MeasurementFormMixin, forms.ModelForm): class Meta: model = XRFMeasurement fields = [“name”, “dataset”, “sample”, “element”, “concentration_ppm”]
form = XRFMeasurementForm(request=request, data=request.POST) ```
Initialization
- manager_only_fields#
(‘dataset’,)
- class MeasurementForm(*args, **kwargs)#
Bases:
fairdm.core.measurement.forms.MeasurementFormMixin,django.forms.ModelFormBase form for measurements, which refuses to create a bare
Measurement.Measurementis a concrete polymorphic base with its own table, but direct instantiation is refused here and inMeasurement.clean(). Build forms for concrete measurement types onMeasurementFormMixininstead. This class exists for registry auto-generation and as a reference implementation.Initialization
- image#
‘ImageField(…)’
- class Meta#
- model#
None
- fields#
[‘name’, ‘dataset’, ‘sample’, ‘image’, ‘tags’]
- widgets#
None
- help_texts#
None
- clean()#
Refuse to create a bare
Measurement.