fairdm.core.sample.forms#
Forms for the Sample app.
Module Contents#
Classes#
Mixin giving sample model forms the dataset field and the location input. |
|
Base form for samples, which refuses to create a bare |
Data#
API#
- logger#
‘getLogger(…)’
- class SampleFormMixin(*args, **kwargs)#
Bases:
fairdm.utils.location.forms.LocationFormMixin,fairdm.core.forms.ManagerOnlyFieldsMixinMixin giving sample model forms the dataset field and the location input.
Use it with the
ModelFormof a concrete sample type. The dataset choices are the datasets the requesting user may edit. For a sample that already exists the dataset is offered only to someone who can manage the sample. A form given no authenticated user offers no dataset at all, which is the safe default, and logs a warning because a create form that can never validate explains nothing on its own. The status defaults tounknown, matching the model default, so a form never asserts where a specimen is when nobody chose.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 RockSampleForm(SampleFormMixin, forms.ModelForm): class Meta: model = RockSample fields = [“name”, “dataset”, “rock_type”]
form = RockSampleForm(request=request, data=request.POST) ```
Initialization
- manager_only_fields#
(‘dataset’,)
- class SampleForm(*args, **kwargs)#
Bases:
fairdm.core.sample.forms.SampleFormMixin,django.forms.ModelFormBase form for samples, which refuses to create a bare
Sample.Build forms for concrete sample types on
SampleFormMixininstead. This class exists for registry auto-generation and as a reference implementation.Initialization
- image#
‘ImageField(…)’
- class Meta#
- model#
None
- fields#
[‘name’, ‘dataset’, ‘local_id’, ‘status’, ‘location’, ‘image’, ‘tags’, ‘related’]
- widgets#
None
- help_texts#
None
- clean()#
Refuse to create a bare
Sample.