goodmap 0.4.1__py3-none-any.whl → 0.4.3__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_api.py +6 -5
- goodmap/data_models/location.py +2 -2
- goodmap/db.py +8 -8
- {goodmap-0.4.1.dist-info → goodmap-0.4.3.dist-info}/METADATA +2 -2
- {goodmap-0.4.1.dist-info → goodmap-0.4.3.dist-info}/RECORD +7 -7
- {goodmap-0.4.1.dist-info → goodmap-0.4.3.dist-info}/LICENSE.md +0 -0
- {goodmap-0.4.1.dist-info → goodmap-0.4.3.dist-info}/WHEEL +0 -0
goodmap/core_api.py
CHANGED
|
@@ -46,10 +46,10 @@ def core_pages(
|
|
|
46
46
|
"""Suggest new location"""
|
|
47
47
|
try:
|
|
48
48
|
suggested_location = request.get_json()
|
|
49
|
-
suggested_location.update({"
|
|
49
|
+
suggested_location.update({"uuid": str(uuid.uuid4())})
|
|
50
50
|
location = location_model.model_validate(suggested_location)
|
|
51
51
|
message = (
|
|
52
|
-
f"A new location has been suggested under
|
|
52
|
+
f"A new location has been suggested under uuid: '{location.uuid}' "
|
|
53
53
|
f"at position: {location.position}"
|
|
54
54
|
)
|
|
55
55
|
notifier_function(message)
|
|
@@ -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):
|
|
@@ -102,7 +103,7 @@ def core_pages(
|
|
|
102
103
|
class GetLocations(Resource):
|
|
103
104
|
def get(self):
|
|
104
105
|
"""
|
|
105
|
-
Shows list of locations with
|
|
106
|
+
Shows list of locations with uuid and position
|
|
106
107
|
"""
|
|
107
108
|
query_params = request.args.to_dict(flat=False)
|
|
108
109
|
all_locations = database.get_locations(query_params)
|
goodmap/data_models/location.py
CHANGED
|
@@ -5,7 +5,7 @@ from pydantic import BaseModel, Field, create_model, field_validator
|
|
|
5
5
|
|
|
6
6
|
class LocationBase(BaseModel, extra="allow"):
|
|
7
7
|
position: tuple[float, float]
|
|
8
|
-
|
|
8
|
+
uuid: str
|
|
9
9
|
|
|
10
10
|
@field_validator("position")
|
|
11
11
|
@classmethod
|
|
@@ -17,7 +17,7 @@ class LocationBase(BaseModel, extra="allow"):
|
|
|
17
17
|
return v
|
|
18
18
|
|
|
19
19
|
def basic_info(self):
|
|
20
|
-
return {"
|
|
20
|
+
return {"uuid": self.uuid, "position": self.position}
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
def create_location_model(obligatory_fields: list[tuple[str, Type[Any]]]) -> Type[BaseModel]:
|
goodmap/db.py
CHANGED
|
@@ -51,25 +51,25 @@ def get_data(db):
|
|
|
51
51
|
# get_location
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
def get_location_from_raw_data(raw_data,
|
|
55
|
-
point = next((point for point in raw_data["data"] if point["
|
|
54
|
+
def get_location_from_raw_data(raw_data, uuid, location_model):
|
|
55
|
+
point = next((point for point in raw_data["data"] if point["uuid"] == uuid), None)
|
|
56
56
|
return location_model.model_validate(point) if point else None
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
def google_json_db_get_location(self,
|
|
59
|
+
def google_json_db_get_location(self, uuid, location_model):
|
|
60
60
|
return get_location_from_raw_data(
|
|
61
|
-
json.loads(self.blob.download_as_text(client=None))["map"],
|
|
61
|
+
json.loads(self.blob.download_as_text(client=None))["map"], uuid, location_model
|
|
62
62
|
)
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
def json_file_db_get_location(self,
|
|
65
|
+
def json_file_db_get_location(self, uuid, location_model):
|
|
66
66
|
with open(self.data_file_path, "r") as file:
|
|
67
|
-
point = get_location_from_raw_data(json.load(file)["map"],
|
|
67
|
+
point = get_location_from_raw_data(json.load(file)["map"], uuid, location_model)
|
|
68
68
|
return point
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
def json_db_get_location(self,
|
|
72
|
-
return get_location_from_raw_data(self.data,
|
|
71
|
+
def json_db_get_location(self, uuid, location_model):
|
|
72
|
+
return get_location_from_raw_data(self.data, uuid, location_model)
|
|
73
73
|
|
|
74
74
|
|
|
75
75
|
def get_location(db, location_model):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: goodmap
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.3
|
|
4
4
|
Summary: Map engine to serve all the people :)
|
|
5
5
|
Author: Krzysztof Kolodzinski
|
|
6
6
|
Author-email: krzysztof.kolodzinski@problematy.pl
|
|
@@ -110,7 +110,7 @@ TODO: `obligatory_fields` is a new subsection, start using it in the actual appl
|
|
|
110
110
|
```
|
|
111
111
|
- `meta-data` - some special data like
|
|
112
112
|
```
|
|
113
|
-
"
|
|
113
|
+
"uuid"
|
|
114
114
|
```
|
|
115
115
|
|
|
116
116
|
You can define the fields in all these subsections. Besides these types of fields, there is no restriction on the number of fields a datapoint can have.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
goodmap/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
2
2
|
goodmap/core.py,sha256=hOTHrDRzbqkfSeKAoD01lzSoY4W8JwupXlJTwTzcvAU,586
|
|
3
|
-
goodmap/core_api.py,sha256=
|
|
4
|
-
goodmap/data_models/location.py,sha256=
|
|
3
|
+
goodmap/core_api.py,sha256=wy861bym-OtJV_y65TNJNr_hxUW45bUK0j2Vt96HG1s,6544
|
|
4
|
+
goodmap/data_models/location.py,sha256=ESR4Z_zINIjldJKhlXImMaQrdtUPJBQc6SatpPPJyNQ,1054
|
|
5
5
|
goodmap/data_validator.py,sha256=e_PCc2CTgiEBK6inF_HDX5mb5R8poh3KkcbhyrLrFVA,4086
|
|
6
|
-
goodmap/db.py,sha256=
|
|
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
10
|
goodmap/templates/map.html,sha256=eU_h61l404g8e3_wszUokDrOC92bQ1nFl8yGMKRXFww,3820
|
|
11
|
-
goodmap-0.4.
|
|
12
|
-
goodmap-0.4.
|
|
13
|
-
goodmap-0.4.
|
|
14
|
-
goodmap-0.4.
|
|
11
|
+
goodmap-0.4.3.dist-info/LICENSE.md,sha256=nkCQOR7uheLRvHRfXmwx9LhBnMcPeBU9d4ebLojDiQU,1067
|
|
12
|
+
goodmap-0.4.3.dist-info/METADATA,sha256=nvPI8Jtcm5s-KrGCABgU5OKgYEui4gjC5B-MKgg26tU,4525
|
|
13
|
+
goodmap-0.4.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
14
|
+
goodmap-0.4.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|