-
Notifications
You must be signed in to change notification settings - Fork 1
/
forms.py
50 lines (43 loc) · 1.88 KB
/
forms.py
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
from django.forms import ModelForm
from django import forms
from .models import BatchTest, BatchNote, BatchAddition
class DateTimeWidget(forms.DateTimeInput):
input_type = "datetime-local"
def __init__(self,**kwargs):
kwargs["format"] = "%Y/%m/%dT%H:%M"
super().__init__(**kwargs)
class BatchTestForm(ModelForm):
class Meta:
model = BatchTest
fields = "__all__"
def __init__(self,*args,**kwargs):
super().__init__(*args,**kwargs)
self.fields["datetime"].widget = DateTimeWidget()
self.fields["datetime"].input_formats = ["%Y-%m-%dT%H:%M", "%Y-%m-%d %H:%M"]
class BatchNoteForm(ModelForm):
class Meta:
model = BatchNote
fields = "__all__"
def __init__(self,*args,**kwargs):
super().__init__(*args,**kwargs)
self.fields["date"].widget = DateTimeWidget()
self.fields["date"].input_formats = ["%Y-%m-%dT%H:%M", "%Y-%m-%d %H:%M"]
class BatchAdditionForm(ModelForm):
class Meta:
model = BatchAddition
fields = "__all__"
class RefractometerCorrectionForm(forms.Form):
unitChoices = (
('sg', "Specific Gravity"),
('bx', "Brix")
)
startData = forms.FloatField(help_text="Enter starting measurement",
label="Starting Measurement",
initial=0.0)
startUnit = forms.ChoiceField(choices=unitChoices, help_text="Choose starting unit type of measurement",
label="Starting Measurement Unit")
currentData = forms.FloatField(help_text="Enter current measurement",
label="Current Measurement",
initial=0.0)
currentUnit = forms.ChoiceField(choices=unitChoices, help_text="Choose current unit type of measurement",
label="Current Measurement Unit")