goodmap 0.4.2__py3-none-any.whl → 0.4.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- goodmap/core.py +28 -1
- goodmap/core_api.py +3 -2
- goodmap/templates/map.html +1 -0
- {goodmap-0.4.2.dist-info → goodmap-0.4.4.dist-info}/METADATA +2 -2
- {goodmap-0.4.2.dist-info → goodmap-0.4.4.dist-info}/RECORD +7 -7
- {goodmap-0.4.2.dist-info → goodmap-0.4.4.dist-info}/WHEEL +1 -1
- {goodmap-0.4.2.dist-info → goodmap-0.4.4.dist-info}/LICENSE.md +0 -0
goodmap/core.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing import Any, Dict, List
|
|
2
|
+
|
|
1
3
|
# TODO move filtering to db site
|
|
2
4
|
|
|
3
5
|
|
|
@@ -10,10 +12,35 @@ def does_fulfill_requirement(entry, requirements):
|
|
|
10
12
|
return all(matches)
|
|
11
13
|
|
|
12
14
|
|
|
15
|
+
def sort_by_distance(data: List[Dict[str, Any]], query_params: Dict[str, List[str]]):
|
|
16
|
+
try:
|
|
17
|
+
if "lat" in query_params and "lon" in query_params:
|
|
18
|
+
lat = float(query_params["lat"][0])
|
|
19
|
+
lon = float(query_params["lon"][0])
|
|
20
|
+
data.sort(key=lambda x: (x["position"][0] - lat) ** 2 + (x["position"][1] - lon) ** 2)
|
|
21
|
+
return data
|
|
22
|
+
return data
|
|
23
|
+
except (ValueError, KeyError, IndexError):
|
|
24
|
+
return data
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def limit(data, query_params):
|
|
28
|
+
try:
|
|
29
|
+
if "limit" in query_params:
|
|
30
|
+
limit = int(query_params["limit"][0])
|
|
31
|
+
data = data[:limit]
|
|
32
|
+
return data
|
|
33
|
+
return data
|
|
34
|
+
except (ValueError, KeyError, IndexError):
|
|
35
|
+
return data
|
|
36
|
+
|
|
37
|
+
|
|
13
38
|
def get_queried_data(all_data, categories, query_params):
|
|
14
39
|
requirements = []
|
|
15
40
|
for key in categories.keys():
|
|
16
41
|
requirements.append((key, query_params.get(key)))
|
|
17
42
|
|
|
18
43
|
filtered_data = [x for x in all_data if does_fulfill_requirement(x, requirements)]
|
|
19
|
-
|
|
44
|
+
final_data = sort_by_distance(filtered_data, query_params)
|
|
45
|
+
final_data = limit(final_data, query_params)
|
|
46
|
+
return final_data
|
goodmap/core_api.py
CHANGED
|
@@ -72,8 +72,9 @@ def core_pages(
|
|
|
72
72
|
)
|
|
73
73
|
notifier_function(message)
|
|
74
74
|
except Exception as e:
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
error_message = gettext("Error sending notification")
|
|
76
|
+
return make_response(jsonify({"message": f"{error_message} : {e}"}), 400)
|
|
77
|
+
return make_response(jsonify({"message": gettext("Location reported")}), 200)
|
|
77
78
|
|
|
78
79
|
@core_api.route("/data")
|
|
79
80
|
class Data(Resource):
|
goodmap/templates/map.html
CHANGED
|
@@ -116,6 +116,7 @@ window.PRIMARY_COLOR = "{{ primary_color }}";
|
|
|
116
116
|
window.SHOW_SUGGEST_NEW_POINT_BUTTON = {{ feature_flags.SHOW_SUGGEST_NEW_POINT_BUTTON | default(false) | tojson }};
|
|
117
117
|
window.SHOW_SEARCH_BAR = {{ feature_flags.SHOW_SEARCH_BAR | default(false) | tojson }};
|
|
118
118
|
window.USE_LAZY_LOADING = {{ feature_flags.USE_LAZY_LOADING | default(false) | tojson }};
|
|
119
|
+
window.SHOW_ACCESSIBILITY_TABLE = {{ feature_flags.SHOW_ACCESSIBILITY_TABLE | default(false) | tojson }};
|
|
119
120
|
</script>
|
|
120
121
|
<script src="/static/map.js"></script>
|
|
121
122
|
{% endblock %}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
goodmap/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
2
|
-
goodmap/core.py,sha256=
|
|
3
|
-
goodmap/core_api.py,sha256=
|
|
2
|
+
goodmap/core.py,sha256=rzMhOIYnR1jxTX6uHQJKIPLYxdUm4_v2d6LrtHtJpHU,1465
|
|
3
|
+
goodmap/core_api.py,sha256=wy861bym-OtJV_y65TNJNr_hxUW45bUK0j2Vt96HG1s,6544
|
|
4
4
|
goodmap/data_models/location.py,sha256=ESR4Z_zINIjldJKhlXImMaQrdtUPJBQc6SatpPPJyNQ,1054
|
|
5
5
|
goodmap/data_validator.py,sha256=e_PCc2CTgiEBK6inF_HDX5mb5R8poh3KkcbhyrLrFVA,4086
|
|
6
6
|
goodmap/db.py,sha256=AJHUP3n29BRjgt6GoGnPtxLNg5TL-KSJhtSZtsZKmGM,3665
|
|
7
7
|
goodmap/formatter.py,sha256=VlUHcK1HtM_IEU0VE3S5TOkZLVheMdakvUeW2tCKdq0,783
|
|
8
8
|
goodmap/goodmap.py,sha256=cPTTyGqajuza3RDlfFuCl8idxy7TFo6LPuANP8hmg7U,1806
|
|
9
9
|
goodmap/templates/admin.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
-
goodmap/templates/map.html,sha256=
|
|
11
|
-
goodmap-0.4.
|
|
12
|
-
goodmap-0.4.
|
|
13
|
-
goodmap-0.4.
|
|
14
|
-
goodmap-0.4.
|
|
10
|
+
goodmap/templates/map.html,sha256=llzzfWGHM0Xtr4Io05QJLCLajySHNBzKejR0Km5nGMw,3926
|
|
11
|
+
goodmap-0.4.4.dist-info/LICENSE.md,sha256=nkCQOR7uheLRvHRfXmwx9LhBnMcPeBU9d4ebLojDiQU,1067
|
|
12
|
+
goodmap-0.4.4.dist-info/METADATA,sha256=9efllxXa6i44w0t6sXK5ok5mNsNDtmcxh_OolIBfdSg,4525
|
|
13
|
+
goodmap-0.4.4.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
14
|
+
goodmap-0.4.4.dist-info/RECORD,,
|
|
File without changes
|