fairdm.core.forms#
Base form, the manager-only fields mixin, the keyword form and the concept drop-down shared by the core forms.
Module Contents#
Classes#
Leave the fields that decide who gets into a record out of its form, for anyone who cannot manage it. |
|
Model form that accepts the request and drops declared fields missing from |
|
Edit a record’s free keywords: words a person types, with no vocabulary behind them. |
|
Yield a concept field’s choices in the order of the collection it is limited to. |
|
A concept field drawn as a drop-down of the concepts it offers. |
API#
- class ManagerOnlyFieldsMixin#
Leave the fields that decide who gets into a record out of its form, for anyone who cannot manage it.
Visibility and the record a record sits under (a project’s owner, a dataset’s project, a sample’s or measurement’s dataset) change who holds rights over it, so only someone who can manage it is offered them. A form for a new record leaves nothing out.
Attributes: manager_only_fields: The names of the fields to leave out.
- manager_only_fields: tuple[str, ...]#
()
- withhold_manager_only_fields(request)#
Remove the manager-only fields unless the request’s user can manage the record.
Args: request: The current request, or None, which counts as someone who cannot manage it.
- class BaseForm(*args, **kwargs)#
Bases:
django.forms.ModelFormModel form that accepts the request and drops declared fields missing from
Meta.fields.Args: *args: Positional arguments passed to
ModelForm. **kwargs: Keyword arguments passed toModelForm.requestis removed first and setsself.requestandself.user.Initialization
- class KeywordForm(*args, **kwargs)#
Bases:
django.forms.ModelFormEdit a record’s free keywords: words a person types, with no vocabulary behind them.
Keywords chosen from a controlled vocabulary are not offered here and are left as they are when the form is saved.
Args: *args: Passed to
ModelForm. **kwargs: Passed toModelForm. The model is taken frominstancewhen given.Initialization
- save(commit=True)#
Save the free keywords, leaving the record’s vocabulary keywords alone.
- class CollectionOrderIterator(field)#
Bases:
django.forms.models.ModelChoiceIteratorYield a concept field’s choices in the order of the collection it is limited to.
A field with no collection lists its concepts by name.
Initialization
- class ConceptSelectField(*args, model_field=None, **kwargs)#
Bases:
controlled_vocabularies.forms.DeclinesAdminRelatedWrapperMixin,django.forms.ModelChoiceFieldA concept field drawn as a drop-down of the concepts it offers.
For a short, closed list such as the description, date and identifier types, in place of the search box a concept field renders by default. Pass it as the
form_classof aConceptField’s form field. Each concept is shown by its name in the reading language.Args: *args: Passed to
ModelChoiceField. model_field: TheConceptFieldthe form field was built from. **kwargs: Passed toModelChoiceField.Initialization
- iterator#
None
- label_from_instance(obj)#
Return the concept’s name in the reading language.