File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,9 @@ def fixup_name(self, name):
193193 We use replace because it looks to be one of the fasted options:
194194 https://stackoverflow.com/questions/3411771/best-way-to-replace-multiple-characters-in-a-string
195195 """
196+ prefix = name [0 ]
197+ if prefix .isnumeric ():
198+ name = name .replace (name [0 ], "_" )
196199 return (
197200 name .lower ()
198201 .replace ("-" , "_" )
Original file line number Diff line number Diff line change 2525 drop_dynamic_model_schema ,
2626 should_be_imported ,
2727)
28+ from geonode .upload .handlers .base import BaseHandler
2829
2930
3031class TestHandlersUtils (TestCase ):
@@ -81,3 +82,13 @@ def test_drop_dynamic_model_schema(self):
8182 drop_dynamic_model_schema (schema_model = _model_schema )
8283
8384 self .assertFalse (ModelSchema .objects .filter (name = "model_schema" ).exists ())
85+
86+ def test_fixup_name_replace_digits_with_underscore (self ):
87+ """
88+ Ref https://github.com/GeoNode/geonode/issues/12749
89+ If the layer start with a digit, we should translate as a string
90+ """
91+ layer_name = "1layername"
92+ expected_name = "_layername"
93+ actual = BaseHandler ().fixup_name (layer_name )
94+ self .assertEqual (expected_name , actual )
You can’t perform that action at this time.
0 commit comments