コード例 #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)
コード例 #2
0
ファイル: forms.py プロジェクト: ashyhanov/hawc
 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)
コード例 #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)
コード例 #4
0
ファイル: views.py プロジェクト: Firstyear/drinks
 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
コード例 #5
0
ファイル: forms.py プロジェクト: humbcezar/testing-goat
 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}}
コード例 #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']
コード例 #7
0
ファイル: forms.py プロジェクト: code4history/django-chime
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
コード例 #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'
        ]
コード例 #9
0
 def get_custom_widget(self):
     """
     retorna o widget desse field
     """
     return TextInput(attrs={'class': 'upper'})