Beispiel #1
0
 def render(self, form, form_style, context):
     layout_object = FormActions(
         HTML("""<a role="button" class="btn btn-default mr4" href="{0}">
                 Cancel</a>""".format(self.cancel_href)),
         Submit('save', 'Submit'),
     )
     return layout_object.render(form, form_style, context)
Beispiel #2
0
 def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
     success_url = form.opts.get('success_url', '')
     delete_url = form.opts.get('delete_url', '')
     if delete_url:
         delete_url += '&' if '?' in delete_url else '?'
         delete_url += 'success_url=' + force_text(form.opts.get('delete_success_url', success_url))
     template = get_template(form.opts.get('form_actions_template', 'ajaxviews/_form_controls.html'))
     btn_group = template.render({
         'delete_url': delete_url,
         'success_url': force_text(success_url),
         'modal_form': form.opts.get('modal_form', False),
         'form_preview': form.opts.get('preview_stage', False),
         'delete_confirmation': form.opts.get('delete_confirmation', False),
         'form_cfg': json.dumps(form.form_cfg) if getattr(form, 'form_cfg', None) else None,
     })
     layout_object = FormActions(
         Submit('save', form.opts.get('save_button_name', 'Save')),
         HTML(btn_group),
         style='margin-bottom: 0;'
     )
     return layout_object.render(form, form_style, context)
Beispiel #3
0
 def __init__(self, *args, **kwargs):
     super(BreedDeleteForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper(self)
     self.helper.layout.append(
         FormActions(HTML('{% include "customers/button_delete.html" %}'),HTML('{% include "customers/button_cancel.html" %}')))
Beispiel #4
0
 def __init__(self, *args, **kwargs):
     super(ContactForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout('name', 'email', 'comment',
                                 FormActions(Submit('submit', 'Submit')))
Beispiel #5
0
class IdeationStage(BaseModelForm):
    def __init__(self, *args, **kwargs):
        super(IdeationStage, self).__init__(*args, **kwargs)
        self.fields['name'].label = "Idea name"
        self.fields['description'].label = "Please describe your idea"
        self.fields['sectors'].label = "What sectors do you operate in?"
        self.fields[
            'challenge_to_solve'].label = "What problems/Challenges or needs is your idea trying to solve?"
        self.fields[
            'challenge_faced'].label = "What challenges are you facing?"
        self.fields['other_challenges'].label = ""

    name = forms.CharField(widget=forms.TextInput(attrs={
        'class': "",
        'placeholder': 'name of idea'
    }))
    description = forms.CharField(widget=forms.Textarea())
    idea_stage = forms.CharField(required=False)
    sectors = forms.MultipleChoiceField(
        choices=(
            ('agriculture', "Agriculture"),
            ('manufacturing', "Manufacturing and Assembly"),
            ('financial', "Financial Services"),
            ('renewable', "Renewable Energy"),
            ('information security', "Information Security"),
            ('education', "Education"),
            ('health', "Healthcare & Services"),
            ('infrastructure', "Infrastructure"),
            ('transport', "Transport"),
        ),
        widget=forms.CheckboxSelectMultiple,
    )
    other_sectors = forms.CharField(required=False, max_length=2000)
    challenge_to_solve = forms.CharField(widget=forms.Textarea())
    other_challenges = forms.CharField(widget=forms.Textarea(), required=False)
    challenge_faced = forms.MultipleChoiceField(
        choices=(
            ('mentorship', "Mentorship"),
            ('office space', "Office Space"),
            ('networking', "To network"),
            ('training', "Training on how to run a business"),
            ('technical', "Technical Training"),
            ('team', "To build a team"),
            ('funding', "Funding"),
            ('others', "Others"),
        ),
        widget=forms.CheckboxSelectMultiple,
    )

    helper = FormHelper()
    helper.form_class = 'form-horizontal'
    helper.layout = Layout(
        Field('name', css_class='text-small'),
        Field('description', rows="4", css_class='text-large'),
        Field('sectors', ),
        Field('other_sectors', css_class='text-small'),
        Field('challenge_to_solve', rows="4", css_class='text-large'),
        Field('challenge_faced', css_class=''),
        Field('other_challenges',
              css_class='text-small',
              placeholder="Other Challenges"),
        FormActions(
            Button('cancel', 'Cancel', css_class='cancelBtn'),
            Submit('next', 'Finish', css_class="cancelBtn"),
        ),
    )

    class Meta:
        model = Innovation
        fields = ('name', 'description', 'sectors', 'other_sectors',
                  'challenge_faced', 'challenge_to_solve', 'other_challenges')
Beispiel #6
0
    def __init__(self, *args, **kwargs):
        super(PermisoAusentismoForms, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        # self.helper.form_class = 'form-inline'
        self.helper.field_template = 'bootstrap3/layout/inline_field.html'
        self.helper.form_class = 'form-horizontal'

        self.helper.layout = Layout(
            Div(
                #Div(Field('mes_evento'),css_class='col-md-2'),
                Div(Field('idTrabajador'), css_class='col-md-4'),
                Div(Field('tipo_evento'), css_class='col-md-3'),
                Div(FieldWithButtons(
                    'codigoDiagnostico',
                    StrictButton('...',
                                 css_class='btn btn-info',
                                 data_toggle='modal',
                                 data_target="#myModal")),
                    css_class='col-md-3'),
                css_class='row'),
            Div(
                #Div(Field('periodoIncapacidadInicial'), css_class='col-md-3', ),
                Div(Div(
                    Field('periodoIncapacidadInicial'),
                    css_class='',
                ),
                    css_class='col-sm-2'),
                Div(Div(
                    Field('periodoIncapacidadFinal'),
                    css_class='',
                ),
                    css_class='col-sm-2'),
                # HTML('<p>Date: <input name="fechaIngreso" type="text" id="id_date"></p>'),
                #Div(Field('periodoIncapacidadFinal'), css_class='col-md-3', ),
                Div(
                    Field('prorroga'),
                    css_class='col-sm-1',
                ),
                Div(
                    Field('totalDiasIncapacidad', type="hidden"),
                    css_class='col-sm-1',
                ),
                Div(
                    Field('diasCargados'),
                    css_class='col-sm-2',
                ),
                Div(
                    Field('horaInicial'),
                    css_class='col-sm-2',
                ),
                Div(
                    Field('horaFinal'),
                    css_class='col-sm-2',
                ),
                css_class='row',
                style='',
            ),
            Div(css_class='row', ),
            Field('observaciones'),
            Div(FormActions(
                Submit('save', 'Guardar', css_class='btn-default'),
                HTML(
                    '<a type="button" class="btn btn-danger" href="{% url "listado_permiso_ausentismo" %}" >Cancelar</a>'
                ),
            ),
                style='text-align:right;padding-right:1%;padding-top:1%'),
        )
Beispiel #7
0
    def __init__(self, *args, **kwargs):
        super(PostForm, self).__init__(*args, **kwargs)

        LastVal = NumericTraits.objects.all().order_by(
            '-feature_id').values_list()[0][0] + 1
        self.helper = FormHelper(self)
        self.helper.form_method = 'post'
        self.helper.form_action = 'dbPost'

        self.helper.layout = Layout(
            Div(
                HTML(
                    '<div id="div_id_species" class="control-group"> <label id="specieslab" for="id_species" class="control-label requiredField">\
                Species<span class="asteriskField">*</span> </label> <div class="controls"> <select class="selectpicker show-tick" data-live-search="true" name="species" id="id_species">\
                <option>Select by scientific name</option>{% for x in species %}<option value={{x.species_id_html}}>{{x.species_id}}</option>{% endfor %}</select></div> </div>'
                ),

                #Field('species__genus_species', css_class='selectpicker show-tick', data_live_search="true", name="specSearch", id="specSearch"),
                style='width:50%; display:inline-block;',
            ),
            Div(HTML(
                "<a href='/EntryKey' target='_blank' class='btn btn-warning'><span class='glyphicon glyphicon-list-alt'></span> Data Entry Key </a>"
            ),
                style="float:right;"),
            HTML("<hr />"),
            HTML(
                '<a href="/admin/app/citation/add/" target="_blank" class="btn btn-danger btn-lg"> Add new citation </a>'
            ),
            HTML("<hr />"),
            Fieldset(
                'Add Trait',
                Div(HTML(
                    '<div id="div_id_traits" class="control-group"> <label id="traitlab" for="id_traits" class="control-label requiredField">\
                Numeric Traits<span class="asteriskField">*</span> </label> <div class="controls"> <select class="selectpicker show-tick" name="traits" id="id_traits">\
                <option>Select trait to add</option>{% for x in numtraits %}<option value="{{x.traits}}">{{x.traits}}</option>{% endfor %}</select></div> </div>'
                ),
                    HTML(
                        '<div id="div_id_units" class="control-group"> <label id="unitlab" for="id_units" class="control-label requiredField">\
                Units<span class="asteriskField">*</span> </label> <div class="controls"> <select class="selectpicker show-tick" name="units" id="id_units">\
                <option>Select units</option>{% for x in units %}<option value="{{x.units}}">{{x.units}}</option>{% endfor %}</select></div> </div>'
                    ),
                    HTML(
                        '<div id="div_id_uncertainty" class="control-group"> <label id="uncertaintylab" for="id_uncertainty" class="control-label requiredField">\
                Uncertainty <span class="asteriskField">*</span> </label> <div class="controls"> <select class="selectpicker show-tick" name="uncertainty" id="id_uncertainty">\
                <option>Select uncertainty</option><option value="ex">Exact</option><option value="ca">Approximate</option><option value="+">Greater than</option>\
                <option value="-">Less than</option></select></div> </div>'),
                    css_class='col-md-3 input-md'),
                Div(
                    'mean',
                    HTML('<h4> And/or </h4>'),
                    HTML(
                        ' <div id="div_id_range" class="control-group"> <label for="id_range_0" class="control-label ">Range\
                            </label> <div class="controls"> <input class="numberinput" id="id_range_0" name="range_0" type="number">\
                            <span> Lower</span><input class="numberinput" id="id_range_1" name="range_1" type="number"><span>  Upper</span> </div> </div>'
                    ),
                    css_class='col-md-3 input-md',
                ),
                Div(HTML(
                    '<div id="div_id_citation" class="control-group"> <label id="citationlab" for="id_citation" class="control-label requiredField">\
                Citation <span class="asteriskField">*</span> </label> <div class="controls"> <select class="selectpicker show-tick" data-live-search="true" name="citation" id="id_citation">\
                <option>Select citation</option>{% for x in citations %}<option value="{{x.citation_name}}">{{x.citation_name}}</option>{% endfor %}</select></div> </div>'
                ),
                    HTML('<div class="col-md-12"><br /></div>'),
                    'study_year',
                    'study_location',
                    css_class='col-md-3 input-md'),
                Div('comments', css_class='col-md-3 input-md'),
                HTML('<div class="col-md-5"><br /></div>'),
            ),
            HTML("<br />"),
            Fieldset(
                'Save the data',
                HTML(
                    '<div id="div_id_feature_id" style="display:none" class="col-md-3 control-group"> <label for="id_feature_id" class="control-label requiredField">\
                Feature id<span class="asteriskField">*</span> </label> <div class="controls"> <input readonly class="numberinput" id="id_feature_id" name="feature_id" type="number" value="'
                    + str(LastVal) + '"> </div> </div>'),
                HTML(
                    '<div id="div_id_username" style="display:none" class="col-md-3 control-group"> <label for="id_username" class="control-label requiredField">\
                Username<span class="asteriskField">*</span> </label> <div class="controls"> <input readonly class="textinput textInput" id="id_username" maxlength="30" name="username" type="text" value={{user.username}}> </div> </div>'
                ),
                HTML(
                    '<div id="div_id_dt" style="display:none" class="col-md-3 control-group"> <label for="id_dt" class="control-label requiredField">\
                Dt<span class="asteriskField">*</span> </label> <div class="controls"> <input readonly class="textinput textInput" id="id_dt" maxlength="30" name="dt" type="text" value={{day}}/{{month}}/{{year}}> </div> </div>'
                ),
                Div(FormActions(
                    Submit('dbPost',
                           'Save data',
                           css_class='btn btn-success',
                           action=".")),
                    css_class='col-md-3'),
                HTML('<div class="col-md-3" id="savesuccess"></div>')),
        )
Beispiel #8
0
    def __init__(self, *args, **kwargs):
        call = kwargs.pop('call', None)
        super().__init__(*args, **kwargs)

        self.helper = FormHelper(self)

        if self.instance.id:
            self.helper.form_action = reverse('logged-call-evaluation-update', kwargs={'pk': self.instance.id})
            self.fields['call'].initial = call = self.instance.call
        else:
            self.helper.form_action = reverse('logged-call-evaluation-add') + f'?call={call.id}'
            self.fields['call'].initial = call

        XDSoftYearMonthDayPickerInput.set_format_to_field(self.fields['panel_date'])

        if hasattr(call, 'callevaluation'):
            cancel_edit_url = reverse('logged-call-evaluation-detail', kwargs={'pk': call.callevaluation.id})
            initial_reviewers = call.reviewer_set.all()
        else:
            cancel_edit_url = reverse('logged-call-evaluation-add') + f'?call={call.id}'
            initial_reviewers = []

        self.fields['reviewers'] = ReviewerMultipleChoiceField(initial=initial_reviewers,
                                                               queryset=Reviewer.objects.all(),
                                                               required=True,
                                                               widget=FilteredSelectMultiple(
                                                                   is_stacked=True,
                                                                   verbose_name='reviewers'),
                                                               help_text=self.Meta.help_texts['reviewers'])

        criterion_choices, criterion_initial = CheckboxSelectMultipleSortable.get_choices_initial(
            CriterionCallEvaluation,
            self.instance, 'call_evaluation',
            Criterion, 'criterion',
            label_from_instance=lambda obj: format_html('{} <small>({})</small>', obj.name, obj.description)
        )

        self.fields['criteria'] = forms.MultipleChoiceField(choices=criterion_choices,
                                                            initial=criterion_initial,
                                                            widget=CheckboxSelectMultipleSortable,
                                                            label='Criteria (drag and drop to order them)',
                                                            help_text='These criteria are used in the Excel Evaluation sheet'
                                                            )

        self.criteria_order_key = f'criteria-{CheckboxSelectMultipleSortable.order_of_values_name}'

        self.helper.layout = Layout(
            Div(
                Div('call', css_class='col-12', hidden=True),
                css_class='row'
            ),
            Div(
                Div('reviewers', css_class='col-12'),
                css_class='row'
            ),
            Div(
                Div('panel_date', css_class='col-12'),
                css_class='row'
            ),
            Div(
                Div('criteria', css_class='col-12'),
                css_class='row'
            ),
            Div(
                Div('post_panel_management_table', css_class='col-12'),
                css_class='row'
            ),
            FormActions(
                Submit('save', 'Save Call Evaluation'),
                cancel_edit_button(cancel_edit_url)
            )
        )
Beispiel #9
0
    def __init__(self, *args, **kwargs):

        # extract arguments for shape of form

        self.stim = kwargs.pop('stim')
        self.cons = kwargs.pop('cons')
        self.structure = kwargs.pop('structure')
        self.classes = kwargs.pop('classes')

        # add helper for layout of form

        self.helper = FormHelper()
        self.helper.form_method = 'POST'
        self.helper.field_class = 'col-lg-12'
        self.helper.label_class = 'col-lg-12'
        self.helper.layout = Layout(Fieldset("Contrasts and probabilities"))

        # define iterable fields and compute width of each box
        if self.stim < 6:
            cssclass = "col-xs-" + str(int(np.floor(12 / self.stim)))
        else:
            cssclass = "col-xs-" + str(int(np.floor(12 / 5)))

        fields = [[
            'C00', 'C01', 'C02', 'C03', 'C04', 'C05', 'C06', 'C07', 'C08',
            'C09'
        ],
                  [
                      'C10', 'C11', 'C12', 'C13', 'C14', 'C15', 'C16', 'C17',
                      'C18', 'C19'
                  ],
                  [
                      'C20', 'C21', 'C22', 'C23', 'C24', 'C25', 'C26', 'C27',
                      'C28', 'C29'
                  ],
                  [
                      'C30', 'C31', 'C32', 'C33', 'C34', 'C35', 'C36', 'C37',
                      'C38', 'C39'
                  ],
                  [
                      'C40', 'C41', 'C42', 'C43', 'C44', 'C45', 'C46', 'C47',
                      'C48', 'C49'
                  ]]
        fieldsPG = [
            'PG0', 'PG1', 'PG2', 'PG3', 'PG4', 'PG5', 'PG6', 'PG7', 'PG8',
            'PG9'
        ]
        fieldsP = ['P0', 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9']

        # add layout: probabilities

        self.helper.layout.append(
            Div(Field('G', type='hidden'),
                Field('I', type='hidden'),
                css_class=cssclass))

        self.helper.layout.append(
            Div(Field("conpars", type='hidden'), css_class=cssclass))

        self.helper.layout.append(
            HTML(
                '<h5> What are the probabilities (or relative frequencies) for each stimulus type? </h5><p>The probabilities for each stimulus should be specified within each class of stimuli.  Ideally, the probabilities sum to 1 within each class (or the should be relative to each other within the class).<p><br>'
            ))

        for indl in xrange(10):  # loop over lines (contrasts)

            # titles
            if indl > 0 and indl < len(self.structure):
                self.helper.layout.append(HTML("<br><br><br><br>"))
            # self.helper.layout.append(
            #     HTML('<h6> Probability for class %s (C%s)</h6>'%(indl+1,indl+1))
            #     )
            self.helper.layout.append(
                Div(Field(
                    fieldsPG[indl],
                    type='hidden' if indl >= len(self.structure) else None),
                    css_class="col-sm-5"))

            # fields
            if indl < len(self.structure):
                for indf, field in enumerate(
                        self.structure[indl]):  # loop over fields (stimuli)
                    self.helper.layout.append(
                        Div(Field(field), css_class="col-sm-3"))

        Pflat = [item for sublist in self.structure for item in sublist]
        Pnot = [val for val in fieldsP if not val in Pflat]
        for field in Pnot:
            self.helper.layout.append(
                Div(Field(field, type='hidden'), css_class="col-xs-1"))

        for ind in xrange(len(self.structure)):
            self.helper.layout.append(HTML("<br><br>"))

        # hard limit
        self.helper.layout.append(
            HTML(
                '<h5> Do you want a hard limit on those probabilities? </h5><br><p>Check if you want to preserve the probabilities exactly.  This largely restricts the possibilities to search over, so the optimisation will take (a lot) longer.</p>'
            ))

        self.helper.layout.append(
            Div(Div(Field('HardProb'), css_class='col-lg-3 col-sm-12'),
                css_class='row-md-12 col-xs-12'))

        # add layout: contrasts

        if self.cons > 0:
            self.helper.layout.append(HTML('<br><br><br><br><br>'))
            self.helper.layout.append(
                HTML(
                    '''<h5> What are the specific contrasts that will be tested? </h5><br>
                <p>If the contrast sums to 0, you will model the difference between stimuli.  Examples with 3 stimulus types:</p>
                <ul>
                <li>The contrast [1 0 -1] will model the difference between stimulus type 1 and stimulus type 3.</li>
                <li>The contrast [1 -0.5 -0.5] will model the difference between stimulus type 1 and the average of stimulus type 2 and 3.</li>
                </ul>
                <p>If the contrast sums to 1, you will model the main effect of a certain stimulus.  Examples with 3 stimulus types:</p>
                <ul>
                <li>The contrast [1 0 0] will model the main effect of stimulus type 1 (vs. baseline). </li>
                <li>The contrast [0.33,0.33,0.33] will model the average effect of all stimulus types versus baseline.  (don't worry that they don't exactly sum to 1, this will be rescaled)</li>
                </ul><br><br><br>
                '''))

        for indl, line in enumerate(fields):  # loop over lines (contrasts)

            # titles
            if indl < self.cons:
                if indl > 0:
                    self.helper.layout.append(HTML("<br><br><br><br>"))
                self.helper.layout.append(
                    HTML('<h6> Contrast %s </h6>' % (indl + 1)))

            # fields
            for indf, field in enumerate(
                    fields[indl]):  # loop over fields (stimuli)
                self.helper.layout.append(
                    Div(Field(field,
                              type='hidden' if indf >= self.stim
                              or indl >= self.cons else None),
                        css_class=cssclass))

        # finalise layout: submit FormActions

        self.helper.layout.append(HTML("<br><br><br><br>"))
        self.helper.layout.append(
            FormActions(
                Submit('Submit', 'Save and next', css_class='btn-secondary')))

        # initiate the form

        super(DesignNestedConsForm, self).__init__(*args, **kwargs)

        # only labels for the fields from the probabilities

        s = 0
        for ind, field in enumerate(self.fields.keys()):
            s = s + 1
            snew = "Class " + str(int(self.classes[s - 1])) + " - Stim " + str(
                s) if s < (len(self.classes) + 1) else ""
            self.fields[field].label = snew

        s = 0
        for ind in np.arange(10, 20):
            s = s + 1
            snew = "Class " + str(int(s)) + " probabilities" if s < (
                len(self.classes) + 1) else ""
            self.fields[self.fields.keys()[ind]].label = snew

        s = 0
        for ind in np.arange(20, 30):
            s = s + 1
            snew = "C" + str(int(self.classes[s - 1])) + " - S" + str(
                s) if s < (len(self.classes) + 1) else ""
            self.fields[self.fields.keys()[ind]].label = snew
Beispiel #10
0
 def __init__(self, *args, **kwargs):
     super(ConditionReportForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_id = 'ConditionReportForm'
     self.helper.form_class = 'form-horizontal'
     #self.helper.field_template = 'bootstrap3/layout/inline_field_custom.html'
     #		self.helper.label_class = 'col-lg-3'
     self.helper.field_class = 'col-lg-8'
     self.helper.label_class = 'col-lg-2'
     self.helper.layout = Layout(
         Fieldset('Property Condition Report', 'Property'),
         Fieldset(
             'Property Picture',
             Div('picture'),
         ),
         Fieldset(
             'Roof',
             Div('roof_shingles', 'roof_shingles_notes'),
             Div('roof_framing', 'roof_framing_notes'),
             Div('roof_gutters', 'roof_gutters_notes'),
         ),
         Fieldset(
             'Foundation',
             Div('foundation_slab', 'foundation_slab_notes'),
             Div('foundation_crawl', 'foundation_crawl_notes'),
         ),
         Fieldset(
             'Exterior Siding',
             Div('exterior_siding_brick', 'exterior_siding_brick_notes'),
             Div('exterior_siding_vinyl', 'exterior_siding_vinyl_notes'),
             Div('exterior_siding_wood', 'exterior_siding_wood_notes'),
             Div('exterior_siding_other', 'exterior_siding_other_notes'),
         ),
         Fieldset(
             'Miscellaneous',
             Div('windows', 'windows_notes'),
             Div('garage', 'garage_notes'),
             Div('fencing', 'fencing_notes'),
             Div('landscaping', 'landscaping_notes'),
             Div('doors', 'doors_notes'),
             Div('kitchen_cabinets', 'kitchen_cabinets_notes'),
         ),
         Fieldset(
             'Flooring',
             Div('flooring_subflooring', 'flooring_subflooring_notes'),
             Div('flooring_covering', 'flooring_covering_notes'),
         ),
         Fieldset(
             'Electrical',
             Div('electrical_knob_tube_cloth',
                 'electrical_knob_tube_cloth_notes'),
             Div('electrical_standard', 'electrical_standard_notes'),
         ),
         Fieldset(
             'Plumbing',
             Div('plumbing_metal', 'plumbing_metal_notes'),
             Div('plumbing_plastic', 'plumbing_plastic_notes'),
         ),
         Fieldset(
             'Walls',
             Div('walls_drywall', 'walls_drywall_notes'),
             Div('walls_lathe_plaster', 'walls_lathe_plaster_notes'),
         ),
         Fieldset(
             'HVAC',
             Div('hvac_furance', 'hvac_furance_notes'),
             Div('hvac_duct_work', 'hvac_duct_work_notes'),
             Div('hvac_air_conditioner', 'hvac_air_conditioner_notes'),
         ),
         FormActions(Button('cancel', 'Cancel'),
                     Submit('save', 'Save changes')))
     self.helper.form_method = 'post'
     self.helper.form_action = ''
Beispiel #11
0
    def __init__(self, *args, **kwargs):
        """Inicialización del formulario."""
        super().__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs['autocomplete'] = 'off'

        if 'data' in kwargs.keys():
            if 'provincia' in kwargs['data'].keys():
                provincia = kwargs['data'].get('provincia', None)
                if provincia:
                    self.fields['distrito'].queryset = Distrito.objects.filter(
                        provincia=provincia)

            if 'distrito' in kwargs['data'].keys():
                distrito = kwargs['data'].get('distrito', None)
                if distrito:
                    self.fields[
                        'localidad'].queryset = Localidad.objects.filter(
                            distrito=distrito)
        else:
            if self.instance and self.instance.provincia:
                self.fields['distrito'].queryset = Distrito.objects.filter(
                    provincia=self.instance.provincia)
            else:
                self.fields['distrito'].queryset = Distrito.objects.none()

            if self.instance and self.instance.distrito:
                self.fields['localidad'].queryset = Localidad.objects.filter(
                    distrito=self.instance.distrito)
            else:
                self.fields['localidad'].queryset = Localidad.objects.none()

        self.helper = FormHelper()
        self.helper.layout = Layout(
            Fieldset(
                'Datos generales',
                Div(Div('razon_social', css_class='col-8'),
                    Div('cuit', css_class='col-4'),
                    css_class='row'),
                Div(Div('correo', css_class='col-6'),
                    Div('telefono', css_class='col-6'),
                    css_class='row'),
                HTML("""<legend>Dirección</legend>"""),
                Div(
                    Div('calle', css_class='col-6'),
                    Div('numero', css_class='col-2'),
                    Div('piso', css_class='col-2'),
                    Div('dpto', css_class='col-2'),
                    css_class='row',
                ),
                Div(
                    Div('provincia', css_class='col-4'),
                    Div('distrito', css_class='col-4'),
                    Div('localidad', css_class='col-4'),
                    css_class='row',
                ),
                HTML("""<legend>Pagos</legend>"""),
                Div(Div('cbu', css_class='col-6'), css_class='row'),
            ),
            FormActions(Submit('submit', 'Guardar', css_class='float-right'),
                        Reset('reset', 'Limpiar', css_class='float-right')),
        )
Beispiel #12
0
 def __init__(self, *args, **kwargs):
     super(EditProfileForm, self).__init__(*args, **kwargs)
     self.fields['langlevel'] = forms.ChoiceField(
         choices=((str(x), x) for x in range(1, 101)))
     self.fields['langlevel'].label = '2° Language Level'
     self.fields['feecode'].empty_label = 'Neutral mood'
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Div(
             Field('cliname', css_class='form-control'),
             Field('gencode', css_class='form-control'),
             Field('feecode', css_class='form-control'),
             Field('clidescription', css_class='form-control'),
             css_class='edit-details',
         ),
         Div(
             Field('marcode', css_class='form-control'),
             Field('clibirthdate', css_class='form-control'),
             Field('citcode', css_class='form-control'),
             Field('ethcode', css_class='form-control'),
             Field('educode', css_class='form-control'),
             css_class='column-edit',
         ),
         Div(
             Field('lancodefirst', css_class='form-control'),
             Field('lancodesecond', css_class='form-control'),
             Field('langlevel', css_class='form-control'),
             HTML('<label class="lblpercent">%</label>'),
             Field('ocucode', css_class='form-control'),
             HTML('<label class="lblpercent">$</label>'),
             Field('inccode', css_class='form-control'),
             HTML('<label class="lblpercent">USD</label>'),
             css_class='col-md-6 col-xs-12 column-edit',
         ),
         Div(
             HTML('<span class="title">Physical description</span><hr >'),
             css_class='separator',
         ),
         Div(
             Field('bodycode', css_class='form-control'),
             Field('heicode', css_class='form-control'),
             Field('weicode', css_class='form-control'),
             css_class='column-edit',
         ),
         Div(
             Field('eyecode', css_class='form-control'),
             Field('haicode', css_class='form-control'),
             Field('hlecode', css_class='form-control'),
             css_class='column-edit',
         ),
         Div(
             HTML('<span class="title">Other</span><hr >'),
             css_class='separator',
         ),
         Div(
             Field('frecodedrink', css_class='form-control'),
             Field('frecodesmoke', css_class='form-control'),
             Field('zodcode', css_class='form-control'),
             css_class='column-edit',
         ),
         Div(
             Field('relcode', css_class='form-control'),
             Field('chicode', css_class='form-control'),
             css_class='column-edit',
         ),
         FormActions(
             Submit('submit', 'SAVE',
                    css_class='btn-primary form-control')),
     )
Beispiel #13
0
    def __init__(self, *args, **kwargs):
        if 'domain' not in kwargs:
            raise Exception("Expected domain in kwargs")
        self.domain = kwargs.pop('domain')
        self.enhancements_enabled = AUTO_CASE_UPDATE_ENHANCEMENTS.enabled(
            self.domain)
        super(AddAutomaticCaseUpdateRuleForm, self).__init__(*args, **kwargs)

        if not self.enhancements_enabled:
            # Always set the value of filter_on_server_modified to true when the
            # enhancement toggle is not set
            self.data = self.data.copy()
            self.initial['filter_on_server_modified'] = 'true'
            self.data['filter_on_server_modified'] = 'true'

        # We can't set these fields to be required because they are displayed
        # conditionally and we'll confuse django validation if we make them
        # required. However, we should show the asterisk for consistency, since
        # when they are displayed they are required.
        self.fields['update_property_name'].label = _(
            "Property") + '<span class="asteriskField">*</span>'
        self.fields['update_property_value'].label = _(
            "Value") + '<span class="asteriskField">*</span>'
        self.helper = FormHelper()
        self.helper.form_class = 'form form-horizontal'
        self.helper.label_class = 'col-sm-3 col-md-2'
        self.helper.field_class = 'col-sm-4 col-md-3'
        self.helper.form_method = 'POST'
        self.helper.form_action = '#'

        if self.enhancements_enabled:
            self.allow_updates_without_closing()

        _update_property_fields = [
            _f for _f in [
                Field(
                    'update_property_name',
                    ng_model='update_property_name',
                    css_class='case-property-typeahead',
                ),
                Field(
                    'property_value_type',
                    ng_model='property_value_type',
                ) if self.enhancements_enabled else None,
                Field(
                    'update_property_value',
                    ng_model='update_property_value',
                )
            ] if _f
        ]

        _basic_info_fields = [
            _f for _f in [
                Field(
                    'name',
                    ng_model='name',
                ),
                Field(
                    'case_type',
                    ng_model='case_type',
                ),
                Field(
                    'filter_on_server_modified',
                    ng_model='filter_on_server_modified',
                ) if self.enhancements_enabled else None,
                hqcrispy.B3MultiField(
                    _("Close Case") + '<span class="asteriskField">*</span>',
                    Div(
                        hqcrispy.MultiInlineField(
                            'server_modified_boundary',
                            ng_model='server_modified_boundary',
                        ),
                        css_class='col-sm-6',
                    ),
                    Div(
                        HTML('<label class="control-label">%s</label>' %
                             _('days after the case was last modified.')),
                        css_class='col-sm-6',
                    ),
                    help_bubble_text=_(
                        "This will close the case if it has been "
                        "more than the chosen number of days since "
                        "the case was last modified. Cases are "
                        "checked against this rule weekly."),
                    css_id='server_modified_boundary_multifield',
                    label_class=self.helper.label_class,
                    field_class='col-sm-8 col-md-6',
                    ng_show='showServerModifiedBoundaryField()',
                ),
                Field(
                    'action',
                    ng_model='action',
                ),
                Div(*_update_property_fields, ng_show='showUpdateProperty()')
            ] if _f
        ]

        self.set_case_type_choices(self.initial.get('case_type'))
        self.helper.layout = Layout(
            Fieldset(_("Basic Information"), *_basic_info_fields),
            Fieldset(
                _("Filter Cases to Close (Optional)"),
                Field(
                    'conditions',
                    type='hidden',
                    ng_value='conditions',
                ),
                Div(ng_include='', src="'conditions.tpl'"),
            ),
            FormActions(
                StrictButton(
                    _("Save"),
                    type='submit',
                    css_class='btn btn-primary col-sm-offset-1',
                ), ),
        )
Beispiel #14
0
    def __init__(self, data=None, *args, **kwargs):
        super().__init__(data=data, *args, **kwargs)

        self.no_mail = data is not None and 'no_mail' in data

        self.fields['gender'].help_text = _(
            "La participation aux tirages au sort étant paritaire, merci d'indiquer"
            " votre genre si vous souhaitez être tirés au sort.")

        emails = self.instance.emails.all()
        self.several_mails = len(emails) > 1

        fields = []

        block_template = """
            <label class="control-label">{label}</label>
            <div class="controls">
              <div>{value}</div>
              <p class="help-block">{help_text}</p>
            </div>
        """

        email_management_link = HTML(
            block_template.format(
                label=_("Gérez vos adresses emails"),
                value=format_html(
                    '<a href="{}" class="btn btn-default">{}</a>',
                    reverse('email_management'),
                    _("Accéder au formulaire de gestion de vos emails"),
                ),
                help_text=
                _("Ce formulaire vous permet d'ajouter de nouvelles adresses ou de supprimer les existantes"
                  ),
            ))

        email_fieldset_name = _("Mes adresses emails")
        email_label = _("Email de contact")
        email_help_text = _(
            "L'adresse que nous utilisons pour vous envoyer les lettres d'informations et les notifications."
        )

        if self.several_mails:
            self.fields['primary_email'] = forms.ModelChoiceField(
                queryset=emails,
                required=True,
                label=email_label,
                initial=emails[0],
                help_text=email_help_text,
            )
            fields.append(
                Fieldset(
                    email_fieldset_name,
                    Row(HalfCol('primary_email'),
                        HalfCol(email_management_link))))
        else:
            fields.append(
                Fieldset(
                    email_fieldset_name,
                    Row(
                        HalfCol(
                            HTML(
                                block_template.format(
                                    label=email_label,
                                    value=emails[0].address,
                                    help_text=email_help_text))),
                        HalfCol(email_management_link))))

        fields.extend([
            Fieldset(
                _("Préférences d'emails"),
                'subscribed',
                'group_notifications',
                'event_notifications',
            ),
            Fieldset(_("Ma participation"),
                     Row(
                         HalfCol('draw_participation'),
                         HalfCol('gender'),
                     )),
            FormActions(
                Submit('submit', 'Sauvegarder mes préférences'),
                Submit('no_mail',
                       'Ne plus recevoir de mails du tout',
                       css_class='btn-danger'))
        ])

        self.helper = FormHelper()
        self.helper.form_method = 'POST'
        self.helper.layout = Layout(*fields)
Beispiel #15
0
    def __init__(self, *args, **kwargs):
        user = kwargs.pop("user")
        super(TimeReportForm, self).__init__(*args, **kwargs)

        # Make the Year and Semester fields not required (they will be handled later)
        self.fields["year"].required = False
        self.fields["term"].required = False

        # restrict the dropdown lists to actual teachers
        teachers = Group.objects.get(name="teachers").user_set.all()
        self.fields["master_thesis_teacher_in_charge"].queryset = teachers
        self.fields["semester_project_teacher_in_charge"].queryset = teachers
        self.fields["other_job_teacher_in_charge"].queryset = teachers

        # Restrict the list of users to the currently logged in user to improve performances
        self.fields["created_by"].queryset = Person.objects.filter(id=user.id).all()

        # Restrict the list of courses to the Hired applications
        courses_keys = (
            Applications.objects.filter(applicant=user, status="Hired")
            .values_list("course", flat=True)
            .distinct()
        )
        courses = Course.objects.filter(id__in=courses_keys).all()
        self.fields["class_teaching_course"].queryset = courses

        # Layout of the form
        self.helper = FormHelper()
        self.helper.layout = Layout(
            TabHolder(
                Tab(
                    "Common",
                    HTML(
                        """
                    <div class="alert alert-info" role="alert">
                    You should enter a year (under the form of <strong>2 consecutive years - e.g. 2019-2020</strong>), select a term and select an activity type. Based on the activity type you selected, a new tab will be open with further information to provide.
                    </div>
                    """
                    ),
                    Field("created_at", type="hidden"),
                    Field("created_by", type="hidden"),
                    Row(
                        Column(
                            Field("year", data_tab="Common", data_required="true"),
                            css_class="form-group col-md-6 mb-0",
                        ),
                        Column(
                            Field("term", data_tab="Common", data_required="true"),
                            css_class="form-group col-md-6 mb-0",
                            data_tab="Common",
                            data_required="true",
                        ),
                        css_class="form-row",
                    ),
                    Field("activity_type"),
                ),
                Tab(
                    "Class teaching",
                    Field(
                        "class_teaching_course",
                        data_tab="Class teaching",
                        data_required="true",
                        data_autocomplete="true",
                        data_autocomplete_source=reverse("web:autocomplete_my_courses"),
                    ),
                    Row(
                        Column(
                            AppendedText(
                                "class_teaching_preparation_hours",
                                "Hr",
                                active=True,
                                data_tab="Class teaching",
                                data_required="false",
                            ),
                            css_class="form-group col-md-4 mb-0",
                        ),
                        Column(
                            AppendedText(
                                "class_teaching_teaching_hours",
                                "Hr",
                                active=True,
                                data_tab="Class teaching",
                                data_required="false",
                            ),
                            css_class="form-group col-md-4 mb-0",
                        ),
                        css_class="form-row",
                    ),
                    Row(
                        Column(
                            AppendedText(
                                "class_teaching_practical_work_hours",
                                "Hr",
                                active=True,
                                data_tab="Class teaching",
                                data_required="false",
                            ),
                            css_class="form-group col-md-4 mb-0",
                        ),
                        Column(
                            AppendedText(
                                "class_teaching_exam_hours",
                                "Hr",
                                active=True,
                                data_tab="Class teaching",
                                data_required="false",
                            ),
                            css_class="form-group col-md-4 mb-0",
                        ),
                        css_class="form-row",
                    ),
                ),
                Tab(
                    "Master thesis",
                    Field(
                        "master_thesis_title",
                        data_tab="Master thesis",
                        data_required="true",
                    ),
                    Field(
                        "master_thesis_student_name",
                        data_tab="Master thesis",
                        data_required="true",
                        data_autocomplete="true",
                        data_autocomplete_source=reverse(
                            "web:autocomplete_all_students"
                        ),
                    ),
                    Field(
                        "master_thesis_teacher_in_charge",
                        data_tab="Master thesis",
                        data_required="true",
                        data_autocomplete="true",
                        data_autocomplete_source=reverse(
                            "web:autocomplete_all_teachers"
                        ),
                    ),
                    AppendedText(
                        "master_thesis_supervision_hours",
                        "Hr",
                        active=True,
                        data_tab="Master thesis",
                        data_required="true",
                    ),
                    Field(
                        "master_thesis_comments",
                        data_tab="Master thesis",
                        data_required="false",
                    ),
                ),
                Tab(
                    "Semester project",
                    Field(
                        "semester_project_thesis_title",
                        data_tab="Semester project",
                        data_required="true",
                    ),
                    Field(
                        "semester_project_student_name",
                        data_tab="Semester project",
                        data_required="true",
                        data_autocomplete="true",
                        data_autocomplete_source=reverse(
                            "web:autocomplete_all_students"
                        ),
                    ),
                    Field(
                        "semester_project_teacher_in_charge",
                        data_tab="Semester project",
                        data_required="true",
                        data_autocomplete="true",
                        data_autocomplete_source=reverse(
                            "web:autocomplete_all_teachers"
                        ),
                    ),
                    AppendedText(
                        "semester_project_supervision_hours",
                        "Hr",
                        active=True,
                        data_tab="Semester project",
                        data_required="true",
                    ),
                    Field(
                        "semester_project_comments",
                        data_tab="Semester project",
                        data_required="false",
                    ),
                ),
                Tab(
                    "Other job",
                    Field("other_job_name", data_tab="Other job", data_required="true"),
                    Field(
                        "other_job_unit",
                        data_tab="Other job",
                        data_required="true",
                        data_autocomplete="true",
                        data_autocomplete_source=reverse("web:autocomplete_all_units"),
                    ),
                    Field(
                        "other_job_teacher_in_charge",
                        data_tab="Other job",
                        data_required="true",
                        data_autocomplete="true",
                        data_autocomplete_source=reverse(
                            "web:autocomplete_all_teachers"
                        ),
                    ),
                    AppendedText(
                        "other_job_hours",
                        "Hr",
                        active=True,
                        data_tab="Other job",
                        data_required="true",
                    ),
                    Field(
                        "other_job_comments",
                        data_tab="Other job",
                        data_required="false",
                    ),
                ),
                Tab(
                    "Nothing to report",
                    Field(
                        "nothing_to_report_comments",
                        data_tab="Nothing to report",
                        data_required="true",
                    ),
                ),
                Tab(
                    "Not available",
                    Field(
                        "not_available_comments",
                        data_tab="Not available",
                        data_required="true",
                    ),
                ),
                Tab(
                    "MAN",
                    AppendedText(
                        "MAN_hours",
                        "Hr",
                        active=True,
                        data_tab="MAN",
                        data_required="true",
                    ),
                    Field("MAN_comments", data_tab="MAN", data_required="false"),
                ),
                Tab(
                    "Exam proctoring and grading",
                    Field(
                        "exam_proctoring_and_grading_course",
                        data_tab="exam proctoring and grading",
                        data_required="true",
                        data_use_select2="true",
                    ),
                    AppendedText(
                        "exam_proctoring_and_grading_hours",
                        "Hr",
                        active=True,
                        data_tab="exam proctoring and grading",
                        data_required="true",
                    ),
                    Field(
                        "exam_proctoring_and_grading_comments",
                        data_tab="exam proctoring and grading",
                        data_required="false",
                    ),
                ),
            ),
            FormActions(
                Submit("submit", "Submit"),
                Button("cancel", "Cancel"),
                Reset("reset", "Reset"),
            ),
        )
Beispiel #16
0
 def __init__(self, *args, **kwargs):
     super(TargetedSMSForm, self).__init__(*args, **kwargs)
     self.helper.layout = Layout(Field('user'), Field('message'),
                                 FormActions(Submit('save', 'Send')))
Beispiel #17
0
    def __init__(self, *args, **kwargs):

        # extract arguments for shape of form

        self.stim = kwargs.pop('stim')
        self.cons = kwargs.pop('cons')

        # add helper for layout of form

        self.helper = FormHelper()
        self.helper.form_method = 'POST'
        self.helper.field_class = 'col-lg-12'
        self.helper.label_class = 'col-lg-12'
        self.helper.layout = Layout(Fieldset("Contrasts and probabilities"))

        # define iterable fields and compute width of each box
        if self.stim < 6:
            cssclass = "col-xs-" + str(int(np.floor(12 / self.stim)))
        else:
            cssclass = "col-xs-" + str(int(np.floor(12 * 2 / (self.stim))))

        fields = [[
            'C00', 'C01', 'C02', 'C03', 'C04', 'C05', 'C06', 'C07', 'C08',
            'C09'
        ],
                  [
                      'C10', 'C11', 'C12', 'C13', 'C14', 'C15', 'C16', 'C17',
                      'C18', 'C19'
                  ],
                  [
                      'C20', 'C21', 'C22', 'C23', 'C24', 'C25', 'C26', 'C27',
                      'C28', 'C29'
                  ],
                  [
                      'C30', 'C31', 'C32', 'C33', 'C34', 'C35', 'C36', 'C37',
                      'C38', 'C39'
                  ],
                  [
                      'C40', 'C41', 'C42', 'C43', 'C44', 'C45', 'C46', 'C47',
                      'C48', 'C49'
                  ]]
        fieldsP = ['P0', 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9']

        # add layout: probabilities

        self.helper.layout.append(
            Div(Field('G', type='hidden'),
                Field('I', type='hidden'),
                css_class=cssclass))

        self.helper.layout.append(
            HTML(
                '<h5> What are the probabilities (or relative frequencies) for each stimulus type? </h5><br>'
            ))

        for indf, field in enumerate(fieldsP):
            self.helper.layout.append(
                Div(Field(field, type='hidden' if indf >= self.stim else None),
                    css_class=cssclass))

        self.helper.layout.append(HTML('<br><br><br><br><br>'))

        # add layout: contrasts

        if self.cons > 0:
            self.helper.layout.append(HTML('<br><br><br><br><br>'))
            self.helper.layout.append(
                HTML(
                    '''<h5> What are the specific contrasts that will be tested? </h5><br>
                <p>If the contrast sums to 0, you will model the difference between stimuli.  Examples with 3 stimulus types:</p>
                <ul>
                <li>The contrast [1 0 -1] will model the difference between stimulus type 1 and stimulus type 3.</li>
                <li>The contrast [1 -0.5 -0.5] will model the difference between stimulus type 1 and the average of stimulus type 2 and 3.</li>
                </ul>
                <p>If the contrast sums to 1, you will model the main effect of a certain stimulus.  Examples with 3 stimulus types:</p>
                <ul>
                <li>The contrast [1 0 0] will model the main effect of stimulus type 1 (vs. baseline). </li>
                <li>The contrast [0.33,0.33,0.33] will model the average effect of all stimulus types versus baseline.  (don't worry that they don't exactly sum to 1, this will be rescaled)</li>
                </ul><br><br><br>
                '''))

        for indl, line in enumerate(fields):  # loop over lines (contrasts)

            # titles
            if indl < self.cons:
                if indl > 0:
                    self.helper.layout.append(HTML("<br><br><br><br>"))
                self.helper.layout.append(
                    HTML('<h6> Contrast %s </h6>' % (indl + 1)))

            # fields
            for indf, field in enumerate(
                    fields[indl]):  # loop over fields (stimuli)
                self.helper.layout.append(
                    Div(Field(field,
                              type='hidden' if indf >= self.stim
                              or indl >= self.cons else None),
                        css_class=cssclass))

        # finalise layout: submit FormActions

        self.helper.layout.append(HTML("<br><br><br><br>"))
        self.helper.layout.append(
            FormActions(
                Submit('Submit', 'Save and next', css_class='btn-secondary')))

        # initiate the form

        super(DesignConsForm, self).__init__(*args, **kwargs)

        # only labels for the fields from the probabilities

        s = 0
        for field in self.fields.keys():
            s = s + 1
            snew = "stim " + str(s) if s < 10 else ""
            self.fields[field].label = snew
Beispiel #18
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        print('USER_REQUIRED_FIELDS', inventor_settings.USER_REQUIRED_FIELDS)
        for required_field_name in inventor_settings.USER_REQUIRED_FIELDS:
            self.fields[required_field_name].required = True

        print('USER_HIDDEN_FIELDS', inventor_settings.USER_HIDDEN_FIELDS)
        for hidden_field_name in inventor_settings.USER_HIDDEN_FIELDS:
            if self.fields[hidden_field_name].required:
                raise ValueError(
                    f'Field {hidden_field_name} can not be hidden, because it is required'
                )
            self.fields[hidden_field_name].widget = HiddenInput()

        address_fields = ['street', 'postcode', 'city', 'country']
        address_label = '' if set(address_fields) <= set(
            inventor_settings.USER_HIDDEN_FIELDS) else _('Address')
        dob_fields = ['date_of_birth']
        dob_label = '' if set(dob_fields) <= set(
            inventor_settings.USER_HIDDEN_FIELDS) else _('Date of birth')

        # placeholders
        if inventor_settings.USE_PLACEHOLDERS:
            for field_name, field in self.fields.items():
                if isinstance(field, forms.CharField) or \
                        isinstance(field, forms.ChoiceField) or \
                        isinstance(field, forms.DateField):
                    asterisk = '*' if field.required else ''
                    field.widget.attrs[
                        'placeholder'] = f'{field.label.capitalize()}{asterisk}'
                    field.label = ''

        # agreements
        try:
            terms = FlatPage_i18n.objects.get(machine_name='terms')
            self.fields['agree_terms_and_conditions'].label = _(
                'I agree <a href="%s" target="_blank">terms and conditions</a>'
            ) % terms.get_absolute_url()
        except ObjectDoesNotExist:
            pass

        try:
            privacy = FlatPage_i18n.objects.get(machine_name='privacy')
            self.fields['agree_privacy_policy'].label = _(
                'I agree <a href="%s" target="_blank">privacy policy</a>'
            ) % privacy.get_absolute_url()
        except ObjectDoesNotExist:
            pass

        self.helper = FormHelper()
        self.helper.form_tag = False
        self.helper.layout = Layout(
            # Row(
            Fieldset(
                _('Name and surname'),
                Row(
                    Div('first_name', css_class='col-md-5'),
                    Div('last_name', css_class='col-md-7'),
                ),
            ),
            Fieldset(
                _('Contact details'),
                Row(
                    Div(PrependedText('email', '<i class="fas fa-at"></i>'),
                        css_class='col-md-7'
                        if 'phone' not in inventor_settings.USER_HIDDEN_FIELDS
                        else 'col-md-12'),
                    Div(PrependedText('phone',
                                      '<i class="far fa-mobile"></i>'),
                        css_class='col-md-5' if 'phone'
                        not in inventor_settings.USER_HIDDEN_FIELDS else ''),
                ),
            ),
            Fieldset(address_label, *address_fields),
            Fieldset(dob_label, *dob_fields),
            Fieldset(
                pgettext('signup form', 'Other'),
                InlineRadios('gender'),
                'team',
                'password1',
            ),
            Fieldset(
                _('Agreements'),
                'agree_terms_and_conditions',
                'agree_privacy_policy',
                'agree_marketing_purposes',
                'agree_social_networks_sharing',
            ),
            # ),
            FormActions(Submit('submit', _('Sign up'),
                               css_class='btn-primary')))
Beispiel #19
0
class DesignOptionsForm(forms.ModelForm):
    class Meta:
        model = DesignModel
        fields = [
            'rho', 'Aoptimality', 'resolution', 'G', 'q', 'I', 'cycles',
            'preruncycles', 'conv_crit', 'HardProb', 'outdes'
        ]

    def __init__(self, *args, **kwargs):
        super(DesignOptionsForm, self).__init__(*args, **kwargs)
        self.fields[
            'rho'].label = "The assumed temporal autocorrelation coefficient."
        self.fields[
            'Aoptimality'].label = "Do you want to optimise using A-optimality or D-optimality?"
        #self.fields['Saturation'].label = "We assume that there is saturation in the BOLD-signal: the signal cannot exceed 2 times the height of the HRF.  This avoids that for an ITI going towards 0, the signal goes to infinity."
        self.fields[
            'resolution'].label = "The resolution of the timing of stimuli."
        self.fields[
            'G'].label = "How many designs go from one generation to the next?"
        self.fields['q'].label = "What percentage of the trials gets mutated?"
        self.fields['I'].label = "How many immigrants per generation?"
        self.fields[
            'cycles'].label = "Number of generations (iterations or cycles)."
        self.fields[
            'preruncycles'].label = "Number of generations in the prerun to define the maximum efficiency and detection power."
        self.fields[
            'conv_crit'].label = "Number of stable generations to reach convergence"
        self.fields[
            'HardProb'].label = "Do you want a hard limit on the probabilities? (experimental)"
        self.fields['outdes'].label = 'How many designs do you want to get?'

    def clean(self):
        cleaned_data = super(DesignOptionsForm, self).clean()
        return cleaned_data

    helper = FormHelper()
    helper.form_method = 'POST'
    helper.field_class = 'col-lg-12'
    helper.label_class = 'col-lg-12'
    helper.layout = Layout(
        Fieldset(
            'Design and optimisation parameters',
            HTML(
                """<p>These parameters are hidden and the default values can be found below.  To change the parameters, fill out the fields you wish to change and click save.</p><br><br>"""
            ),
            Div(
                Div(Field('rho'), css_class='col-xs-12'),
                Div(Field('Aoptimality'), css_class='col-xs-12'),
                #Div(Field('Saturation'),css_class='col-xs-12'),
                Div(Field('resolution'), css_class='col-xs-12'),
                Div(Field('outdes'), css_class='col-xs-12'),
                Div(Field('HardProb'), css_class='col-xs-4'),
                css_class='row-md-12 col-xs-12')),
        HTML("<br><br><br>"),
        Fieldset(
            'Genetic algorithm parameters',
            HTML(
                """<p>The following parameters are set for a good flow of the genetic algorithm.</p><br><br>"""
            ),
            Div(Div(Field('G'), css_class='col-xs-12'),
                Div(Field('q'), css_class='col-xs-12'),
                Div(Field('I'), css_class='col-xs-12'),
                Div(Field('cycles'), css_class='col-xs-12'),
                Div(Field('preruncycles'), css_class='col-xs-12'),
                Div(Field('conv_crit'), css_class='col-xs-12'),
                css_class='row-md-12 col-xs-12')),
        HTML("""<br><br><br><br><br>"""),
        FormActions(Submit('Submit', 'Save', css_class='btn-black')),
        HTML("""<br><br><br><br><br>"""))
Beispiel #20
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        print('USER_REQUIRED_FIELDS', inventor_settings.USER_REQUIRED_FIELDS)
        for required_field_name in inventor_settings.USER_REQUIRED_FIELDS:
            self.fields[required_field_name].required = True

        print('USER_HIDDEN_FIELDS', inventor_settings.USER_HIDDEN_FIELDS)
        for hidden_field_name in inventor_settings.USER_HIDDEN_FIELDS:
            if self.fields[hidden_field_name].required:
                raise ValueError(
                    f'Field {hidden_field_name} can not be hidden, because it is required'
                )
            self.fields[hidden_field_name].widget = HiddenInput()

        address_fields = ['street', 'postcode', 'city', 'country']
        address_label = '' if set(address_fields) <= set(
            inventor_settings.USER_HIDDEN_FIELDS) else _('Address')
        dob_fields = ['date_of_birth']
        dob_label = '' if set(dob_fields) <= set(
            inventor_settings.USER_HIDDEN_FIELDS) else _('Date of birth')

        # placeholders
        if inventor_settings.USE_PLACEHOLDERS:
            for field_name, field in self.fields.items():
                if isinstance(field, forms.CharField) or \
                        isinstance(field, forms.ChoiceField) or \
                        isinstance(field, forms.DateField):
                    asterisk = '*' if field.required else ''
                    field.widget.attrs[
                        'placeholder'] = f'{field.label.capitalize()}{asterisk}'
                    field.label = ''

        self.helper = FormHelper()

        if inventor_settings.USER_FORM_COLUMNS:
            column_class = 'col-md-6'
        else:
            column_class = 'col-md-6 offset-md-3'

        self.helper.layout = Layout(
            Div(
                Div(
                    Fieldset(
                        _('Name and surname'),
                        Row(
                            Div('first_name', css_class='col-md-5'),
                            Div('last_name', css_class='col-md-7'),
                        ),
                    ),
                    Fieldset(
                        _('Contact details'),
                        PrependedText('email', '<i class="fas fa-at"></i>'),
                        PrependedText('phone',
                                      '<i class="far fa-mobile"></i>')),
                    Fieldset(address_label, *address_fields),
                    Fieldset(dob_label, *dob_fields),
                    # Fieldset(
                    #     _('Address'),
                    #     'street',
                    #     Row(
                    #         Div('postcode', css_class='col-md-5'),
                    #         Div('city', css_class='col-md-7'),
                    #     ),
                    #     'country',
                    # ),
                    # Fieldset(
                    #     _('Date of birth'),
                    #     'date_of_birth',
                    # ),
                    css_class=column_class),
                Div(
                    Fieldset(
                        _('Other'),
                        InlineRadios('gender'),
                        'team',
                        'avatar',
                    ),
                    Fieldset(_('Preferred language'), 'preferred_language'),
                    Fieldset(
                        _('Agreements'),
                        # agreements / GDPR
                        'agree_terms_and_conditions',
                        'agree_privacy_policy',
                        'agree_marketing_purposes',
                        'agree_social_networks_sharing',
                    ),
                    css_class=column_class),
                css_class='row'),
            FormActions(Submit('submit',
                               _('Submit'),
                               css_class='btn-lg btn-primary'),
                        css_class='text-center'))
Beispiel #21
0
    def __init__(self, *args, **kwargs):
        super(PostFormOther, self).__init__(*args, **kwargs)

        for field in self.fields:
            self.fields[field].error_messages = {
                'required': 'This field is required'
            }

        LastVal = OtherTraits.objects.all().order_by(
            '-trt_id').values_list()[0][0] + 1
        self.helper = FormHelper(self)
        self.helper.form_method = 'post'
        self.helper.form_action = 'dbPostother'
        self.helper.form_id = 'dbPostother_id'

        self.helper.layout = Layout(
            Div(
                HTML(
                    '<div id="div_id_species" class="control-group"> <label id="specieslab" for="id_species" class="control-label requiredField">\
                Species<span class="asteriskField">*</span> </label> <div class="controls"> <select class="selectpicker show-tick" data-live-search="true" name="species" id="id_species">\
                <option>Select by scientific name</option>{% for x in species %}<option value={{x.species_id_html}}>{{x.species_id}}</option>{% endfor %}</select></div> </div>\
                <div id="specieserror"></div>'),
                style='width:50%; display:inline-block;',
            ),
            Div(HTML(
                "<a href='/EntryKey' target='_blank' class='btn btn-warning'><span class='glyphicon glyphicon-list-alt'></span> Data Entry Key </a>"
            ),
                style="float:right;"),
            HTML("<hr />"),
            HTML(
                '<a href="/admin/app/citation/add/" target="_blank" class="btn btn-danger btn-lg"> Add new citation </a>'
            ),
            HTML("<hr />"),
            Fieldset(
                'Add Trait',
                Div(HTML(
                    '<div id="div_id_traits" class="control-group"> <label for="id_traits" class="control-label requiredField">\
                Character Traits<span class="asteriskField">*</span> </label> <div class="controls"> <select class="selectpicker show-tick" onchange="traitopts()" name="traits" id="id_traits">\
                {% for x in traits %}<option value="{{x.variable}}">{{x.variable}}</option>{% endfor %}</select></div> </div>'
                ),
                    css_class='col-md-3 input-md'),
                Div(
                    HTML(
                        '<div id="div_id_traitopt" class="control-group"> <label id="traitoptlab" for="id_traitopt" class="control-label requiredField">\
                Trait values<span class="asteriskField">*</span> </label> <div class="controls"> <select class="selectpicker show-tick" name="traitopt" id="id_traitopt">\
                <option>Select value</option>{% for x in traitopts %}<option value="{{x.tr_value}}">{{x.tr_name}}</option>{% endfor %}</select></div> </div>'
                    ),
                    css_class='col-md-3 input-md',
                ),
                Div(HTML(
                    '<div id="div_id_citation" class="control-group"> <label id="citationlab" for="id_citation" class="control-label requiredField">\
                Citation <span class="asteriskField">*</span> </label> <div class="controls"> <select class="selectpicker show-tick" data-live-search="true" name="citation" id="id_citation">\
                <option>Select citation</option>{% for x in citations %}<option value="{{x.citation_name}}">{{x.citation_name}}</option>{% endfor %}</select></div> </div>'
                ),
                    HTML('<div class="col-md-12"><br /></div>'),
                    'study_year',
                    'study_location',
                    css_class='col-md-3 input-md'),
                Div('comments', css_class='col-md-3 input-md'),
                HTML('<div class="col-md-5"><br /></div>'),
            ),
            HTML("<br />"),
            Fieldset(
                'Save the data',
                HTML(
                    '<div id="div_id_trtid" style="display:none" class="col-md-3 control-group"> <label for="id_trtid" class="control-label requiredField">\
                Feature id<span class="asteriskField">*</span> </label> <div class="controls"> <input readonly class="numberinput" id="id_trtid" name="trtid" type="number" value="'
                    + str(LastVal) + '"> </div> </div>'),
                HTML(
                    '<div id="div_id_username" style="display:none" class="col-md-3 control-group"> <label for="id_username" class="control-label requiredField">\
                Username<span class="asteriskField">*</span> </label> <div class="controls"> <input readonly class="textinput textInput" id="id_username" maxlength="30" name="username" type="text" value={{user.username}}> </div> </div>'
                ),
                HTML(
                    '<div id="div_id_dt" style="display:none" class="col-md-3 control-group"> <label for="id_dt" class="control-label requiredField">\
                Dt<span class="asteriskField">*</span> </label> <div class="controls"> <input readonly class="textinput textInput" id="id_dt" maxlength="30" name="dt" type="text" value={{day}}/{{month}}/{{year}}> </div> </div>'
                ),
                Div(FormActions(
                    Submit('dbPostother',
                           'Save data',
                           css_class='btn btn-success',
                           action=".")),
                    css_class='col-md-3'),
                HTML('<div class="col-md-3" id="savesuccess"></div>'),
            ),
        )
Beispiel #22
0
    def __init__(self,
                 account,
                 domain,
                 creating_user,
                 current_subscription,
                 renewed_version,
                 data=None,
                 *args,
                 **kwargs):
        self.current_subscription = current_subscription
        super(ConfirmSubscriptionRenewalForm, self).__init__(account,
                                                             domain,
                                                             creating_user,
                                                             data=data,
                                                             *args,
                                                             **kwargs)

        self.fields['plan_edition'].initial = renewed_version.plan.edition
        self.fields['confirm_legal'].label = mark_safe(
            ugettext_noop('I have read and agree to the <a href="%(pa_url)s" '
                          'target="_blank">Software Product Agreement</a>.') %
            {
                'pa_url': reverse("product_agreement"),
            })

        from corehq.apps.domain.views import DomainSubscriptionView
        self.helper.layout = crispy.Layout(
            'plan_edition',
            crispy.Fieldset(
                _("Billing Administrators"),
                crispy.Field('billing_admins', css_class='input-xxlarge'),
            ),
            crispy.Fieldset(
                _("Basic Information"),
                'company_name',
                'first_name',
                'last_name',
                crispy.Field('emails', css_class='input-xxlarge'),
                'phone_number',
            ),
            crispy.Fieldset(
                _("Mailing Address"), 'first_line', 'second_line', 'city',
                'state_province_region', 'postal_code',
                crispy.Field('country',
                             css_class="input-large",
                             data_countryname=dict(COUNTRIES).get(
                                 self.current_country, ''))),
            crispy.Fieldset(
                _("Re-Confirm Product Agreement"),
                'confirm_legal',
            ),
            FormActions(
                crispy.HTML(
                    '<a href="%(url)s" style="margin-right:5px;" class="btn">%(title)s</a>'
                    % {
                        'url':
                        reverse(DomainSubscriptionView.urlname,
                                args=[self.domain]),
                        'title':
                        _("Cancel"),
                    }),
                StrictButton(
                    _("Renew Plan"),
                    type="submit",
                    css_class='btn btn-success',
                ),
            ),
        )
Beispiel #23
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.attrs = {'id': 'selected_problems'}
     self.helper.layout = Layout(
         FormActions(Field('problem_list', type="hidden")), )
Beispiel #24
0
    def __init__(self,
                 account,
                 domain,
                 creating_user,
                 data=None,
                 *args,
                 **kwargs):
        self.account = account
        self.domain = domain
        self.creating_user = creating_user

        try:
            self.current_country = self.account.billingcontactinfo.country
        except Exception:
            initial = kwargs.get('initial')
            self.current_country = initial.get(
                'country') if initial is not None else None

        try:
            kwargs['instance'] = self.account.billingcontactinfo
        except BillingContactInfo.DoesNotExist:
            pass

        super(EditBillingAccountInfoForm, self).__init__(data, *args, **kwargs)

        other_admins = self.account.billing_admins.filter(
            domain=self.domain).exclude(web_user=self.creating_user).all()
        self.fields['billing_admins'].initial = ','.join(
            [o.web_user for o in other_admins])

        self.helper = FormHelper()
        self.helper.form_class = 'form form-horizontal'
        self.helper.layout = crispy.Layout(
            crispy.Fieldset(
                _("Billing Administrators"),
                crispy.Field('billing_admins', css_class='input-xxlarge'),
            ),
            crispy.Fieldset(
                _("Basic Information"),
                'company_name',
                'first_name',
                'last_name',
                crispy.Field('emails', css_class='input-xxlarge'),
                'phone_number',
            ),
            crispy.Fieldset(
                _("Mailing Address"),
                'first_line',
                'second_line',
                'city',
                'state_province_region',
                'postal_code',
                crispy.Field('country',
                             css_class="input-large",
                             data_countryname=dict(COUNTRIES).get(
                                 self.current_country, '')),
            ),
            FormActions(
                StrictButton(
                    _("Update Billing Information"),
                    type="submit",
                    css_class='btn btn-primary',
                ), ),
        )
Beispiel #25
0
class InvestmentCompanyForm(BaseModelForm):
    def __init__(self, *args, **kwargs):
        super(InvestmentCompanyForm, self).__init__(*args, **kwargs)
        self.fields[
            'preferred_industries'].label = 'Please select your prefered industries'
        self.fields[
            'investment_stage'].label = 'At what stage do you support investments?'
        self.fields[
            'ticket_size'].label = 'Please tell us your ticket size for investments?'
        self.fields['url'].label = 'What is your organisation URL?'
        self.fields['logo'].label = "Organisation logo (jpeg, png, gif)"

    investor_focus = forms.CharField(
        widget=forms.Textarea(),
        label="Please describe the investor focus of your organisation")
    preferred_industries = forms.MultipleChoiceField(choices=(
        ('agriculture', "Agriculture"),
        ('manufacturing', "Manufacturing and Assembly"),
        ('financial', "Financial Services"),
        ('renewable', "Renewable Energy"),
        ('information security', "Information Security"),
        ('education', "Education"),
        ('health', "Healthcare & Services"),
        ('infrastructure', "Infrastructure"),
        ('transport', "Transport"),
    ),
                                                     required=True)
    other_industries = forms.CharField()
    investment_stage = forms.MultipleChoiceField(
        choices=(("Concept Stage", "Concept stage"),
                 ("Seed stage (finding product market fit)",
                  "Seed stage (finding product market fit)"),
                 ("Venture captial (growth)", "Venture captial (growth)"),
                 ("Private Equity (scaling and expansion)",
                  "Private Equity (scaling and expansion)")),
        required=True)
    ticket_size = forms.CharField(required=True)
    url = forms.CharField()
    logo = forms.ImageField(validators=[validate_img], required=False)
    organisation_name = forms.CharField()

    helper = FormHelper()
    helper.form_class = 'form-horizontal'
    helper.layout = Layout(
        Field('organisation_name', css_class='text-small form-control'),
        Field('logo'),
        Field('url', css_class='text-small form-control'),
        Field('ticket_size', css_class='text-small form-control'),
        InlineCheckboxes('preferred_industries'),
        Field('other_industries', css_class='text-small form-control'),
        Field('investor_focus', css_class='text-large form-control'),
        InlineCheckboxes('investment_stage'),
        FormActions(
            Button('cancel', 'Cancel', css_class='cancelBtn'),
            Submit('next', 'Finish', css_class="cancelBtn"),
        ),
    )

    class Meta:
        model = InvestmentCompany
        fields = [
            'investor_focus', 'preferred_industries', 'other_industries',
            'investment_stage', 'ticket_size', 'logo', 'url',
            'organisation_name'
        ]
Beispiel #26
0
    def __init__(self,
                 *args,
                 workshop_url,
                 has_perm_to_edit=True,
                 has_perm_to_disable_uploads=False,
                 profile_warnings=None,
                 **kwargs):
        super(ModelForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.include_media = False

        # Disable fields that should be disabled
        if not self.instance.is_workshop_editable() or not has_perm_to_edit:
            for field in self.fields.values():
                field.disabled = True

        if self.instance.status:
            # The proposition cannot be edited once the workshop has a status set
            self.fields['proposition_description'].disabled = True

        if not has_perm_to_disable_uploads:
            self.fields['solution_uploads_enabled'].disabled = True

        # Make sure only current category and type choices are displayed
        if self.instance is None:
            raise ValueError(
                'WorkshopForm must be provided with an instance with the .year field already set'
            )
        year = self.instance.year
        self.fields['category'].queryset = WorkshopCategory.objects.filter(
            year=year)
        self.fields['type'].queryset = WorkshopType.objects.filter(year=year)

        # Display link to current qualification tasks:
        if self.instance.qualification_problems:
            self.fields['qualification_problems'].help_text = format_html(
                'Aktualnie: <a href="{}" target="_blank">{}</a>',
                reverse('qualification_problems',
                        args=[self.instance.year.pk, self.instance.name]),
                os.path.basename(self.instance.qualification_problems.path))
        else:
            self.fields['qualification_problems'].help_text = 'Aktualnie: brak'

        # Configure TinyMCE settings
        mce_attrs = {}
        mce_attrs['readonly'] = self.fields[
            'proposition_description'].disabled  # does not seem to respect the Django field settings for some reason
        self.fields['proposition_description'].widget = InitializedTinyMCE(
            mce_attrs=mce_attrs)

        mce_attrs = settings.TINYMCE_DEFAULT_CONFIG_WITH_IMAGES.copy()
        if self.instance and self.instance.pk:
            mce_attrs['automatic_uploads'] = True
            mce_attrs['images_upload_url'] = reverse('workshop_edit_upload',
                                                     kwargs={
                                                         'year':
                                                         self.instance.year.pk,
                                                         'name':
                                                         self.instance.name
                                                     })
        mce_attrs['readonly'] = self.fields[
            'page_content'].disabled  # does not seem to respect the Django field settings for some reason
        self.fields['page_content'].widget = InitializedTinyMCE(
            mce_attrs=mce_attrs)

        # Layout
        self.fieldset_general = Fieldset(
            "Ogólne",
            Div(Div(PrependedAppendedText(
                'name',
                workshop_url[0] + '<b>' + str(year.pk) + '</b>' +
                workshop_url[1],
                workshop_url[2],
                template=
                "%s/layout/prepended_appended_text_with_mobile_support.html"),
                    css_class='col-lg-12'),
                Div('title', css_class='col-lg-12'),
                css_class='row'),
            Div(Div('type', css_class='col-lg-6'),
                Div('category', css_class='col-lg-6'),
                css_class='row'),
        )
        if profile_warnings:
            for message in profile_warnings:
                self.fieldset_general.fields.append(
                    Alert(content=message,
                          dismiss=False,
                          css_class='alert-info'))
        self.fieldset_proposal = Fieldset(
            "Opis propozycji",
            'proposition_description',
        )
        self.fieldset_qualification = Fieldset(
            "Kwalifikacja",
            'is_qualifying',
            Div('qualification_problems',
                Div(Div('max_points', css_class='col-lg-6'),
                    Div('qualification_threshold', css_class='col-lg-6'),
                    css_class='row'),
                'solution_uploads_enabled',
                css_id='qualification_settings'),
        )
        self.fieldset_public_page = Fieldset("Strona warsztatów",
                                             'short_description',
                                             'page_content',
                                             'page_content_is_public')
        self.fieldset_submit = FormActions(
            StrictButton(
                'Zapisz' if self.instance and self.instance.pk else 'Zgłoś!',
                type='submit',
                css_class='btn-outline-primary btn-lg mx-1 my-3'),
            css_class='text-right',
        )

        if not self.instance or not self.instance.is_publicly_visible():
            for field in [
                    'qualification_problems', 'is_qualifying',
                    'solution_uploads_enabled', 'max_points',
                    'qualification_threshold', 'short_description',
                    'page_content', 'page_content_is_public'
            ]:
                del self.fields[field]

            self.helper.layout = Layout(
                self.fieldset_general,
                self.fieldset_proposal,
                self.fieldset_submit,
            )
        else:
            if not has_perm_to_edit:
                self.helper.layout = Layout(
                    self.fieldset_general,
                    self.fieldset_proposal,
                    self.fieldset_qualification,
                    self.fieldset_public_page,
                )
            else:
                self.helper.layout = Layout(
                    self.fieldset_general,
                    self.fieldset_proposal,
                    self.fieldset_qualification,
                    self.fieldset_public_page,
                    self.fieldset_submit,
                )
Beispiel #27
0
from ajax_select.fields import AutoCompleteSelectField
from ajax_select import make_ajax_field

from django.forms.widgets import FileInput, HiddenInput

#from floppyforms.widgets import DateInput
from tagging.forms import TagField
from ac_tagging.widgets import TagAutocompleteTagIt

from lib.widgets.widgets import ReadOnlyIconField

ACTION_LAYOUT = action_layout = FormActions(
    HTML(
        '<button type="submit" name="save" value="save" class="btn btn-primary pull-right ajax_submit" id="submit-id-save-i-classicon-arrow-upi"><i class="icon-save icon-white"></i> Save</button>'
    ),
    HTML(
        '<button type="reset" name="reset" value="reset" class="reset resetButton btn btn-secondary pull-right" id="reset-id-reset"><i class="icon-trash"></i> Cancel</button>'
    ),
)
ACTION_LAYOUT_EXTENDED = action_layout = FormActions(
    Field('publish', css_class='input-hidden'),
    HTML(
        '<button type="submit" name="save" value="save" class="btn btn-primary pull-right ajax_submit" id="submit-id-save-i-classicon-arrow-upi"><i class="icon-save icon-white"></i> Save</button>'
    ),
    HTML(
        '<button type="submit" name="save-and-publish" value="save" class="btn pull-right ajax_submit save-and-publish" id="submit-id-save-i-classicon-arrow-upi"><i class="icon-bullhorn icon-white"></i> Save & Publish</button>'
    ),
    HTML(
        '<button type="reset" name="reset" value="reset" class="reset resetButton btn btn-secondary pull-right" id="reset-id-reset"><i class="icon-trash"></i> Cancel</button>'
    ),
)
Beispiel #28
0
    def __init__(self, *args, participant_view=False, **kwargs):
        super(WorkshopParticipantPointsForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.include_media = False
        self.helper.form_tag = False
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-lg-3'
        self.helper.field_class = 'col-lg-9'
        self.helper.layout = Layout(
            AppendedText(
                'qualification_result',
                'na&nbsp;<b>{}</b>&nbsp;możliwych'.format(
                    self.instance.workshop.max_points)
                if self.instance.workshop.max_points is not None else None,
                css_class='col-md-3'),
            'comment',
            # I don't think there is any proper way to render a field-like constant text using crispy forms :<
            HTML(
                format_html(
                    '''
                <div id="div_id_mark" class="form-group row">
                    <label for="id_mark" class="col-form-label col-lg-3">
                        Zakwalifikowano
                    </label>

                    <div class="col-lg-9">
                        <div id="id_mark" class="form-control px-0" style="border: 0;">
                            {}
                        </div>
                        {}
                    </div>
                </div>
            ''', qualified_mark(self.instance.is_qualified()),
                    mark_safe(
                        '<small id="hint_id_mark" class="form-text text-muted">To pole jest wypełniane automatycznie na podstawie progu kwalifikacji ustawionego w edytorze warsztatów</small>'
                    ) if not participant_view else '')))
        if not participant_view:
            self.helper.layout.fields.append(
                FormActions(StrictButton(
                    'Zapisz',
                    type='submit',
                    css_class='btn-outline-primary btn-lg mx-1 my-3'),
                            css_class='text-right row'))

            self.fields[
                'comment'].help_text = 'Komentarz jest widoczny dla uczestnika na stronie z wynikami kwalifikacji oraz w widoku rozwiązania'
            self.fields[
                'qualification_result'].help_text = 'Maksymalną liczbę punktów możliwą do uzyskania można ustawić w edytorze warsztatów. Możesz postawić punkty bonusowe powyżej tej wartości, ale tylko do {}% wartości bazowej.'.format(
                    settings.MAX_POINTS_PERCENT)

        for field in self.fields.values():
            # autocomplete=off fixes a problem on Firefox where the form fields don't reset on reload, making the save button visibility desync
            field.widget.attrs.update({
                'class': 'form-control',
                'autocomplete': 'off'
            })
            field.required = False

        if not self.instance.workshop.is_qualification_editable(
        ) or participant_view:
            for field in self.fields.values():
                field.disabled = True
Beispiel #29
0
 def __init__(self, *args, **kwargs):
     super(CustomerDeleteForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper(self)
     self.helper.layout.append(
         FormActions(deletebutton,cancelbutton)
     )
Beispiel #30
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Field('is_active'), Field('is_superuser'), Field('groups'),
         FormActions(Submit('save', _('Save')), Back(reverse('users'))))
Beispiel #31
0
    def __init__(self, *args, **kwargs):
        super(ContactAdd, self).__init__(*args, **kwargs)

        self.fields['due_date'].widget = util.AngularPopupDatePicker(
            {'required': True}, min=3)
        self.fields['birthdate'].widget = util.AngularPopupDatePicker(
            {
                'required': True,
                'datepicker-position-right': True
            },
            max=-5110  # 14 years or older
        )
        self.fields['art_initiation'].widget = util.AngularPopupDatePicker(
            max=0)
        self.fields['clinic_visit'].widget = util.AngularPopupDatePicker(
            {'required': True}, min=7)

        self.helper = FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.form_id = 'participant-details-form'
        self.helper.label_class = 'col-sm-6'
        self.helper.field_class = 'col-sm-6'
        self.helper.form_tag = False

        self.helper.layout = Layout(
            Fieldset(
                'Study Information',
                Div(Div('study_id', css_class="col-md-4"),
                    Div('anc_num', css_class="col-md-4"),
                    Div('study_group', css_class="col-md-4"),
                    css_class="row"),
                Div(
                    Div('ccc_num', css_class="col-md-4"),
                    Div('send_day',
                        css_class="col-md-4",
                        ng_if="participant.study_group != 'control'"),
                    Div('send_time',
                        css_class="col-md-4",
                        ng_if="participant.study_group != 'control'"),
                    css_class="row",
                ),
            ),
            Fieldset(
                'Client Information',
                Div(Div('nickname', css_class="col-md-4"),
                    Div('phone_number', css_class="col-md-4"),
                    Div('birthdate', css_class="col-md-4"),
                    css_class="row"),
                Div(Div('relationship_status', css_class="col-md-4"),
                    Div('partner_name', css_class="col-md-4"),
                    Div('previous_pregnancies', css_class="col-md-4"),
                    css_class="row"),
                Div(Div('language', css_class="col-md-4"),
                    Div('condition', css_class="col-md-4"),
                    css_class="row"),
            ),
            Fieldset(
                'Disclosure and Consent',
                Div(Div('hiv_disclosed', css_class="col-md-4"),
                    Div('phone_shared', css_class="col-md-4"),
                    Div('hiv_messaging', css_class="col-md-4"),
                    css_class="row")),
            Fieldset(
                'Important Dates',
                Div(Div('art_initiation', css_class="col-md-4"),
                    Div('due_date', css_class="col-md-4"),
                    Div('clinic_visit', css_class="col-md-4"),
                    css_class="row")),
            FormActions(Submit('submit',
                               'Enroll Participant',
                               ng_disabled='participantNewForm.$invalid',
                               style='margin-bottom:20px'),
                        css_class="row"))

        # thank you: http://stackoverflow.com/questions/24663564/django-add-attribute-to-every-field-by-default
        for field in self:

            field.field.widget.attrs.update({
                'ng-model':
                'participant.{0}'.format(field.name),
            })
Beispiel #32
0
class DesignMainForm(forms.ModelForm):
    class Meta:
        model = DesignModel
        fields = [
            'stim_duration', 'TR', 'L', 'S', 'Clen', 'Call', 'RestNum',
            'RestDur', 'ConfoundOrder', 'MaxRepeat', 'W1', 'W2', 'W3', 'W4',
            'duration_unitfree', 'duration_unit', 'durspec', 'ITImodel',
            'ITIfixed', 'ITIunifmin', 'ITIunifmax', 'ITItruncmin',
            'ITItruncmax', 'ITItruncmean', 't_prestim', 't_poststim'
        ]

    def __init__(self, *args, **kwargs):
        super(DesignMainForm, self).__init__(*args, **kwargs)
        self.fields['ITImodel'].label = "Choose a model to sample ITI's from"
        self.fields['ITIfixed'].label = "ITI duration (seconds)"
        self.fields['ITIunifmin'].label = "Minimum ITI (seconds)"
        self.fields['ITIunifmax'].label = "Maximum ITI (seconds)"
        self.fields['ITItruncmin'].label = "Minimum ITI (seconds)"
        self.fields['ITItruncmax'].label = "Maximum ITI (seconds)"
        self.fields['ITItruncmean'].label = "Average ITI (seconds)"
        self.fields['TR'].label = "Scanner TR (seconds)"
        self.fields['S'].label = "Number of stimulus types"
        self.fields['stim_duration'].label = "Stimulus duration (seconds)"
        self.fields['t_prestim'].label = "Seconds before stimulus"
        self.fields['t_poststim'].label = "Seconds after stimulus"
        self.fields['L'].label = "Total number of trials"
        self.fields['duration_unitfree'].label = 'Total duration of the task'
        self.fields['duration_unit'].label = 'Unit of duration'
        self.fields['Call'].label = 'Check to include all pairwise contrasts'
        self.fields['Clen'].label = 'Number of custom contrasts'
        self.fields['RestNum'].label = 'How many trials between rest blocks'
        self.fields['RestDur'].label = 'Duration of rest (seconds)'
        self.fields['ConfoundOrder'].label = 'Order of confounding control'
        self.fields[
            'MaxRepeat'].label = 'Max number of repeated stimulus types'
        self.fields['W1'].label = 'Design efficiency'
        self.fields['W2'].label = 'Detection power'
        self.fields['W3'].label = 'Trial probabilities'
        self.fields['W4'].label = 'Psychological confounds'
        self.fields['durspec'].label = ""
        # self.fields['nested'].label = "Check for a nested design"
        # self.fields['nest_classes'].label = "If the design is nested, how many classes of stimulus types are there?"

    def clean(self):
        cleaned_data = super(DesignMainForm, self).clean()

        # if cleaned_data.get("ITI")<0:
        #     raise forms.ValidationError("ITI cannot be smaller than 0. Parameters not saved.")
        if cleaned_data.get("duspec") == 1 and cleaned_data.get(
                "duration_unitfree") == None:
            raise forms.ValidationError(
                "You need to specify the total duration of the experiment.")

        if cleaned_data.get("duspec") == 2 and cleaned_data.get("L") == None:
            raise forms.ValidationError(
                "You need to specify the total number of trials.")

        if cleaned_data.get("TR") < 0 or cleaned_data.get("TR") > 10:
            raise forms.ValidationError(
                "Are you sure about that TR? Parameters not saved.")

        if cleaned_data.get("S") > 10:
            raise forms.ValidationError(
                "Sorry, at the moment we can only model designs when there are at most 10 stimulus types. Parameters not saved."
            )

        if cleaned_data.get("S") == 1:
            raise forms.ValidationError(
                "Sorry, at the moment we can only model designs with more than 1 stimulus type.  Check back, this extension is on the agenda!"
            )

        if cleaned_data.get("Clen") > 5:
            raise forms.ValidationError(
                "Sorry, at the moment we can only model designs when there are at most 5 contrasts. Parameters not saved."
            )

        if cleaned_data.get("Clen") == 0 and cleaned_data.get("Call") == False:
            raise forms.ValidationError(
                "Either choose a number of contrasts to be tested or choose all pairwise contrasts."
            )

        if cleaned_data.get("ConfoundOrder") > 10:
            raise forms.ValidationError(
                "Sorry, at the moment we can only model designs with a confoundorder smaller than 10. Parameters not saved."
            )

        if cleaned_data.get("ITImodel") == 1 and cleaned_data.get(
                "ITIfixed") == None:
            raise forms.ValidationError(
                "For a fixed ITI, please fill out the duration of the ITI's.")

        if cleaned_data.get("ITImodel") == 2 and (
                cleaned_data.get("ITItruncmin") == None
                or cleaned_data.get("ITItruncmax") == None
                or cleaned_data.get("ITItruncmean") == None):
            raise forms.ValidationError(
                "For a truncated ITI, please fill out mean, min and max.")

        if cleaned_data.get("ITImodel") == 2:
            mn = cleaned_data.get("ITItruncmax") - cleaned_data.get(
                "ITItruncmin")
            if mn < cleaned_data.get("ITItruncmean"):
                raise forms.ValidationError(
                    "You specified a truncated exponential for the ITI's, but the mean is larger than the mean between min and max.  This is not possible for a truncated exponential."
                )

        if cleaned_data.get("ITImodel") == 3 and (
                cleaned_data.get("ITIunifmin") == None
                or cleaned_data.get("ITIunifmax") == None):
            raise forms.ValidationError(
                "For ITI's sampled from a uniform distribution, please fill out the min and max."
            )

        # if cleaned_data.get("ITImin")==None and cleaned_data.get("ITImax")==None and cleaned_data.get("ITImean")==None:
        #     raise forms.ValidationError("You need to specify at least either a range of ITI, or the average (fixed) ITI.")
        #
        # if (cleaned_data.get("ITImin")==None and not cleaned_data.get("ITImax")==None) or (cleaned_data.get("ITImax")==None and not cleaned_data.get("ITImin")==None):
        #     raise forms.ValidationError("You specified either a minimum or a maximum ITI.  You need to fill out both.")
        #
        if (cleaned_data.get("RestNum") > 0
                and cleaned_data.get("RestDur") == 0):
            raise forms.ValidationError(
                "You wanted restblocks but you didn't specify their duration.")

        smaller = [
            cleaned_data.get("TR") < 0,
            cleaned_data.get("ITIunifmin") < 0,
            cleaned_data.get("ITIfixed") < 0,
            cleaned_data.get("ITIunifmax") < 0,
            cleaned_data.get("ITItruncmax") < 0,
            cleaned_data.get("ITItruncmin") < 0,
            cleaned_data.get("ITItruncmean") < 0,
            cleaned_data.get("S") < 0,
            cleaned_data.get("stim_duration") < 0,
            cleaned_data.get("L") < 0,
            cleaned_data.get("Clen") < 0,
            cleaned_data.get("RestNum") < 0,
            cleaned_data.get("RestDur") < 0,
            cleaned_data.get("ConfoundOrder") < 0,
            cleaned_data.get("MaxRepeat") < 0,
            cleaned_data.get("W1") < 0,
            cleaned_data.get("W2") < 0,
            cleaned_data.get("W3") < 0,
            cleaned_data.get("W4") < 0,
            cleaned_data.get("t_prestim") < 0,
            cleaned_data.get("t_poststim") < 0
        ]
        snone = [
            cleaned_data.get("TR") == None,
            cleaned_data.get("ITIunifmin") == None,
            cleaned_data.get("ITIfixed") == None,
            cleaned_data.get("ITIunifmax") == None,
            cleaned_data.get("ITItruncmax") == None,
            cleaned_data.get("ITItruncmin") == None,
            cleaned_data.get("ITItruncmean") == None,
            cleaned_data.get("S") == None,
            cleaned_data.get("stim_duration") == None,
            cleaned_data.get("L") == None,
            cleaned_data.get("Clen") == None,
            cleaned_data.get("RestNum") == None,
            cleaned_data.get("RestDur") == None,
            cleaned_data.get("ConfoundOrder") == None,
            cleaned_data.get("MaxRepeat") == None,
            cleaned_data.get("W1") == None,
            cleaned_data.get("W2") == None,
            cleaned_data.get("W3") == None,
            cleaned_data.get("W4") == None,
            cleaned_data.get("t_prestim") == None,
            cleaned_data.get("t_poststim") == None
        ]
        svalid = [
            True if a and not b else False for a, b in zip(smaller, snone)
        ]
        if any(svalid):
            raise forms.ValidationError(
                "Some values are smaller than zero.  Please check for errors or typo's."
            )

        return cleaned_data

    helper = FormHelper()
    helper.form_method = 'POST'
    helper.field_class = 'col-lg-12'
    helper.label_class = 'col-lg-12'
    helper.layout = Layout(
        Fieldset(
            'Design parameters',
            HTML(
                """<h5 style="margin-left: 15px">These parameters refer to your design and need your careful attention.</h5><br>"""
            ),
            Div(Div(Field('S'), css_class='col-md-6 col-sm-6 col-xs-12'),
                Div(Field('TR'), css_class='col-md-6 col-sm-6 col-xs-12'),
                css_class='row-md-12 col-xs-12'),
        ),
        HTML("<br><br><br>"),
        Fieldset(
            "",
            Div(
                HTML(
                    """<h5 style="margin-left: 15px">Trial structure</h5><p style="margin-left: 20px"> What does one trial look like?  Probably there is some time before the stimulus of interest (the target), where a fixation cross is shown.  Maybe there is some time after the stimulus is presented.</p>"""
                ),
                Div(Field('t_prestim'),
                    css_class='col-md-4 col-sm-4 col-xs-12'),
                Div(Field('stim_duration'),
                    css_class='col-md-4 col-sm-4 col-xs-12'),
                Div(Field('t_poststim'),
                    css_class='col-md-4 col-sm-4 col-xs-12'),
            )),
        HTML("<br><br><br>"),
        Fieldset(
            "",
            Div(
                HTML(
                    """<h5 style="margin-left: 15px">Duration of experiment</h5><p style="margin-left: 20px"> <ul><li><b>If you give duration</b>: number of trials = duration/(trialduration + mean ITI)</li><li><b>If you give number of trials</b>: duration = (trialduration + mean ITI)* number of trials</li></ul><br>"""
                ),
                Div(Field('durspec'),
                    css_class='col-md-12 col-sm-12 col-xs-12',
                    css_id="durspec")),
        ),
        HTML("<br>"),
        Fieldset(
            '',
            Div(Div(Field('duration_unitfree'),
                    css_class='col-md-6 col-sm-6 col-xs-12'),
                Div(Field('duration_unit'),
                    css_class='col-md-6 col-sm-6 col-xs-12'),
                css_class='row-md-12 col-xs-12',
                css_id="duration"),
            Div(Div(Field('L'), css_class='col-md-12 col-sm-12 col-xs-12'),
                css_class='row-md-12 col-xs-12',
                css_id="trialcount"),
        ),
        HTML("<br><br><br>"),
        Fieldset(
            "",
            Div(
                HTML(
                    """<br><h5 style="margin-left: 15px">Inter Trial Interval (ITI)</h5><p style="margin-left: 20px">The ITI's can be fixed or variable.   Variable ITI's can be sampled from a uniform model or a truncated exponential model.</p> <br>"""
                ),
                Div(Field('ITImodel'),
                    css_class='col-md-12 col-sm-12 col-xs-12',
                    css_id="ITImodel")),
        ),
        HTML("<br>"),
        Fieldset(
            '',
            Div(Div(Field('ITIunifmin'),
                    css_class='col-md-6 col-sm-6 col-xs-12'),
                Div(Field('ITIunifmax'),
                    css_class='col-md-6 col-sm-6 col-xs-12'),
                css_class='row-md-12 col-xs-12',
                css_id="uniform"),
            Div(Div(Field('ITItruncmin'),
                    css_class='col-md-4 col-sm-12 col-xs-12'),
                Div(Field('ITItruncmax'),
                    css_class='col-md-4 col-sm-12 col-xs-12'),
                Div(Field('ITItruncmean'),
                    css_class='col-md-4 col-sm-12 col-xs-12'),
                css_class='row-md-12 col-xs-12',
                css_id="exp"),
            Div(Div(Field('ITIfixed'),
                    css_class='col-md-12 col-sm-12 col-xs-12'),
                css_class='row-md-12 col-xs-12',
                css_id="fixed"),
        ),
        HTML("<br><br>"),
        Fieldset(
            '',
            HTML("""<h5 style="margin-left: 15px">Contrasts</h5>
            <p style="margin-left: 20px">How many contrasts do you want to optimise?  You can choose to include all pairwise comparisons.  You can also add custom contrasts (to be specified on the next page).  You can do both.</p>"""
                 ),
            Div(Div(Field('Call'), css_class='col-lg-3 col-sm-12'),
                css_class='row-lg-12'),
            Div(Div(Field('Clen'), css_class='col-lg-12'),
                css_class='row-md-12 col-xs-12'),
        ),
        HTML("<br><br>"),
        Fieldset(
            '',
            HTML("""<h5 style="margin-left: 15px">Rest blocks</h5>
            <p style="margin-left: 20px">Do you want to include rest blocks? If not: leave these boxes empty.</p><br> """
                 ),
            Div(Div(Field('RestNum'), css_class='col-md-4 col-sm-6 col-xs-12'),
                Div(Field('RestDur'), css_class='col-md-4 col-sm-6 col-xs-12'),
                css_class='row-md-12 col-xs-12')),
        HTML("<br><br><br><br>"),
        # Fieldset(
        #     '',
        #     HTML("""<h5 style="margin-left: 15px">Nested designs: Is there a specific structure amongst the stimulus types?</h5>
        #     <p style="margin-left: 20px"><b>Example:</b> A researcher designs a task with two condition (congruent and incongruent).  Within those conditions, the subject is presented with either a go signal or a stop signal (no go).  As such the condition <b>go/no go</b> is nested within the condition <b>congruency</b>.</p>
        #     <p style="margin-left: 20px"><b>How to specify your structure?</b> Please provide the total number of stimulus types above at the lowest level.  For the stop signal example above, you have a total of 4 stimuli (congruent stop, congruent go, incongruent stop, incongruent go).  On the next page, you will be asked to group those stimuli in classes.</p>
        #     <!-- <p style="margin-left: 20px"><b>Why is this important?</b> In the design optimisation, you want to avoid psychological confounds: if congruent always follows congruent, the experiment is predictable and this can influence your results.  If you don't specify the nested structure, the algorithm will avoid the predictability of all stimuli, but not of the stimulus classes.  For example: the algorithm will avoid that a 'congruent stop' follows 'congruent go' as much as it follows 'incongruent stop'.  However, the algorithm will not avoid that 'congruent' follows 'congruent' more than 'incongruent'.  By specifying the nesting structure, the algorithm will avoid psychological confounding on all levels of the nested design.</p>
        #     <p style = 'margin-left: 20px'><b>Symmetry.</b>  We call a symmetric design if all conditions nested within amother condition are the same.  In the example above: both the congruent and the incongruent trials are presented with a go or a no go trial.  Failing to ticking this box for a symmetric design would lead to the fact that the psychological confounding is preserved for the upper level (congruent vs. noncongruent), but not for the lower level (go vs. no go).</p> -->
        #     """),
        #     Div(
        #     Div(Field('nested'),css_class='col-lg-3 col-sm-12'),
        #     css_class='row-md-12 col-xs-12'
        #     ),
        #     # Div(
        #     # Div(Field('nest_symmetry'),css_class='col-lg-3 col-sm-12'),
        #     # css_class='row-md-12 col-xs-12'
        #     # ),
        #     Div(
        #     Div(Field('nest_classes'),css_class='col-lg-12'),
        #     css_class='row-md-12 col-xs-12'
        #     ),
        #     ),
        # HTML("<br><br>"),
        Fieldset(
            'Design optimisation parameters',
            HTML(
                """<p>There are 4 criteria that quantify the optimality of the design:</p>
            <ol>
            <li> Estimation efficiency (estimating the HRF)
                <img src="../../static/img/info.png" data-toggle="tooltip" data-placement="right" title="A possible goal of the research is to estimate the exact shape of the signal (the HRF) after a stimulus has been presented.  This can be interesting for research into how the HRF varies accross subjects/regions/...  This outcome is also desirable when estimating connectivity between region/time series.  The optimisation algorithm will improve the likeliness to have a good estimate of the brain response at following a stimulus with a good temporal resolution." style="width:10px;"/>
            </li>
            <li> Detection power (activation detection)
                <img src="../../static/img/info.png" data-toggle="tooltip" data-placement="right" title="A potential goal of an fMRI study is to detect brain activation related to a certain task.  The keyword is contrast.  For example: the researcher wants to find which part of the brain is responsible for the contrast between seeing faces and houses, the contrast between angry and happy faces, or the contrast between auditory stimulation and nothing (baseline).  In this case, the optimisation algorithm will improve the statistical separation between the modeled conditions." style="width:10px;"/>
            </li>
            <li> Final frequencies of each trial type
                <img src="../../static/img/info.png" data-toggle="tooltip" data-placement="right" title="Sometimes, you can get higher detection power or estimation efficiency when the frequencies of the stimuli are slightly changed.  For example: in a stop-signal experiment, you want 30% of the stimuli to be stop-trials and 70% to be go-trials.  However, the genetic algorithm has a better detection power when the frequencies are changed from 30-70 to 25-75%.  In certain tasks (like a  basic stop-signal task), changing these frequencies can have a large psychological impact and you want to avoid changing the frequencies." style="width:10px;"/>
            </li>
            <li> Avoiding psychological confounds
                <img src="../../static/img/info.png" data-toggle="tooltip" data-placement="right" title="When a subject in the scanner can predict which stimulus will follow, the effect of that stimulus might be biased.  As such, it is important to avoid certain contingencies." style="width:10px;"/>
            </li>
            </ol>
            <p>Please provide the weights that you want to give to each of the design criteria.</p>
            <p> Ideally, the weights sum to 1.  If not, they will be rescaled as such. <br><br>"""
            ),
            Div(Div(Field('W1'), css_class='col-md-3 col-sm-6 col-xs-12'),
                Div(Field('W2'), css_class='col-md-3 col-sm-6 col-xs-12'),
                Div(Field('W3'), css_class='col-md-3 col-sm-6 col-xs-12'),
                Div(Field('W4'), css_class='col-md-3 col-sm-6 col-xs-12'),
                css_class='row-md-12 col-xs-12')),
        HTML("<br><br><br>"),
        Fieldset(
            'Design specifications to avoid psychological confounding',
            HTML(
                """<h5 style="margin-left: 15px">Trial contingencies</h><br><br>"""
            ),
            HTML(
                '''<p>To prevent predictability of the design, you can control the contingencies in the design. Eg. </p>
            <ul>
            <li> Order 1: <b>P(AA) = P(BA)</b>.</li>
            <li> Order 2: <b>P(AxA) = P(BxA)</b></li>
            <li> Order 3: <b>P(AxxA) = P(BxxA)</b></li>
            <li> ... </li>
            </ul>
            <p> To which order do you wish to control the contingencies (maximum 10)? In other words: how far back do you want to control the predictability?  </p>
            '''),
            Div(Div(Field('ConfoundOrder'), css_class='col-xs-12'),
                css_class='row-md-12 col-xs-12'),
            HTML(
                """<br><br><br><br><h5 style="margin-left: 15px">Trial blockedness</h><br><br>"""
            ),
            HTML(
                '''<p>To prevent predictability of the design, you can control the number of times a stimulus type is repeated. </p>
            '''),
            Div(Div(Field('MaxRepeat'), css_class='col-xs-12'),
                css_class='row-md-12 col-xs-12'),
            HTML("""<br><br><br><br><br>"""),
            FormActions(
                Submit('Submit', 'Save and next', css_class='btn-black')),
            HTML("""<br><br><br><br><br>""")))