disbi.forms module

Forms used throughout the DISBi app.

disbi.forms.construct_direct_select_form(model)[source]

Construct a form for directly selecting model instances.

Parameters:model (models.Model) – A Django model, for which the form is constructed.
disbi.forms.construct_foreign_select_field(model, field)[source]

Construct a form for directly selecting related model instances.

Parameters:
  • model (models.Model) – A Django model, for which the form is constructed.
  • field (fields.related.ForeignKey) – The field of the realated instances.
disbi.forms.construct_forms(experiment_model)[source]

Wrapper for construct_modelfieldsform with appropriate arguments.

disbi.forms.construct_modelfieldsform(model, exclude=['id'], direct_select=False)[source]

Construct forms based on a model and available values in the DB.

Parameters:

model (models.Model) – A Django model, for which the forms are constructed.

Keyword Arguments:
 
  • exclude (iterable) – Fields for which no forms should be constructed.
  • direct_select (bool) – Determines whether a form for directly selecting model instances is constructed.
Returns:

list – A list of namedtuples with the form classes and the prefix.

disbi.forms.foldchange_form_factory(experiments)[source]

Create a form with two fields for selecting experiments.

The fields are select widgets allowing to calculate a fold change between the two.

Parameters:experiments (Queryset) – The selectable experiments.
Returns:Form – The constructed form.
disbi.forms.make_ChoiceField(model, attribute, label=None, empty_choice=None)[source]

Return a ChoiceField and the maxiumn number of choices.

The ChoiceField contains all distinct values of an attribute of model. Addtionally a NULL option is inserted as first choice.

Parameters:
  • model (Model) – The model from which the field should be constructed.
  • attribute (Field) – The attribute of the model.
  • label (str) – The label used when displaying the form (default None).
  • empty_choice (tuple) – 2-tuple of a value label pair, used for enabling the user to choose an empty condition, e.g. no stress.
Returns:

ChoiceField – A Choicefield based on the available options in the DB. int: The number of availablbe options.

Raises:

IndexError – Raises error when no entries are found in the DB.