示例#1
0
class FilesForm(forms.Form):
    Size = forms.IntegerField(widget=NumberInput(
        attrs={
            'type': 'range',
            'step': '1',
            'min': '1',
            'max': '5'
        }))
    Price = forms.IntegerField(widget=NumberInput(
        attrs={
            'type': 'range',
            'step': '1',
            'min': '1',
            'max': '5'
        }))
    Group = forms.ChoiceField(choices=GROUP_CHOICES,
                              widget=forms.RadioSelect())
    Level = forms.ChoiceField(choices=LEVEL_CHOICES,
                              widget=forms.RadioSelect())
    Continent = forms.ChoiceField(choices=CONTINENT_CHOICES,
                                  widget=forms.RadioSelect())
    '''Continent = forms.ModelMultipleChoiceField(queryset=qs, widget=Select2Multiple(
        select2attrs={'width': 'auto'}
    ))'''
    '''text1 = forms.CharField()
示例#2
0
 class Meta:
     model = Potenciales
     fields = [
         'nombre',
         'apellido',
         'celular',
         'telefono_h',
         'estado',
         'municipio',
         'parroquia',
     ]
     widgets = {
         'estado':
         Select2Widget(attrs={'class': 'django-select2 form-control'}),
         'municipio':
         Select2Widget(attrs={'class': 'django-select2 form-control'}),
         'parroquia':
         Select2Widget(attrs={'class': 'django-select2 form-control'}),
         'celular':
         NumberInput(attrs={'class': 'form-control'}),
         'telefono_h':
         NumberInput(attrs={'class': 'form-control'}),
         'nombre':
         TextInput(attrs={
             'class': 'form-control',
             'required': 'True'
         }),
         'apellido':
         TextInput(attrs={
             'class': 'form-control',
             'required': 'True'
         }),
     }
示例#3
0
 class Meta:
     model = Barcos
     fields = '__all__'
     labels = {
         'id_socio': 'Datos del socio',
         'nom_barco': 'Nom. del barco',
         'num_amarre': 'Num. de amarre',
         'num_cuota': 'Num. de cuota'
     }
     widgets = {
         'id_socio':
         Select(attrs={
             'class': 'form-control',
             'autocomplete': 'off'
         }),
         'nom_barco':
         TextInput(attrs={
             'class': 'form-control',
             'autocomplete': 'off'
         }),
         'num_amarre':
         NumberInput(attrs={
             'class': 'form-control',
             'autocomplete': 'off'
         }),
         'num_cuota':
         NumberInput(attrs={
             'class': 'form-control',
             'autocomplete': 'off'
         }),
     }
示例#4
0
 class Meta:
     model = Metrics
     fields = [
         'algorithm_version', 'molecule', 'gate_depth', 'qubit_count',
         'average_iterations', 'success_rate'
     ]
     widgets = {
         'algorithm_version': HiddenInput(),
         'gate_depth': NumberInput(attrs={
             'min': 0,
             'max': 1000000
         }),
         'qubit_count': NumberInput(attrs={
             'min': 0,
             'max': 1000000
         }),
         'averaget_iterations': NumberInput(attrs={
             'min': 0,
             'max': 1000000
         }),
         'success_rate': NumberInput(attrs={
             'min': 0,
             'max': 1000000
         }),
     }
示例#5
0
 class Meta:
     model = Item
     exclude = ['order']
     widgets = {
         'product':
         Select(
             attrs={
                 'oninput': 'dynamic_product(this)',
                 'class': 'form-control form-control-sm'
             }),
         'price':
         NumberInput(
             attrs={
                 'oninput': 'dynamic_total(this)',
                 'min': '0',
                 'class': 'form-control form-control-sm price'
             }),
         'quantity':
         NumberInput(
             attrs={
                 'oninput': 'dynamic_total(this)',
                 'class': 'form-control form-control-sm quantity'
             }),
         'rentability':
         Select(attrs={
             'readonly': True,
             'class': 'form-control form-control-sm'
         })
     }
示例#6
0
 def __init__(self, attrs=None):
     self.widgets = [
         NumberInput(attrs={'label': 'Day'}),
         NumberInput(attrs={'label': 'Month'}),
         NumberInput(attrs={'label': 'Year'}),
     ]
     super(MultiWidget, self).__init__(attrs)
示例#7
0
class StruggleModelForm(ModelForm):
    frustration_level = forms.IntegerField(
        label='Frustration level (rate 0 to 10)',
        widget=NumberInput(attrs={
            'type': 'range',
            'step': '1',
            'max': '10',
            'min': '0',
            'value': '5'
        }))
    learning_level = forms.IntegerField(
        required=False,
        label='Learning level (rate 0 to 10)',
        widget=NumberInput(attrs={
            'type': 'range',
            'step': '1',
            'max': '10',
            'min': '0',
            'value': '5'
        }))
    struggle = forms.CharField(widget=forms.Textarea(
        attrs={'placeholder': 'Enter your struggle here...'}))
    plan = forms.CharField(widget=forms.Textarea(
        attrs={'placeholder': 'Enter your plan here...'}))

    class Meta:
        model = StruggleData
        fields = [
            'title', 'struggle', 'plan', 'frustration_level', 'learning_level',
            'code_screen_shot', 'review_learning', 'struggle_in_progess',
            'code_screen_shot_update', 'helpful_link'
        ]
        ordering = ['-priority', 'time_started']
示例#8
0
    class Meta:
        model = Voluntario

        fields = [
            'cedula', 'nombres', 'apellidos', 'edad', 'sexo',
            'fecha_nacimiento', 'convencional', 'celular', 'correo',
            'direccion', 'ocupacion', 'carrera', 'institucion', 'idioma',
            'fecha_ingreso', 'estado', 'referencia'
        ]
        widgets = {
            'convencional':
            NumberInput(),
            'celular':
            NumberInput(),
            'fecha_nacimiento':
            DateInput(attrs={
                'class': 'mdl-color-text--orange',
                'type': 'date'
            }),
            'fecha_ingreso':
            DateInput(attrs={
                'class': 'mdl-color-text--orange',
                'type': 'date'
            }),
            'correo':
            EmailInput(attrs={'type': 'email'}),
        }

        help_texts = {'cedula': 'Cedula Ecuatoriana'}
    def __init__(self, attrs=None):
        freqChoices = [(3, "Daily"),
                       (2, "Weekly"),
                       (1, "Monthly"),
                       (0, "Yearly")]
        ordChoices  = [(1, "The First"),
                       (2, "The Second"),
                       (3, "The Third"),
                       (4, "The Fourth"),
                       (5, "The Fifth"),
                       (-1, "The Last"),
                       (_EveryDay, "Every"),
                       (_SameDay, "The Same")]
        dayChoices1  = enumerate(calendar.day_abbr)
        dayChoices2  = list(enumerate(calendar.day_name)) +\
                       [(_DayOfMonth, "Day of the month")]
        monthChoices = enumerate(calendar.month_name[1:], 1)

        numAttrs = {'min': 1, 'max': 366}
        if attrs:
            numAttrs.update(attrs)
        widgets = [AdminDateInput(attrs=attrs),
                   Select(attrs=attrs, choices=freqChoices), #1
                   NumberInput(attrs=numAttrs),
                   CheckboxSelectMultiple(attrs=attrs, choices=dayChoices1),
                   NumberInput(attrs=numAttrs),
                   AdminDateInput(attrs=attrs),              #5
                   Select(attrs=attrs, choices=ordChoices),
                   Select(attrs=attrs, choices=dayChoices2),
                   Select(attrs=attrs, choices=monthChoices) ]
        super().__init__(widgets, attrs)
示例#10
0
 class Meta:
     model = Problem
     fields = "__all__"
     widgets = {
         "epochs": NumberInput(attrs={"min": 50, "max": 10000}),
         "gamma": NumberInput(attrs={"min": 0.0, "max": 1.0, "step": ".01"}),
         "alpha": NumberInput(attrs={"min": 0.0, "max": 1.0, "step": ".01"}),
     }
示例#11
0
 class Meta:
     model = Orders
     fields = ('amount', 'rate', 'pair')
     widgets = {
             "amount":NumberInput(attrs={"class":"buyBtcInp"}),
             "rate":NumberInput(attrs={"class":"buyBtcInp"}),
             "pair":HiddenInput(),
         }
示例#12
0
 class Meta:
     model = Person
     fields = ('holidayNum', 'holidayNumSum', 'holidayNumUsed')
     widgets = {
         'holidayNum': NumberInput(attrs={'name': '现有倒休'}),
         'holidayNumSum': NumberInput(attrs={'name': '历史倒休和'}),
         'holidayNumUsed': NumberInput(attrs={'name': '已使用的倒休'})
     }
class CreateStoreForm(forms.Form):
    store_name = forms.CharField(widget=TextInput(attrs={'placeholder' : 'Store Name'}), label=False)
    website = forms.CharField(widget=TextInput(attrs={"placeholder" : "Company's Website"}), label=False)
    address = forms.CharField(widget=TextInput(attrs={'placeholder' : 'Street Address'}), label=False, required=False)
    city = forms.CharField(widget=TextInput(attrs={'placeholder' : 'City'}), label=False, required=False)
    state = forms.CharField(widget=TextInput(attrs={'placeholder' : 'MO'}), label=False, required=False)
    zip = forms.IntegerField(widget=NumberInput(attrs={'placeholder' : 'Postal Zip Code'}), label=False, required=False)
    phone_num = forms.IntegerField(widget=NumberInput(attrs={'placeholder' : 'Customer Service Phone Number'}), label=False, required=False)
    email = forms.EmailField(widget=EmailInput(attrs={'placeholder': 'Customer Service Email'}), label=False, required=False)
    is_credit_union = forms.BooleanField(label='Is this a Credit Union', required=False)
示例#14
0
class DateDropDownInputForm(forms.Form, BaseFormFieldPluginForm):
    """
    Form for ``DateDropDownInputPlugin``.
    """
    plugin_data_fields = [
        ("label", ""),
        ("name", ""),
        ("help_text", ""),
        ("year_min", ""),
        ("year_max", ""),
        ("initial", ""),
        ("input_formats", ""),
        ("required", False),
    ]

    label = forms.CharField(
        label = _("Label"),
        required = True,
        widget = forms.widgets.TextInput(attrs={'class': theme.form_element_html_class})
        )
    name = forms.CharField(
        label = _("Name"),
        required = True,
        widget = forms.widgets.TextInput(attrs={'class': theme.form_element_html_class})
        )
    help_text = forms.CharField(
        label = _("Help text"),
        required = False,
        widget = forms.widgets.Textarea(attrs={'class': theme.form_element_html_class})
        )
    year_min = forms.IntegerField(
        label = _("Minimum year value"),
        required = False,
        widget = NumberInput(attrs={'class': theme.form_element_html_class})
        )
    year_max = forms.IntegerField(
        label = _("Maximum year value"),
        required = False,
        widget = NumberInput(attrs={'class': theme.form_element_html_class})
        )
    initial = forms.CharField(
        label = _("Initial"),
        required = False,
        widget = forms.widgets.TextInput(attrs={'class': theme.form_element_html_class})
        )
    input_formats = forms.CharField(
        label = _("Input  formats"),
        required = False,
        widget = forms.widgets.TextInput(attrs={'class': theme.form_element_html_class})
        )
    required = forms.BooleanField(
        label = _("Required"),
        required = False,
        widget = forms.widgets.CheckboxInput(attrs={'class': theme.form_element_checkbox_html_class})
        )
示例#15
0
    def __init__(self, allow_null=False, attrs=None, mode=0):
        _widgets = (
            NumberInput(attrs=attrs),
            NumberInput(attrs=attrs),
        )

        if allow_null:
            self.allow_null = True
            _widgets += (CheckboxInput(), )

        super(RangeWidget, self).__init__(_widgets, attrs)
示例#16
0
    class Meta:
        model = ProductModel
        fields = ('product_code', 'product_name', 'product_description',
                  'pdt_category', 'pdt_sub_category', 'price', 'tax',
                  'discount', 'pdt_image')

        widgets = {
            'product_name':
            TextInput(attrs={
                'class': 'form-control',
                'style': 'width=80%'
            }),
            'product_code':
            TextInput(attrs={
                'class': 'form-control',
                'style': 'width=80%'
            }),
            'product_description':
            Textarea(attrs={
                'class': 'form-control',
                'style': 'width=80%'
            }),
            'pdt_category':
            Select(
                attrs={
                    'class': 'form-control',
                    'style': 'width=80%',
                    "id": "product_category_change"
                }),
            'pdt_sub_category':
            Select(
                attrs={
                    'class': 'form-control',
                    'style': 'width=80%',
                    "id": "product_subcategory_change"
                }),
            'price':
            NumberInput(attrs={
                'class': 'form-control',
                'style': 'width=80%'
            }),
            'tax':
            NumberInput(attrs={
                'class': 'form-control',
                'style': 'width=80%'
            }),
            'discount':
            NumberInput(attrs={
                'class': 'form-control',
                'style': 'width=80%'
            }),
            # 'pdt_image':ImageThumbnailFileInput(attrs={'class':'form-control','style':'width=80%'}),
        }
示例#17
0
 class Meta:
     model = Assessment
     exclude = ('patient', )
     widgets = {
         'visit_date':
         DateInput(attrs={'type': 'date'}),
         'height':
         NumberInput(attrs={'placeholder': 'In cm'}),
         'weight':
         NumberInput(attrs={'placeholder': 'In kgs'}),
         'temperature':
         NumberInput(attrs={'placeholder': 'In degrees celcius'}),
     }
 class Meta:
     model = Pain_Symptom
     exclude = ['symptom']
     widgets = {
         'bodyache_area': TextInput(attrs={'class': 'form-control', 'placeholder':'บริเวณ'}),
         'bodyache_date': NumberInput(attrs={'class': 'form-control', 'placeholder':'จำนวนวัน'}),
         'pain_score': NumberInput(attrs={'class': 'form-control', 'placeholder':'0 - 10'}),
         'ache_detail': TextInput(attrs={'class': 'form-control', 'placeholder':'ลักษณะการปวด'}),
         'trigger': TextInput(attrs={'class': 'form-control', 'placeholder':'สิ่งที่กระตุ้น/สิ่งที่บรรเทา'}),
         'crack': TextInput(attrs={'class': 'form-control', 'placeholder':'ร้าวไป'}),
         'others': Textarea(attrs={'class': 'form-control', 'cols':'6', 'rows':'10', 'placeholder':'อาการอื่นๆ'}),
         
     }
 class Meta:
     model = RapidInventory
     fields = [
         'diameters_diff_or_same', 'little_diam_nb', 'big_diam_nb',
         'biggest_tree_in_hands', 'canopy_density',
         'regeneration_appearance', 'regen_diff_leaves'
     ]
     widgets = {
         'biggest_tree_in_hands': NumberInput(attrs={
             'min': '0',
         }),
         'regen_diff_leaves': NumberInput(attrs={
             'min': '0',
         }),
     }
示例#20
0
 class Meta:
     model=Resume
     fields=['firstname','lastname','dateofbirth','style']#'__all__'
     widgets={
     'dateofbirth':DateInput(),
     'style': NumberInput(attrs={'type':'range', 'min':'1', 'max':'10'})
     }
def field_to_widget(field):
    if type(field) is CharField:
        if field.choices:
            return Select(attrs={"class": "form-control"})
        return TextInput(attrs={"class": "form-control", "rows": 1})
    if type(field) is TextField:
        return Textarea(attrs={"class": "form-control", "rows": 1})
    if type(field) is AutoField:
        return HiddenInput(attrs={"class": "form-control", "rows": 1})
    if type(field) is IntegerField or type(field) is FloatField:
        return NumberInput(attrs={"class": "form-control"})
    if type(field) is EmailField:
        return EmailInput(attrs={"class": "form-control"})
    if type(field) is ForeignKey:
        return Select(attrs={"class": "form-control"})
    if type(field) is ManyToManyField:
        return CheckboxSelectMultiple(attrs={"class": ""})
    if type(field) is BooleanField:
        return CheckboxInput(attrs={"class": "form-control"})
    if type(field) is FileField:
        return FileInput(attrs={"class": "form-control"})
    if type(field) is DateField:
        return DateInput(attrs={"class": "form-control date", "type": "date"})
    if type(field) is DateTimeField:
        return DateTimeInput(attrs={"class": "form-control datetimepicker"})

    return TextInput(attrs={"class": "form-control", "rows": 1})
示例#22
0
    def __init__(self, data=None, user=None, *args, **kwargs):
        if "default_user" in kwargs:
            default_user = kwargs.pop("default_user")
        else:
            default_user = "******"
        self.default_user = default_user

        super(QuickBookingForm, self).__init__(data=data, **kwargs)

        self.fields["image"] = forms.ModelChoiceField(
            Image.objects.filter(public=True)
            | Image.objects.filter(owner=user))

        self.fields['users'] = SearchableSelectMultipleField(
            queryset=UserProfile.objects.select_related('user').exclude(
                user=user),
            items=get_user_items(exclude=user),
            required=False,
            **get_user_field_opts())

        attrs = FormUtils.getLabData(0)
        self.fields['filter_field'] = MultipleSelectFilterField(
            widget=MultipleSelectFilterWidget(**attrs))
        self.fields['length'] = forms.IntegerField(widget=NumberInput(
            attrs={
                "type": "range",
                'min': "1",
                "max": "21",
                "value": "1"
            }))
示例#23
0
class BookingMetaForm(forms.Form):

    length = forms.IntegerField(
        widget=NumberInput(
            attrs={
                "type": "range",
                'min': "1",
                "max": "21",
                "value": "1"
            }
        )
    )
    purpose = forms.CharField(max_length=1000)
    project = forms.CharField(max_length=400)
    info_file = forms.CharField(max_length=1000, required=False)
    deploy_opnfv = forms.BooleanField(required=False)

    def __init__(self, *args, user_initial=[], owner=None, **kwargs):
        super(BookingMetaForm, self).__init__(**kwargs)

        self.fields['users'] = SearchableSelectMultipleField(
            queryset=UserProfile.objects.select_related('user').exclude(user=owner),
            initial=user_initial,
            items=get_user_items(exclude=owner),
            required=False,
            **get_user_field_opts()
        )
示例#24
0
    def render(self, name, value, attrs=None, renderer=None) -> str:
        try:
            year_val, month_val = value.year, value.month
        except AttributeError:
            now = datetime.datetime.now()
            year_val = now.year
            month_val = now.month

        output = []

        if 'id' in self.attrs:
            id_ = self.attrs['id']
        else:
            id_ = f'id_{name}'

        month_choices = list(MONTHS.items())
        if not (self.required and value):
            month_choices.append(self.none_value)
        month_choices.sort()
        local_attrs = self.build_attrs(base_attrs=self.attrs)
        s = Select(choices=month_choices)
        select_html = s.render(self.month_field % name, month_val, local_attrs)
        output.append(select_html)

        local_attrs['id'] = self.year_field % id_
        s = NumberInput()
        select_html = s.render(self.year_field % name, year_val, local_attrs)
        output.append(select_html)

        return mark_safe(u'\n'.join(output))
示例#25
0
class UserCreationForm(forms.ModelForm):
    """A form for creating new users. Includes all the required
    fields, plus a repeated password."""
    password1 = forms.CharField(label='Password', widget=forms.PasswordInput)
    password2 = forms.CharField(label='Password confirmation',
                                widget=forms.PasswordInput)
    date_of_birth = forms.DateField(label='Date of birth',
                                    widget=NumberInput(attrs={'type': 'date'}))

    class Meta:
        model = User
        fields = ('email', 'date_of_birth')

    def clean_password2(self):
        # Check that the two password entries match
        password1 = self.cleaned_data.get("password1")
        password2 = self.cleaned_data.get("password2")
        if password1 and password2 and password1 != password2:
            raise ValidationError("Passwords don't match")
        return password2

    def save(self, commit=True):
        # Save the provided password in hashed format
        user = super().save(commit=False)
        user.set_password(self.cleaned_data["password1"])
        if commit:
            user.save()
        return user
示例#26
0
文件: forms.py 项目: jarekj9/listjj
class NoteForm(forms.Form):
    """Form for adding new note"""
    def __init__(
        self, *args, **kwargs
    ):  # I need to access 'request.user' via constructor during object creation
        login = kwargs.pop("login")
        recent_category = None
        if "recent_category" in kwargs.keys():
            recent_category = kwargs.pop("recent_category")

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

        self.fields["category"].queryset = Categories.objects.filter(
            login=login)
        self.fields["value"] = forms.FloatField(initial=0)

        try:
            default_category = Categories.objects.get(
                login=login, id=login.profile.default_category.id)
        except AttributeError:  # profile.default_category does not exist yet
            default_category = (0, 0)
        if recent_category:
            default_category = Categories.objects.get(login=login,
                                                      category=recent_category)
        self.fields["category"].initial = default_category

    class Meta:  # because date variable is ignored in the Form (it is set in AddNoteView method)
        model = Journal
        exclude = ["date"]

    value = forms.FloatField(widget=NumberInput())
    category = CategoryModelChoiceField(
        required=True, widget=forms.Select, queryset=None,
        initial=0)  # queryset for category is set in constructor
    description = forms.CharField(max_length=100, widget=TextInput())
示例#27
0
class MembraneTopolForm(ModelForm):

    #version      = forms.CharField(label="Name",
    #                               required=False,
    #                               help_text="YearAuthor")
    equilibration = forms.IntegerField(label="Equilibration (ns)",
                                       widget=NumberInput(attrs={'style': 'width: 340px'}))
    mem_file      = forms.FileField(label="Membrane file")
    description   = forms.CharField(widget=Textarea(attrs={'style': 'width: 340px'}))

    class Meta:
        model = MembraneTopol
        #fields = ['version','forcefield','equilibration','mem_file','description','reference']
        fields = ['forcefield','equilibration','mem_file','description','reference']
        widgets = {
            'reference': autocomplete.ModelSelect2Multiple(
                url='reference-autocomplete',
                attrs={'style': 'width: 340px'},
            ),
            'forcefield': Select(
                attrs={'style': 'width: 340px'},
            )        
        }
        labels = {
            'reference': 'References'
        }
示例#28
0
class ProdForm(forms.Form):
    BDD_PARFUM = []
    choices = [
        ('Sorbet', [(n.id, n.parfum_text) for n in Parfum.objects.all().filter(
            sorbet=True).order_by('parfum_text')])
    ] + [('Glace', [(n.id, n.parfum_text) for n in Parfum.objects.all().filter(
        sorbet=False).order_by('parfum_text')])]
    parfum_text = forms.CharField(label="Parfum",
                                  required=True,
                                  widget=forms.Select(
                                      attrs={'class': 'form-control'},
                                      choices=choices))
    no_lot = forms.CharField(label="N° de lot",
                             initial="",
                             widget=TextInput(attrs={
                                 'size': 10,
                                 'class': 'form-control'
                             }))
    poids = forms.IntegerField(label="Poids (g)",
                               initial=1000,
                               widget=NumberInput(attrs={
                                   'size': 3,
                                   'class': 'form-control span2'
                               }))
    date_prod = forms.DateField(label='Date de production',
                                initial=datetime.now(),
                                widget=DatePickerInput(
                                    format='%d/%m/%Y',
                                    attrs={'class': 'form-control'}))
示例#29
0
class FrameAdmin(admin.ModelAdmin):
    def get_queryset(self, request):
        return super().get_queryset(request).with_sighting()

    formfield_overrides = {
        models.DateTimeField: {
            'widget': MicrosecondDateTimeWidget(),
        },
        models.FloatField: {
            'widget': NumberInput(attrs={
                'size': 10,
            })
        }
    }

    fieldsets = (
        ('Identity', {
            'fields': ('sighting', 'order'),
        }),
        ('Coordinates', {
            'fields': [
                ('timestamp'),
                ('x', 'y'),
                ('altitude', 'azimuth'),
            ]
        }),
        ('Photometry', {
            'fields': ('magnitude', ),
        }),
    )

    list_display = ['__str__', 'sighting', 'order', 'timestamp']
    list_display_links = ['__str__', 'sighting']
    readonly_fields = ['id']
    save_as = True
示例#30
0
文件: filters.py 项目: sree181/oldp
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        # No fancy widgets
        self.filters.get('court__jurisdiction').field.widget = TextInput()
        self.filters.get('court__level_of_appeal').field.widget = TextInput()
        self.filters.get('has_reference_to_law').field.widget = NumberInput()