generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Input files parsed in browser of user (#141)
* removed file import, parsing in browser now. Not working yet * fixed parsing comment * default uncertainty * added handling of file separators and improved form responsiveness * disallow form submission if no data is loaded * parsing old session data in browser now * updated readme * adjusted tests for new file import * small clarifications
- Loading branch information
1 parent
dc53c08
commit f95e1ca
Showing
8 changed files
with
624 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,173 @@ | ||
from django import forms | ||
from django.core import validators | ||
|
||
|
||
class DatePickerInput(forms.DateInput): | ||
input_type = 'date' | ||
input_type = "date" | ||
|
||
|
||
class import_rc_data(forms.Form): | ||
# csv_upload = forms.FileField(label="csv file", widget=forms.FileInput(attrs={'class': 'form-control form-control-sm'})) | ||
csv_upload = forms.FileField(label="csv file", widget=forms.FileInput(attrs={'class': 'form-control form-control-sm', 'style': 'font-size: 11.5px;'})) | ||
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;'})) | ||
csv_upload.required = False | ||
header_row.required = False | ||
input_session_type = forms.ChoiceField( | ||
label="import type", | ||
widget=forms.Select( | ||
attrs={ | ||
"class": "form-control form-control-sm", | ||
"style": "font-size: 11.5px;", | ||
} | ||
), | ||
choices=[ | ||
("new", "new session"), | ||
("load", "load previous session"), | ||
], | ||
) | ||
|
||
csv_content = forms.CharField( | ||
label="csv content", | ||
widget=forms.Textarea( | ||
attrs={ | ||
"class": "form-control form-control-sm", | ||
"style": "font-size: 11.5px; height: 200px;", | ||
} | ||
), | ||
required=False, | ||
) | ||
|
||
session_content = forms.CharField( | ||
label="session content", | ||
widget=forms.Textarea( | ||
attrs={ | ||
"class": "form-control form-control-sm", | ||
"style": "font-size: 11.5px; height: 200px;", | ||
} | ||
), | ||
required=False, | ||
) | ||
|
||
csv_separator = forms.ChoiceField( | ||
label="separator", | ||
widget=forms.Select( | ||
attrs={ | ||
"class": "form-control form-control-sm", | ||
"style": "font-size: 11.5px;", | ||
} | ||
), | ||
choices=[ | ||
(",", "comma"), | ||
(";", "semicolon"), | ||
("\t", "tab"), | ||
], | ||
) | ||
|
||
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;", | ||
} | ||
), | ||
) | ||
|
||
|
||
class develop_rc(forms.Form): | ||
set_offset1 = forms.FloatField(label="offset 1", widget=forms.NumberInput(attrs={'class': 'form-control form-control-sm', 'id':'offset1', 'style': 'font-size: 11.5px;'})) | ||
set_offset2 = forms.FloatField(label="offset 2", widget=forms.NumberInput(attrs={'class': 'form-control form-control-sm', 'id':'offset2', 'style': 'font-size: 11.5px;'})) | ||
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;'})) | ||
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;'})) | ||
set_offset1 = forms.FloatField( | ||
label="offset 1", | ||
widget=forms.NumberInput( | ||
attrs={ | ||
"class": "form-control form-control-sm", | ||
"id": "offset1", | ||
"style": "font-size: 11.5px;", | ||
} | ||
), | ||
) | ||
set_offset2 = forms.FloatField( | ||
label="offset 2", | ||
widget=forms.NumberInput( | ||
attrs={ | ||
"class": "form-control form-control-sm", | ||
"id": "offset2", | ||
"style": "font-size: 11.5px;", | ||
} | ||
), | ||
) | ||
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;", | ||
} | ||
), | ||
) | ||
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;", | ||
} | ||
), | ||
) | ||
|
||
|
||
class export_rc_data(forms.Form): | ||
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)')]) | ||
export_filetype.widget.attrs['onchange'] = 'toggleExportForm(this.value)' | ||
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) | ||
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) | ||
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)"), | ||
], | ||
) | ||
export_filetype.widget.attrs["onchange"] = "toggleExportForm(this.value)" | ||
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, | ||
) | ||
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, | ||
) | ||
export_station_name.required = False | ||
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) | ||
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, | ||
) | ||
export_comments.required = False | ||
export_date_applic_init = forms.DateField(widget=DatePickerInput) | ||
export_date_applic_init.widget.attrs['class'] = 'form-control form-control-sm' | ||
export_date_applic_init.widget.attrs["class"] = "form-control form-control-sm" | ||
export_date_applic_init.required = False | ||
export_date_applic_final = forms.DateField(widget=DatePickerInput) | ||
export_date_applic_final.widget.attrs['class'] = 'form-control form-control-sm' | ||
export_date_applic_final.widget.attrs["class"] = "form-control form-control-sm" | ||
export_date_applic_final.required = False | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.