Skip to content

Commit 3f43892

Browse files
authored
make geonames search param configurable (#3198)
so we can change it to `name_startsWith` for ANSA to restore previous behaviour. SDANSA-582
1 parent 9fa1a17 commit 3f43892

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

superdesk/default_settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,11 +924,15 @@ def local_to_utc_hour(hour):
924924
#: controll error notifications globally
925925
ERROR_NOTIFICATIONS = strtobool(env("SUPERDESK_ERROR_NOTIFICATIONS", "true"))
926926

927+
927928
#: geonames config
928929
GEONAMES_USERNAME = env("GEONAMES_USERNAME")
929930
GEONAMES_TOKEN = env("GEONAMES_TOKEN")
930931
GEONAMES_URL = env("GEONAMES_URL", "http://api.geonames.org/")
931932
GEONAMES_FEATURE_CLASSES = ["P"]
933+
#: Which param to use for geonames search (e.g. 'name', 'name_startsWith')
934+
#: .. versionadded:: 2.11
935+
GEONAMES_SEARCH_PARAM = env("GEONAMES_SEARCH_PARAM", "name")
932936
#: Set how much metadata should be returned
933937
#:
934938
#: .. versionadded:: 1.33

superdesk/places/places_autocomplete.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ class PlacesAutocompleteResource(superdesk.Resource):
3333

3434
class PlacesAutocompleteService(superdesk.Service):
3535
def get(self, req, lookup):
36-
assert req.args.get("name"), {"name": 1}
36+
search_param = app.config.get("GEONAMES_SEARCH_PARAM", "name")
37+
name_value = req.args.get("name")
38+
assert name_value, {"name": 1}
3739
params = [
38-
("name", req.args.get("name")),
40+
(search_param, name_value),
3941
("lang", req.args.get("lang", "en").split("-")[0]),
4042
("style", req.args.get("style", app.config["GEONAMES_SEARCH_STYLE"])),
4143
]

0 commit comments

Comments
 (0)