File: forms.py

package info (click to toggle)
python-django-pint 0.7.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 432 kB
  • sloc: python: 1,531; makefile: 28; sh: 12
file content (117 lines) | stat: -rw-r--r-- 2,802 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
from django import forms

from quantityfield.fields import (
    DecimalQuantityFormField,
    IntegerQuantityFormField,
    QuantityFormField,
)
from tests.dummyapp.models import (
    BigIntFieldSaveModel,
    DecimalFieldSaveModel,
    FloatFieldSaveModel,
    IntFieldSaveModel,
)


class DefaultFormFloat(forms.ModelForm):
    weight = QuantityFormField(base_units="gram", unit_choices=["ounce", "gram"])

    class Meta:
        model = FloatFieldSaveModel
        fields = "__all__"


class DefaultFormInt(forms.ModelForm):
    weight = IntegerQuantityFormField(base_units="gram", unit_choices=["ounce", "gram"])

    class Meta:
        model = IntFieldSaveModel
        fields = "__all__"


class DefaultFormBigInt(forms.ModelForm):
    weight = IntegerQuantityFormField(base_units="gram", unit_choices=["ounce", "gram"])

    class Meta:
        model = BigIntFieldSaveModel
        fields = "__all__"


class DefaultFormDecimal(forms.ModelForm):
    weight = DecimalQuantityFormField(base_units="gram", unit_choices=["ounce", "gram"])

    class Meta:
        model = DecimalFieldSaveModel
        fields = "__all__"


class DefaultFormFieldsFloat(forms.ModelForm):
    weight = forms.FloatField()

    class Meta:
        model = FloatFieldSaveModel
        fields = "__all__"


class DefaultFormFieldsDecimal(forms.ModelForm):
    weight = forms.FloatField()

    class Meta:
        model = DecimalFieldSaveModel
        fields = "__all__"


class DefaultFormFieldsInt(forms.ModelForm):
    weight = forms.IntegerField()

    class Meta:
        model = IntFieldSaveModel
        fields = "__all__"


class DefaultFormFieldsBigInt(forms.ModelForm):
    weight = forms.IntegerField()

    class Meta:
        model = BigIntFieldSaveModel
        fields = "__all__"


class DefaultWidgetsFormFloat(forms.ModelForm):
    weight = QuantityFormField(
        base_units="gram", unit_choices=["ounce", "gram"], widget=forms.NumberInput
    )

    class Meta:
        model = FloatFieldSaveModel
        fields = "__all__"


class DefaultWidgetsFormDecimal(forms.ModelForm):
    weight = QuantityFormField(
        base_units="gram", unit_choices=["ounce", "gram"], widget=forms.NumberInput
    )

    class Meta:
        model = DecimalFieldSaveModel
        fields = "__all__"


class DefaultWidgetsFormInt(forms.ModelForm):
    weight = IntegerQuantityFormField(
        base_units="gram", unit_choices=["ounce", "gram"], widget=forms.NumberInput
    )

    class Meta:
        model = IntFieldSaveModel
        fields = "__all__"


class DefaultWidgetsFormBigInt(forms.ModelForm):
    weight = IntegerQuantityFormField(
        base_units="gram", unit_choices=["ounce", "gram"], widget=forms.NumberInput
    )

    class Meta:
        model = BigIntFieldSaveModel
        fields = "__all__"