예제 #1
0
class PointsForm(forms.ModelForm):
    lat = forms.DecimalField()
    lon = forms.DecimalField()

    class Meta:
        model = Points
        fields = (
            'nombre',
            'direccion',
            'ciudad',
            'pais',
            'horarios',
            'is_active',
            'celular',
            'telefono',
        )
예제 #2
0
파일: forms.py 프로젝트: Wokiri/nanostring
class QuantileSearchForm(forms.Form):
    quantile_value = forms.DecimalField(
        label='Search Quantile Value',
        required=False,
        decimal_places=2,
        min_value=0,
        max_value=1,
        widget=forms.NumberInput(attrs={'class': 'form-control mr-sm-1'}))
예제 #3
0
파일: forms.py 프로젝트: hcharp/geocontrib
    def __init__(self, *args, **kwargs):
        extra = kwargs.pop('extra', None)
        feature = kwargs.pop('feature', None)
        super().__init__(*args, **kwargs)

        for custom_field in extra.order_by('position'):
            if custom_field.field_type == 'boolean':
                self.fields[custom_field.name] = forms.BooleanField(
                    label=custom_field.label,
                    initial=False,
                    required=False,
                )

            if custom_field.field_type == 'char':
                self.fields[custom_field.name] = forms.CharField(
                    label=custom_field.label, max_length=256, required=False)

            if custom_field.field_type == 'date':
                self.fields[custom_field.name] = forms.DateField(
                    label=custom_field.label,
                    required=False,
                )

            if custom_field.field_type == 'integer':
                self.fields[custom_field.name] = forms.IntegerField(
                    label=custom_field.label, required=False)

            if custom_field.field_type == 'decimal':
                self.fields[custom_field.name] = forms.DecimalField(
                    label=custom_field.label,
                    required=False,
                    widget=forms.TextInput(attrs={'localization': False}))

            if custom_field.field_type == 'text':
                self.fields[custom_field.name] = forms.CharField(
                    label=custom_field.label,
                    required=False,
                    widget=forms.Textarea())

            if custom_field.field_type == 'list' and custom_field.options:
                self.fields[custom_field.name] = forms.ChoiceField(
                    label=custom_field.label,
                    choices=[(str(xx), str(xx))
                             for xx in custom_field.options],
                    required=False)

            self.fields[custom_field.name].widget.attrs.update(
                {'field_type': custom_field.field_type})

        if feature and isinstance(feature.feature_data, dict):
            for custom_field in extra:
                self.fields[
                    custom_field.name].initial = feature.feature_data.get(
                        custom_field.name)
예제 #4
0
class QueryPointForm(forms.Form):
    query_point = forms.PointField(widget=forms.OSMWidget(
        attrs={
            'map_width': 700,
            'map_height': 500,
            'default_lat': 40.304665,
            'default_lon': -3.723679,
            'default_zoom': 6
        }))
    distance = forms.DecimalField(max_digits=6,
                                  decimal_places=2,
                                  help_text='Distance in km.')