text: from django import forms
  
  from .models import PredefinedConfiguration
  
  
  class ExperimentForm(forms.Form):
      # Required fields
      exp_name = forms.CharField(
          label='Experiment name',
          max_length=255)
      author_email = forms.EmailField(
          label='E-Mail',
          required=False)
      in_file = forms.FileField(
          label='Binary data that will be analysed',
          help_text="The data is deleted after the analysis.",
          required=False,
          allow_empty_file=True)
      cstreams_cfg_file = forms.FileField(
          label='Cryptostreams configuration JSON file',
          help_text=None,
          required=False,
          allow_empty_file=True)
      cstreams_cfg_name = forms.CharField(
          label='Cryptostreams config name',
          required=False)
      cstreams_cfg_json = forms.CharField(
          widget=forms.Textarea,
          required=False)
      rttgen_cfg_file = forms.FileField(
          label='RTT-data-gen configuration JSON file',
          help_text=None,
          required=False,
          allow_empty_file=True)
      rttgen_cfg_name = forms.CharField(
          label='RTT-data-gen config name',
          required=False)
      rttgen_cfg_json = forms.CharField(
          widget=forms.Textarea,
          required=False)
  
      # Configuration fields
      default_cfg = forms.BooleanField(
          label='Use default configuration (recommended)',
          required=False,
          initial=True,
          widget=forms.CheckboxInput(attrs={'onclick': 'confDisable();'}))
      choose_cfg = forms.ModelChoiceField(
          queryset=PredefinedConfiguration.objects.order_by('required_bytes'),
          label='Choose configuration',
          empty_label='----------',
          required=False,
          widget=forms.Select(attrs={'onclick': 'confDisable();'}))
      own_cfg = forms.FileField(
          label='Configuration file (advanced user)',
          required=False,
          help_text="For configuration file description read our "
                    "<a href=https://github.com/"
                    "crocs-muni/randomness-testing-toolkit/wiki/Battery-execution-configuration>wiki</a>.",
          widget=forms.FileInput(attrs={'onchange': 'confDisable();'}))
  
      # Battery fields
      batt_sts = forms.BooleanField(
          label='NIST Statistical Testing Suite',
          required=False)
      batt_die = forms.BooleanField(
          label='Dieharder',
          required=False)
      batt_tu_sc = forms.BooleanField(
          label='TestU01 Small Crush',
          required=False)
      batt_tu_c = forms.BooleanField(
          label='TestU01 Crush',
          required=False)
      batt_tu_bc = forms.BooleanField(
          label='TestU01 Big Crush (requires at least 20GB of data, 60GB for full run)',
          required=False)
      batt_tu_rab = forms.BooleanField(
          label='TestU01 Rabbit',
          required=False)
      batt_tu_ab = forms.BooleanField(
          label='TestU01 Alphabit',
          required=False)
      batt_tu_bab = forms.BooleanField(
          label='TestU01 Block Alphabit',
          required=False)
      batt_bool1 = forms.BooleanField(
          label='BoolTest 1',
          required=False)
      batt_bool2 = forms.BooleanField(
          label='BoolTest 2',
          required=False)
      use_booltest_config = forms.BooleanField(
          label='Use BoolTest config json',
          widget=forms.CheckboxInput(attrs={'onclick': 'checkBoolConfig();'}),
          required=False)
      booltest_json = forms.CharField(
          widget=forms.Textarea,
          label='BoolTest json configuration',
          required=False)
      preserve_form = forms.BooleanField(
          label='Preserve form fields',
          required=False)
  
      def clean(self):
          cleaned_data = super().clean()
          default_cfg = cleaned_data.get("default_cfg")
          choose_cfg = cleaned_data.get("choose_cfg")
          own_cfg = cleaned_data.get("own_cfg")
          sts = cleaned_data.get("batt_sts")
          die = cleaned_data.get("batt_die")
          tu_sc = cleaned_data.get("batt_tu_sc")
          tu_c = cleaned_data.get("batt_tu_c")
          tu_bc = cleaned_data.get("batt_tu_bc")
          tu_rab = cleaned_data.get("batt_tu_rab")
          tu_ab = cleaned_data.get("batt_tu_ab")
          tu_bab = cleaned_data.get("batt_tu_bab")
          bool1 = cleaned_data.get("batt_bool1")
          bool2 = cleaned_data.get("batt_bool2")
  
          errors = []
  
          cfg_settings_sum = 0
          if default_cfg:
              cfg_settings_sum += 1
          if choose_cfg is not None:
              cfg_settings_sum += 1
          if own_cfg is not None:
              cfg_settings_sum += 1
  
          if cfg_settings_sum == 0:
              errors.append("You must specify configuration of the experiment.")
  
          if cfg_settings_sum > 1:
              errors.append("You specified multiple configurations of the experiment.")
  
          if not (sts or die or tu_sc or tu_c or tu_bc or tu_rab or tu_ab or tu_bab or bool1 or bool2):
              errors.append("No battery was set for execution.")
  
          if len(errors) > 0:
              raise forms.ValidationError(errors)
  
          return cleaned_data
  