diff --git a/cove_ofds/forms.py b/cove_ofds/forms.py index 7eafc18..049f1e4 100644 --- a/cove_ofds/forms.py +++ b/cove_ofds/forms.py @@ -4,6 +4,7 @@ class NewGeoJSONUploadForm(forms.Form): nodes_file_upload = forms.FileField( + label="Select GeoJSON Nodes file", widget=forms.FileInput( attrs={ "accept": ",".join( @@ -11,9 +12,10 @@ class NewGeoJSONUploadForm(forms.Form): + settings.ALLOWED_GEOJSON_EXTENSIONS ) } - ) + ), ) spans_file_upload = forms.FileField( + label="Select GeoJSON Spans file", widget=forms.FileInput( attrs={ "accept": ",".join( @@ -21,5 +23,5 @@ class NewGeoJSONUploadForm(forms.Form): + settings.ALLOWED_GEOJSON_EXTENSIONS ) } - ) + ), ) diff --git a/cove_ofds/templates/cove_ofds/index.html b/cove_ofds/templates/cove_ofds/index.html index 35dbdc8..2cc1f54 100644 --- a/cove_ofds/templates/cove_ofds/index.html +++ b/cove_ofds/templates/cove_ofds/index.html @@ -4,17 +4,137 @@ {% block content %} -
- Upload JSON -
-
- Upload Spreadsheet -
-
- Upload CSVs -
-
- Upload GeoJSON + +

+ Use the form below to submit your data. You can submit data in either JSON, GeoJSON or CSV format. + For more information, see the publication format reference. +

+ + + + + +
+
+ + +
+ +
+
+
{% csrf_token %} + {% bootstrap_form forms.json.upload_form %} + {% buttons %} + + {% endbuttons %} +
+
+
+
+ + +
+ +
+
+
{% csrf_token %} + {% bootstrap_form forms.json.text_form %} + {% buttons %} + + {% endbuttons %} +
+
+
+
+ + +
+
+ + +
+ +
+
+
{% csrf_token %} + {% bootstrap_form forms.geojson.upload_form %} + {% buttons %} + + {% endbuttons %} +
+
+
+
+ +
+
+ + +
+ +
+
+
{% csrf_token %} + {% bootstrap_form forms.csvs.upload_form %} + {% buttons %} + + {% endbuttons %} +
+
+
+
+ +
+ + {% endblock %} diff --git a/cove_ofds/views.py b/cove_ofds/views.py index 88ba64f..c3c6ec9 100644 --- a/cove_ofds/views.py +++ b/cove_ofds/views.py @@ -19,7 +19,7 @@ WasJSONUploaded, ) from libcoveweb2.models import SuppliedData -from libcoveweb2.views import explore_data_context +from libcoveweb2.views import CSVS_FORM_CLASSES, JSON_FORM_CLASSES, explore_data_context logger = logging.getLogger(__name__) @@ -31,9 +31,29 @@ def default(self, obj): return json.JSONEncoder.default(self, obj) +GEOJSON_FORM_CLASSES = { + "upload_form": NewGeoJSONUploadForm, +} + + def index(request): - return render(request, "cove_ofds/index.html", {}) + forms = { + "json": { + form_name: form_class() + for form_name, form_class in JSON_FORM_CLASSES.items() + }, + "csvs": { + form_name: form_class() + for form_name, form_class in CSVS_FORM_CLASSES.items() + }, + "geojson": { + form_name: form_class() + for form_name, form_class in GEOJSON_FORM_CLASSES.items() + }, + } + + return render(request, "cove_ofds/index.html", {"forms": forms}) def new_geojson(request): diff --git a/libcoveweb2/forms.py b/libcoveweb2/forms.py index 9e07085..3e9d846 100644 --- a/libcoveweb2/forms.py +++ b/libcoveweb2/forms.py @@ -11,7 +11,8 @@ class NewJSONUploadForm(forms.Form): + settings.ALLOWED_JSON_EXTENSIONS ) } - ) + ), + label="Select JSON file", ) @@ -37,15 +38,17 @@ class NewCSVsUploadForm(forms.Form): # something that allows any number of uploads with no limits this will do for now file_field_names = ["file_upload" + str(i) for i in range(0, 10)] file_upload0 = forms.FileField( + label="Select CSV file", widget=forms.FileInput( attrs={ "accept": ",".join( settings.ALLOWED_CSV_CONTENT_TYPES + settings.ALLOWED_CSV_EXTENSIONS ) } - ) + ), ) file_upload1 = forms.FileField( + label="Select CSV file", widget=forms.FileInput( attrs={ "accept": ",".join( @@ -56,6 +59,7 @@ class NewCSVsUploadForm(forms.Form): required=False, ) file_upload2 = forms.FileField( + label="Select CSV file", widget=forms.FileInput( attrs={ "accept": ",".join( @@ -66,6 +70,7 @@ class NewCSVsUploadForm(forms.Form): required=False, ) file_upload3 = forms.FileField( + label="Select CSV file", widget=forms.FileInput( attrs={ "accept": ",".join( @@ -76,6 +81,7 @@ class NewCSVsUploadForm(forms.Form): required=False, ) file_upload4 = forms.FileField( + label="Select CSV file", widget=forms.FileInput( attrs={ "accept": ",".join( @@ -86,6 +92,7 @@ class NewCSVsUploadForm(forms.Form): required=False, ) file_upload5 = forms.FileField( + label="Select CSV file", widget=forms.FileInput( attrs={ "accept": ",".join( @@ -96,6 +103,7 @@ class NewCSVsUploadForm(forms.Form): required=False, ) file_upload6 = forms.FileField( + label="Select CSV file", widget=forms.FileInput( attrs={ "accept": ",".join( @@ -106,6 +114,7 @@ class NewCSVsUploadForm(forms.Form): required=False, ) file_upload7 = forms.FileField( + label="Select CSV file", widget=forms.FileInput( attrs={ "accept": ",".join( @@ -116,6 +125,7 @@ class NewCSVsUploadForm(forms.Form): required=False, ) file_upload8 = forms.FileField( + label="Select CSV file", widget=forms.FileInput( attrs={ "accept": ",".join( @@ -126,6 +136,7 @@ class NewCSVsUploadForm(forms.Form): required=False, ) file_upload9 = forms.FileField( + label="Select CSV file", widget=forms.FileInput( attrs={ "accept": ",".join( diff --git a/libcoveweb2/views.py b/libcoveweb2/views.py index 1b7257a..d150a55 100644 --- a/libcoveweb2/views.py +++ b/libcoveweb2/views.py @@ -75,6 +75,11 @@ def new_json(request): return render(request, "libcoveweb2/new_json.html", {"forms": forms}) +CSVS_FORM_CLASSES = { + "upload_form": NewCSVsUploadForm, +} + + def new_csvs(request): forms = {