Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Use list of valid extensions to populate text in the upload template
Browse files Browse the repository at this point in the history
Whether extensions are explicitly specified in settings, or else just
the default list of extensions is used, we should consider
importers.VALID_EXTENSIONS as canon and use that in user-facing templates
  • Loading branch information
sarasafavi committed Sep 26, 2016
1 parent 4464e11 commit 07277e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions osgeo_importer/templates/osgeo_importer/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ <h2 class="page-title">{% trans "Add data" %}</h2>
{% for error in form.file.errors %}
<i class="fa fa-warning"> {{ error|escape }}</i>
{% endfor %}
<div class="col-md-6" style="padding-top: 5px; padding-left: 2px;">
Valid file extensions: {{ VALID_EXTENSIONS }}
</div>
</div>

</div>
Expand Down
5 changes: 4 additions & 1 deletion osgeo_importer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.utils.text import Truncator
from .forms import UploadFileForm
from .models import UploadedData, UploadLayer, UploadFile, DEFAULT_LAYER_CONFIGURATION
from .importers import OSGEO_IMPORTER
from .importers import OSGEO_IMPORTER, VALID_EXTENSIONS
from .inspectors import OSGEO_INSPECTOR
from .utils import import_string, NoDataSourceFound
from django.core.files.storage import FileSystemStorage
Expand Down Expand Up @@ -224,6 +224,9 @@ def form_valid(self, form):

def render_to_response(self, context, **response_kwargs):

# grab list of valid importer extensions for use in templates
context["VALID_EXTENSIONS"] = ", ".join(VALID_EXTENSIONS)

if self.json:
context = {'errors': context['form'].errors}
return self.render_to_json_response(context, **response_kwargs)
Expand Down

0 comments on commit 07277e0

Please sign in to comment.