From 58e204de04f8b1879254613de1ab8b4ff9bda56c Mon Sep 17 00:00:00 2001 From: Jude Mwenda Date: Thu, 22 Sep 2011 15:27:21 +0300 Subject: [PATCH] changes to forms to allow uploading of companion files with different names --- src/GeoNodePy/geonode/maps/forms.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/GeoNodePy/geonode/maps/forms.py b/src/GeoNodePy/geonode/maps/forms.py index ff2c7d17edf..c7caee78400 100644 --- a/src/GeoNodePy/geonode/maps/forms.py +++ b/src/GeoNodePy/geonode/maps/forms.py @@ -3,6 +3,8 @@ import json import os import tempfile +import pdb + class JSONField(forms.CharField): def clean(self, text): @@ -32,10 +34,10 @@ def clean(self): raise forms.ValidationError("When uploading Shapefiles, .SHX and .DBF files are also required.") dbf_name, __ = os.path.splitext(dbf_file.name) shx_name, __ = os.path.splitext(shx_file.name) - if dbf_name != base_name or shx_name != base_name: - raise forms.ValidationError("It looks like you're uploading " - "components from different Shapefiles. Please " - "double-check your file selections.") + if dbf_name != base_name: + dbf_file.name = base_name + ".dbf" + if shx_name != base_name: + shx_file.name = base_name + ".shx" if cleaned["prj_file"] is not None: prj_file = cleaned["prj_file"].name if os.path.splitext(prj_file)[0] != base_name: