Ejemplo n.º 1
0
 def __init__(self, *args, **kwargs):
     #email field not hidden
     super(SinglePhaseUserRegForm, self).__init__(*args, **kwargs)
     self.fields['email'].widget = TextInput(
         attrs=self.fields['email'].widget.attrs)
     self.fields['confirm_email'].widget = TextInput(
         attrs=self.fields['confirm_email'].widget.attrs)
Ejemplo n.º 2
0
 def setHelper(self):
     self.fields['title'].widget = TextInput()
     self.fields['authors'].widget = TextInput()
     self.fields['journal'].widget = TextInput()
     self.fields['abstract'].widget.attrs['rows'] = 3
     inputs = {
         "legend_text": u"Create a new study",
         "help_text": u"",
         "cancel_url": reverse('study:list',
                               args=[self.instance.assessment.id])
     }
     return super(ReferenceStudyForm, self).setHelper(inputs)
Ejemplo n.º 3
0
 def setHelper(self):
     self.fields["title"].widget = TextInput()
     self.fields["authors"].widget = TextInput()
     self.fields["journal"].widget = TextInput()
     self.fields["abstract"].widget.attrs["rows"] = 3
     inputs = {
         "legend_text":
         "Create a new study",
         "help_text":
         "",
         "cancel_url":
         reverse("study:list", args=[self.instance.assessment.id]),
     }
     return super().setHelper(inputs)
Ejemplo n.º 4
0
 def get_form_class(self):
     if self.batch is None:
         form = modelform_factory(Comment,
                                  fields=('batch', 'viewpoint'),
                                  widgets={'batch': TextInput()})
     else:
         form = modelform_factory(Comment, fields=('viewpoint', ))
     print(dir(form))
     form.base_fields['viewpoint'].widget.attrs['cols'] = 33
     form.base_fields['viewpoint'].widget.attrs['rows'] = 6
     return form
Ejemplo n.º 5
0
 class Meta:
     model = Item
     fields = ('text', )
     widgets = {
         'text':
         TextInput(
             attrs={
                 'placeholder': 'Enter a to-do item',
                 'class': 'form-control input-lg',
             }),
     }
     error_messages = {'text': {'required': EMPTY_ITEM_ERROR}}
Ejemplo n.º 6
0
class ProfileForm(ModelForm):

    command = CharField(label="Command Line",
                        widget=TextInput(attrs={'class': ''}))

    def __init__(self, *args, **kwargs):
        super(ProfileForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-lg-2'
        self.helper.field_class = 'col-lg-8'
        self.helper.layout = Layout(
            'name', 'tool', 'command', 'description',
            FormActions(Submit('add', 'Add Profile'),
                        Button('cancel', 'Cancel')))

    class Meta:
        model = Profile
        fields = ['name', 'tool', 'command', 'description']
Ejemplo n.º 7
0
class PercentageField(FloatField):
    '''
    custom percentage field
    '''

    widget = TextInput(attrs={"class": "percentInput"})

    def to_python(self, value):
        v = super().to_python(value)

        if is_number(v):
            return v / 100

        return v

    def prepare_value(self, value):
        v = super().prepare_value(value)

        if is_number(v) and not isinstance(v, str):
            return str((float(v) * 100))

        return v
Ejemplo n.º 8
0
class ScanForm(ModelForm):

    start_date = CharField(widget=HiddenInput())
    stop_date = CharField(widget=HiddenInput())
    scan_range = CharField(label="Scan Range",
                           widget=TextInput(attrs={'class': 'dtrange'}))

    def __init__(self, *args, **kwargs):
        super(ScanForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.help_text_inline = True
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-lg-2'
        self.helper.field_class = 'col-lg-8'
        self.helper.layout = Layout(
            TabHolder(
                Tab('Details', 'name', 'profile', 'group', 'hosts'),
                Tab(
                    'Options',
                    'chunk_size',
                    'scanner_count',
                    'scan_hours',
                    'scan_range',
                    'start_date',
                    'end_date',
                ), Tab('Deconfliction', 'deconfliction_message', 'htaccess')),
            FormActions(Submit('create', 'Create Scan'),
                        Button('cancel', 'Cancel')))

    class Meta:
        model = Scan
        fields = [
            'name', 'hosts', 'profile', 'group', 'chunk_size', 'scanner_count',
            'deconfliction_message', 'scan_hours', 'start_date', 'stop_date',
            'htaccess'
        ]
Ejemplo n.º 9
0
 def get_custom_widget(self):
     """
     retorna o widget desse field
     """
     return TextInput(attrs={'class': 'upper'})