goodmap 0.4.2__tar.gz → 0.4.4__tar.gz
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-0.4.2 → goodmap-0.4.4}/PKG-INFO +2 -2
- goodmap-0.4.4/goodmap/core.py +46 -0
- {goodmap-0.4.2 → goodmap-0.4.4}/goodmap/core_api.py +3 -2
- {goodmap-0.4.2 → goodmap-0.4.4}/goodmap/templates/map.html +1 -0
- {goodmap-0.4.2 → goodmap-0.4.4}/pyproject.toml +1 -1
- goodmap-0.4.2/goodmap/core.py +0 -19
- {goodmap-0.4.2 → goodmap-0.4.4}/LICENSE.md +0 -0
- {goodmap-0.4.2 → goodmap-0.4.4}/README.md +0 -0
- {goodmap-0.4.2 → goodmap-0.4.4}/goodmap/__init__.py +0 -0
- {goodmap-0.4.2 → goodmap-0.4.4}/goodmap/data_models/location.py +0 -0
- {goodmap-0.4.2 → goodmap-0.4.4}/goodmap/data_validator.py +0 -0
- {goodmap-0.4.2 → goodmap-0.4.4}/goodmap/db.py +0 -0
- {goodmap-0.4.2 → goodmap-0.4.4}/goodmap/formatter.py +0 -0
- {goodmap-0.4.2 → goodmap-0.4.4}/goodmap/goodmap.py +0 -0
- {goodmap-0.4.2 → goodmap-0.4.4}/goodmap/templates/admin.html +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from typing import Any, Dict, List
|
|
2
|
+
|
|
3
|
+
# TODO move filtering to db site
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def does_fulfill_requirement(entry, requirements):
|
|
7
|
+
matches = []
|
|
8
|
+
for category, values in requirements:
|
|
9
|
+
if not values:
|
|
10
|
+
continue
|
|
11
|
+
matches.append(all(entry_value in entry[category] for entry_value in values))
|
|
12
|
+
return all(matches)
|
|
13
|
+
|
|
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
|
+
|
|
38
|
+
def get_queried_data(all_data, categories, query_params):
|
|
39
|
+
requirements = []
|
|
40
|
+
for key in categories.keys():
|
|
41
|
+
requirements.append((key, query_params.get(key)))
|
|
42
|
+
|
|
43
|
+
filtered_data = [x for x in all_data if does_fulfill_requirement(x, requirements)]
|
|
44
|
+
final_data = sort_by_distance(filtered_data, query_params)
|
|
45
|
+
final_data = limit(final_data, query_params)
|
|
46
|
+
return final_data
|
|
@@ -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):
|
|
@@ -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 %}
|
goodmap-0.4.2/goodmap/core.py
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# TODO move filtering to db site
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def does_fulfill_requirement(entry, requirements):
|
|
5
|
-
matches = []
|
|
6
|
-
for category, values in requirements:
|
|
7
|
-
if not values:
|
|
8
|
-
continue
|
|
9
|
-
matches.append(all(entry_value in entry[category] for entry_value in values))
|
|
10
|
-
return all(matches)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def get_queried_data(all_data, categories, query_params):
|
|
14
|
-
requirements = []
|
|
15
|
-
for key in categories.keys():
|
|
16
|
-
requirements.append((key, query_params.get(key)))
|
|
17
|
-
|
|
18
|
-
filtered_data = [x for x in all_data if does_fulfill_requirement(x, requirements)]
|
|
19
|
-
return filtered_data
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|