|
1 | 1 | from django import forms
|
2 | 2 | from django.core import validators
|
3 | 3 |
|
| 4 | + |
4 | 5 | class DatePickerInput(forms.DateInput):
|
5 |
| - input_type = 'date' |
| 6 | + input_type = "date" |
| 7 | + |
6 | 8 |
|
7 | 9 | class import_rc_data(forms.Form):
|
8 |
| - # csv_upload = forms.FileField(label="csv file", widget=forms.FileInput(attrs={'class': 'form-control form-control-sm'})) |
9 |
| - csv_upload = forms.FileField(label="csv file", widget=forms.FileInput(attrs={'class': 'form-control form-control-sm', 'style': 'font-size: 11.5px;'})) |
10 |
| - header_row = forms.IntegerField(label="header row number", widget=forms.NumberInput(attrs={'class': 'form-control form-control-sm', 'min':1, 'value':1, 'id':'form-header-row', 'style': 'font-size: 11.5px;'})) |
11 |
| - csv_upload.required = False |
12 |
| - header_row.required = False |
| 10 | + input_session_type = forms.ChoiceField( |
| 11 | + label="import type", |
| 12 | + widget=forms.Select( |
| 13 | + attrs={ |
| 14 | + "class": "form-control form-control-sm", |
| 15 | + "style": "font-size: 11.5px;", |
| 16 | + } |
| 17 | + ), |
| 18 | + choices=[ |
| 19 | + ("new", "new session"), |
| 20 | + ("load", "load previous session"), |
| 21 | + ], |
| 22 | + ) |
| 23 | + |
| 24 | + csv_content = forms.CharField( |
| 25 | + label="csv content", |
| 26 | + widget=forms.Textarea( |
| 27 | + attrs={ |
| 28 | + "class": "form-control form-control-sm", |
| 29 | + "style": "font-size: 11.5px; height: 200px;", |
| 30 | + } |
| 31 | + ), |
| 32 | + required=False, |
| 33 | + ) |
| 34 | + |
| 35 | + session_content = forms.CharField( |
| 36 | + label="session content", |
| 37 | + widget=forms.Textarea( |
| 38 | + attrs={ |
| 39 | + "class": "form-control form-control-sm", |
| 40 | + "style": "font-size: 11.5px; height: 200px;", |
| 41 | + } |
| 42 | + ), |
| 43 | + required=False, |
| 44 | + ) |
| 45 | + |
| 46 | + csv_separator = forms.ChoiceField( |
| 47 | + label="separator", |
| 48 | + widget=forms.Select( |
| 49 | + attrs={ |
| 50 | + "class": "form-control form-control-sm", |
| 51 | + "style": "font-size: 11.5px;", |
| 52 | + } |
| 53 | + ), |
| 54 | + choices=[ |
| 55 | + (",", "comma"), |
| 56 | + (";", "semicolon"), |
| 57 | + ("\t", "tab"), |
| 58 | + ], |
| 59 | + ) |
| 60 | + |
| 61 | + header_row = forms.IntegerField( |
| 62 | + label="header row number", |
| 63 | + widget=forms.NumberInput( |
| 64 | + attrs={ |
| 65 | + "class": "form-control form-control-sm", |
| 66 | + "min": 1, |
| 67 | + "value": 1, |
| 68 | + "id": "form-header-row", |
| 69 | + "style": "font-size: 11.5px;", |
| 70 | + } |
| 71 | + ), |
| 72 | + ) |
| 73 | + |
13 | 74 |
|
14 | 75 | class develop_rc(forms.Form):
|
15 |
| - set_offset1 = forms.FloatField(label="offset 1", widget=forms.NumberInput(attrs={'class': 'form-control form-control-sm', 'id':'offset1', 'style': 'font-size: 11.5px;'})) |
16 |
| - set_offset2 = forms.FloatField(label="offset 2", widget=forms.NumberInput(attrs={'class': 'form-control form-control-sm', 'id':'offset2', 'style': 'font-size: 11.5px;'})) |
17 |
| - set_breakpoint1 = forms.IntegerField(label="number of breakpoints", widget=forms.NumberInput(attrs={'class form-control-sm': 'form-control','id':'breakpoint1', 'value':1, 'style': 'font-size: 11.5px;'})) |
18 |
| - set_breakpoint2 = forms.IntegerField(label="number of breakpoints", widget=forms.NumberInput(attrs={'class form-control-sm': 'form-control', 'id':'breakpoint2', 'value':1, 'style': 'font-size: 11.5px;'})) |
| 76 | + set_offset1 = forms.FloatField( |
| 77 | + label="offset 1", |
| 78 | + widget=forms.NumberInput( |
| 79 | + attrs={ |
| 80 | + "class": "form-control form-control-sm", |
| 81 | + "id": "offset1", |
| 82 | + "style": "font-size: 11.5px;", |
| 83 | + } |
| 84 | + ), |
| 85 | + ) |
| 86 | + set_offset2 = forms.FloatField( |
| 87 | + label="offset 2", |
| 88 | + widget=forms.NumberInput( |
| 89 | + attrs={ |
| 90 | + "class": "form-control form-control-sm", |
| 91 | + "id": "offset2", |
| 92 | + "style": "font-size: 11.5px;", |
| 93 | + } |
| 94 | + ), |
| 95 | + ) |
| 96 | + set_breakpoint1 = forms.IntegerField( |
| 97 | + label="number of breakpoints", |
| 98 | + widget=forms.NumberInput( |
| 99 | + attrs={ |
| 100 | + "class form-control-sm": "form-control", |
| 101 | + "id": "breakpoint1", |
| 102 | + "value": 1, |
| 103 | + "style": "font-size: 11.5px;", |
| 104 | + } |
| 105 | + ), |
| 106 | + ) |
| 107 | + set_breakpoint2 = forms.IntegerField( |
| 108 | + label="number of breakpoints", |
| 109 | + widget=forms.NumberInput( |
| 110 | + attrs={ |
| 111 | + "class form-control-sm": "form-control", |
| 112 | + "id": "breakpoint2", |
| 113 | + "value": 1, |
| 114 | + "style": "font-size: 11.5px;", |
| 115 | + } |
| 116 | + ), |
| 117 | + ) |
| 118 | + |
19 | 119 |
|
20 | 120 | class export_rc_data(forms.Form):
|
21 |
| - export_filetype = forms.ChoiceField(label='export type', widget=forms.Select(attrs={'class': 'form-control form-control-sm', 'style': 'font-size: 11.5px;'}), choices=[('session settings', 'session settings'), ('session results (pdf)', 'session results (pdf)'), ('session results (csv)', 'session results (csv)')]) |
22 |
| - export_filetype.widget.attrs['onchange'] = 'toggleExportForm(this.value)' |
23 |
| - export_filename = forms.CharField(label="file name", widget=forms.TextInput(attrs={'class': 'form-control form-control-sm', 'style': 'font-size: 11.5px;' }), max_length=200) |
24 |
| - export_station_name = forms.CharField(label="station name", widget=forms.TextInput(attrs={'class': 'form-control form-control-sm', 'style': 'font-size: 11.5px;'}), max_length=200) |
| 121 | + export_filetype = forms.ChoiceField( |
| 122 | + label="export type", |
| 123 | + widget=forms.Select( |
| 124 | + attrs={ |
| 125 | + "class": "form-control form-control-sm", |
| 126 | + "style": "font-size: 11.5px;", |
| 127 | + } |
| 128 | + ), |
| 129 | + choices=[ |
| 130 | + ("session settings", "session settings"), |
| 131 | + ("session results (pdf)", "session results (pdf)"), |
| 132 | + ("session results (csv)", "session results (csv)"), |
| 133 | + ], |
| 134 | + ) |
| 135 | + export_filetype.widget.attrs["onchange"] = "toggleExportForm(this.value)" |
| 136 | + export_filename = forms.CharField( |
| 137 | + label="file name", |
| 138 | + widget=forms.TextInput( |
| 139 | + attrs={ |
| 140 | + "class": "form-control form-control-sm", |
| 141 | + "style": "font-size: 11.5px;", |
| 142 | + } |
| 143 | + ), |
| 144 | + max_length=200, |
| 145 | + ) |
| 146 | + export_station_name = forms.CharField( |
| 147 | + label="station name", |
| 148 | + widget=forms.TextInput( |
| 149 | + attrs={ |
| 150 | + "class": "form-control form-control-sm", |
| 151 | + "style": "font-size: 11.5px;", |
| 152 | + } |
| 153 | + ), |
| 154 | + max_length=200, |
| 155 | + ) |
25 | 156 | export_station_name.required = False
|
26 |
| - export_comments = forms.CharField(label="comments", widget=forms.Textarea(attrs={'class': 'form-control form-control-sm', 'style': 'font-size: 11.5px; height:60px;'}), max_length=1000) |
| 157 | + export_comments = forms.CharField( |
| 158 | + label="comments", |
| 159 | + widget=forms.Textarea( |
| 160 | + attrs={ |
| 161 | + "class": "form-control form-control-sm", |
| 162 | + "style": "font-size: 11.5px; height:60px;", |
| 163 | + } |
| 164 | + ), |
| 165 | + max_length=1000, |
| 166 | + ) |
27 | 167 | export_comments.required = False
|
28 | 168 | export_date_applic_init = forms.DateField(widget=DatePickerInput)
|
29 |
| - export_date_applic_init.widget.attrs['class'] = 'form-control form-control-sm' |
| 169 | + export_date_applic_init.widget.attrs["class"] = "form-control form-control-sm" |
30 | 170 | export_date_applic_init.required = False
|
31 | 171 | export_date_applic_final = forms.DateField(widget=DatePickerInput)
|
32 |
| - export_date_applic_final.widget.attrs['class'] = 'form-control form-control-sm' |
| 172 | + export_date_applic_final.widget.attrs["class"] = "form-control form-control-sm" |
33 | 173 | export_date_applic_final.required = False
|
34 |
| - |
35 |
| - |
36 |
| - |
37 |
| - |
38 |
| - |
39 |
| - |
40 |
| - |
|
0 commit comments