goodmap 1.1.0__tar.gz → 1.1.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: goodmap
3
- Version: 1.1.0
3
+ Version: 1.1.2
4
4
  Summary: Map engine to serve all the people :)
5
5
  License-File: LICENSE.md
6
6
  Author: Krzysztof Kolodzinski
@@ -12,6 +12,7 @@ Classifier: Programming Language :: Python :: 3.11
12
12
  Classifier: Programming Language :: Python :: 3.12
13
13
  Classifier: Programming Language :: Python :: 3.13
14
14
  Classifier: Programming Language :: Python :: 3.14
15
+ Provides-Extra: docs
15
16
  Requires-Dist: Babel (>=2.10.3,<3.0.0)
16
17
  Requires-Dist: Flask (==3.0.3)
17
18
  Requires-Dist: Flask-Babel (>=4.0.0,<5.0.0)
@@ -24,8 +25,12 @@ Requires-Dist: google-cloud-storage (>=2.7.0,<3.0.0)
24
25
  Requires-Dist: gql (>=3.4.0,<4.0.0)
25
26
  Requires-Dist: gunicorn (>=20.1.0,<21.0.0)
26
27
  Requires-Dist: humanize (>=4.6.0,<5.0.0)
28
+ Requires-Dist: myst-parser (>=4.0.0,<5.0.0) ; extra == "docs"
27
29
  Requires-Dist: platzky (>=1.0.0,<2.0.0)
28
30
  Requires-Dist: pydantic (>=2.7.1,<3.0.0)
31
+ Requires-Dist: sphinx (>=8.0.0,<9.0.0) ; extra == "docs"
32
+ Requires-Dist: sphinx-rtd-theme (>=3.0.0,<4.0.0) ; extra == "docs"
33
+ Requires-Dist: tomli (>=2.0.0,<3.0.0) ; extra == "docs"
29
34
  Description-Content-Type: text/markdown
30
35
 
31
36
  ![Github Actions](https://github.com/problematy/goodmap/actions/workflows/release.yml/badge.svg?event=push&branch=main)
@@ -117,13 +117,8 @@ def core_pages(
117
117
  Shows a single location with all data
118
118
  """
119
119
  location = database.get_location(location_id)
120
-
121
- # TODO getting visible_data and meta_data should be taken from db methods
122
- # e.g. db.get_visible_data() and db.get_meta_data()
123
- # visible_data and meta_data should be models
124
- all_data = database.get_data()
125
- visible_data = all_data["visible_data"]
126
- meta_data = all_data["meta_data"]
120
+ visible_data = database.get_visible_data()
121
+ meta_data = database.get_meta_data()
127
122
 
128
123
  formatted_data = prepare_pin(location.model_dump(), visible_data, meta_data)
129
124
  return jsonify(formatted_data)
@@ -2,6 +2,7 @@ import json
2
2
  import os
3
3
  import tempfile
4
4
  from functools import partial
5
+ from typing import Any
5
6
 
6
7
  from goodmap.core import get_queried_data
7
8
  from goodmap.data_models.location import LocationBase
@@ -387,6 +388,142 @@ def get_data(db):
387
388
  return globals()[f"{db.module_name}_get_data"]
388
389
 
389
390
 
391
+ # ------------------------------------------------
392
+ # get_visible_data
393
+
394
+
395
+ def google_json_db_get_visible_data(self) -> dict[str, Any]:
396
+ """
397
+ Retrieve visible data configuration from Google Cloud Storage JSON blob.
398
+
399
+ Returns:
400
+ dict: Dictionary containing field visibility configuration.
401
+ Returns empty dict if not found.
402
+ """
403
+ return self.data.get("map", {}).get("visible_data", {})
404
+
405
+
406
+ def json_file_db_get_visible_data(self) -> dict[str, Any]:
407
+ """
408
+ Retrieve visible data configuration from JSON file database.
409
+
410
+ Returns:
411
+ dict: Dictionary containing field visibility configuration.
412
+ Returns empty dict if not found.
413
+ """
414
+ return self.data.get("map", {}).get("visible_data", {})
415
+
416
+
417
+ def json_db_get_visible_data(self) -> dict[str, Any]:
418
+ """
419
+ Retrieve visible data configuration from in-memory JSON database.
420
+
421
+ Returns:
422
+ dict: Dictionary containing field visibility configuration.
423
+ Returns empty dict if not found.
424
+ """
425
+ return self.data.get("visible_data", {})
426
+
427
+
428
+ def mongodb_db_get_visible_data(self) -> dict[str, Any]:
429
+ """
430
+ Retrieve visible data configuration from MongoDB.
431
+
432
+ Returns:
433
+ dict: Dictionary containing field visibility configuration.
434
+ Returns empty dict if config document not found or field missing.
435
+
436
+ Raises:
437
+ pymongo.errors.ConnectionFailure: If database connection fails.
438
+ pymongo.errors.OperationFailure: If database operation fails.
439
+ """
440
+ config_doc = self.db.config.find_one({"_id": "map_config"})
441
+ if config_doc:
442
+ return config_doc.get("visible_data", {})
443
+ return {}
444
+
445
+
446
+ def get_visible_data(db):
447
+ """
448
+ Get the appropriate get_visible_data function for the given database backend.
449
+
450
+ Args:
451
+ db: Database instance (must have module_name attribute).
452
+
453
+ Returns:
454
+ callable: Backend-specific get_visible_data function.
455
+ """
456
+ return globals()[f"{db.module_name}_get_visible_data"]
457
+
458
+
459
+ # ------------------------------------------------
460
+ # get_meta_data
461
+
462
+
463
+ def google_json_db_get_meta_data(self) -> dict[str, Any]:
464
+ """
465
+ Retrieve metadata configuration from Google Cloud Storage JSON blob.
466
+
467
+ Returns:
468
+ dict: Dictionary containing metadata configuration.
469
+ Returns empty dict if not found.
470
+ """
471
+ return self.data.get("map", {}).get("meta_data", {})
472
+
473
+
474
+ def json_file_db_get_meta_data(self) -> dict[str, Any]:
475
+ """
476
+ Retrieve metadata configuration from JSON file database.
477
+
478
+ Returns:
479
+ dict: Dictionary containing metadata configuration.
480
+ Returns empty dict if not found.
481
+ """
482
+ return self.data.get("map", {}).get("meta_data", {})
483
+
484
+
485
+ def json_db_get_meta_data(self) -> dict[str, Any]:
486
+ """
487
+ Retrieve metadata configuration from in-memory JSON database.
488
+
489
+ Returns:
490
+ dict: Dictionary containing metadata configuration.
491
+ Returns empty dict if not found.
492
+ """
493
+ return self.data.get("meta_data", {})
494
+
495
+
496
+ def mongodb_db_get_meta_data(self) -> dict[str, Any]:
497
+ """
498
+ Retrieve metadata configuration from MongoDB.
499
+
500
+ Returns:
501
+ dict: Dictionary containing metadata configuration.
502
+ Returns empty dict if config document not found or field missing.
503
+
504
+ Raises:
505
+ pymongo.errors.ConnectionFailure: If database connection fails.
506
+ pymongo.errors.OperationFailure: If database operation fails.
507
+ """
508
+ config_doc = self.db.config.find_one({"_id": "map_config"})
509
+ if config_doc:
510
+ return config_doc.get("meta_data", {})
511
+ return {}
512
+
513
+
514
+ def get_meta_data(db):
515
+ """
516
+ Get the appropriate get_meta_data function for the given database backend.
517
+
518
+ Args:
519
+ db: Database instance (must have module_name attribute).
520
+
521
+ Returns:
522
+ callable: Backend-specific get_meta_data function.
523
+ """
524
+ return globals()[f"{db.module_name}_get_meta_data"]
525
+
526
+
390
527
  # ------------------------------------------------
391
528
  # get_categories
392
529
 
@@ -786,6 +923,12 @@ def mongodb_db_add_suggestion(self, suggestion_data):
786
923
  CRUDHelper.add_item_to_mongodb(self.db.suggestions, suggestion_data, "Suggestion", "pending")
787
924
 
788
925
 
926
+ def google_json_db_add_suggestion(self, suggestion_data):
927
+ # Temporary workaround: just use notifier without storing
928
+ # Full implementation would require writing back to Google Cloud Storage
929
+ pass
930
+
931
+
789
932
  def add_suggestion(db, suggestion_data):
790
933
  return globals()[f"{db.module_name}_add_suggestion"](db, suggestion_data)
791
934
 
@@ -876,6 +1019,16 @@ def mongodb_db_get_suggestions_paginated(self, query):
876
1019
  return __build_pagination_response(items, total_count, page, per_page)
877
1020
 
878
1021
 
1022
+ def google_json_db_get_suggestions(self, query_params):
1023
+ # GoogleJsonDb is read-only, suggestions not stored in blob
1024
+ return []
1025
+
1026
+
1027
+ def google_json_db_get_suggestions_paginated(self, query):
1028
+ """Google JSON suggestions with pagination (read-only)."""
1029
+ return PaginationHelper.create_paginated_response([], query)
1030
+
1031
+
879
1032
  def get_suggestions(db):
880
1033
  return globals()[f"{db.module_name}_get_suggestions"]
881
1034
 
@@ -906,6 +1059,11 @@ def mongodb_db_get_suggestion(self, suggestion_id):
906
1059
  return self.db.suggestions.find_one({"uuid": suggestion_id}, {"_id": 0})
907
1060
 
908
1061
 
1062
+ def google_json_db_get_suggestion(self, suggestion_id):
1063
+ # GoogleJsonDb is read-only, suggestions not stored in blob
1064
+ return None
1065
+
1066
+
909
1067
  def get_suggestion(db):
910
1068
  return globals()[f"{db.module_name}_get_suggestion"]
911
1069
 
@@ -946,6 +1104,11 @@ def mongodb_db_update_suggestion(self, suggestion_id, status):
946
1104
  raise ValueError(f"Suggestion with uuid {suggestion_id} not found")
947
1105
 
948
1106
 
1107
+ def google_json_db_update_suggestion(self, suggestion_id, status):
1108
+ # GoogleJsonDb is read-only, no-op
1109
+ pass
1110
+
1111
+
949
1112
  def update_suggestion(db, suggestion_id, status):
950
1113
  return globals()[f"{db.module_name}_update_suggestion"](db, suggestion_id, status)
951
1114
 
@@ -984,6 +1147,11 @@ def mongodb_db_delete_suggestion(self, suggestion_id):
984
1147
  raise ValueError(f"Suggestion with uuid {suggestion_id} not found")
985
1148
 
986
1149
 
1150
+ def google_json_db_delete_suggestion(self, suggestion_id):
1151
+ # GoogleJsonDb is read-only, no-op
1152
+ pass
1153
+
1154
+
987
1155
  def delete_suggestion(db, suggestion_id):
988
1156
  return globals()[f"{db.module_name}_delete_suggestion"](db, suggestion_id)
989
1157
 
@@ -1022,6 +1190,12 @@ def mongodb_db_add_report(self, report_data):
1022
1190
  self.db.reports.insert_one(report_data)
1023
1191
 
1024
1192
 
1193
+ def google_json_db_add_report(self, report_data):
1194
+ # Temporary workaround: just use notifier without storing
1195
+ # Full implementation would require writing back to Google Cloud Storage
1196
+ pass
1197
+
1198
+
1025
1199
  def add_report(db, report_data):
1026
1200
  return globals()[f"{db.module_name}_add_report"](db, report_data)
1027
1201
 
@@ -1128,6 +1302,16 @@ def mongodb_db_get_reports_paginated(self, query):
1128
1302
  return __build_pagination_response(items, total_count, page, per_page)
1129
1303
 
1130
1304
 
1305
+ def google_json_db_get_reports(self, query_params):
1306
+ # GoogleJsonDb is read-only, reports not stored in blob
1307
+ return []
1308
+
1309
+
1310
+ def google_json_db_get_reports_paginated(self, query):
1311
+ """Google JSON reports with pagination (read-only)."""
1312
+ return PaginationHelper.create_paginated_response([], query)
1313
+
1314
+
1131
1315
  def get_reports(db):
1132
1316
  return globals()[f"{db.module_name}_get_reports"]
1133
1317
 
@@ -1157,6 +1341,11 @@ def mongodb_db_get_report(self, report_id):
1157
1341
  return self.db.reports.find_one({"uuid": report_id}, {"_id": 0})
1158
1342
 
1159
1343
 
1344
+ def google_json_db_get_report(self, report_id):
1345
+ # GoogleJsonDb is read-only, reports not stored in blob
1346
+ return None
1347
+
1348
+
1160
1349
  def get_report(db):
1161
1350
  return globals()[f"{db.module_name}_get_report"]
1162
1351
 
@@ -1210,6 +1399,11 @@ def mongodb_db_update_report(self, report_id, status=None, priority=None):
1210
1399
  raise ValueError(f"Report with uuid {report_id} not found")
1211
1400
 
1212
1401
 
1402
+ def google_json_db_update_report(self, report_id, status=None, priority=None):
1403
+ # GoogleJsonDb is read-only, no-op
1404
+ pass
1405
+
1406
+
1213
1407
  def update_report(db, report_id, status=None, priority=None):
1214
1408
  return globals()[f"{db.module_name}_update_report"](db, report_id, status, priority)
1215
1409
 
@@ -1247,6 +1441,11 @@ def mongodb_db_delete_report(self, report_id):
1247
1441
  raise ValueError(f"Report with uuid {report_id} not found")
1248
1442
 
1249
1443
 
1444
+ def google_json_db_delete_report(self, report_id):
1445
+ # GoogleJsonDb is read-only, no-op
1446
+ pass
1447
+
1448
+
1250
1449
  def delete_report(db, report_id):
1251
1450
  return globals()[f"{db.module_name}_delete_report"](db, report_id)
1252
1451
 
@@ -1258,6 +1457,8 @@ def delete_report(db, report_id):
1258
1457
 
1259
1458
  def extend_db_with_goodmap_queries(db, location_model):
1260
1459
  db.extend("get_data", get_data(db))
1460
+ db.extend("get_visible_data", get_visible_data(db))
1461
+ db.extend("get_meta_data", get_meta_data(db))
1261
1462
  db.extend("get_locations", get_locations(db, location_model))
1262
1463
  db.extend("get_locations_paginated", get_locations_paginated(db, location_model))
1263
1464
  db.extend("get_location", get_location(db, location_model))
@@ -1266,17 +1467,16 @@ def extend_db_with_goodmap_queries(db, location_model):
1266
1467
  db.extend("delete_location", delete_location)
1267
1468
  db.extend("get_categories", get_categories(db))
1268
1469
  db.extend("get_category_data", get_category_data(db))
1269
- if db.module_name in ("json_db", "json_file_db", "mongodb_db"):
1270
- db.extend("add_suggestion", add_suggestion)
1271
- db.extend("get_suggestions", get_suggestions(db))
1272
- db.extend("get_suggestions_paginated", get_suggestions_paginated(db))
1273
- db.extend("get_suggestion", get_suggestion(db))
1274
- db.extend("update_suggestion", update_suggestion)
1275
- db.extend("delete_suggestion", delete_suggestion)
1276
- db.extend("add_report", add_report)
1277
- db.extend("get_reports", get_reports(db))
1278
- db.extend("get_reports_paginated", get_reports_paginated(db))
1279
- db.extend("get_report", get_report(db))
1280
- db.extend("update_report", update_report)
1281
- db.extend("delete_report", delete_report)
1470
+ db.extend("add_suggestion", add_suggestion)
1471
+ db.extend("get_suggestions", get_suggestions(db))
1472
+ db.extend("get_suggestions_paginated", get_suggestions_paginated(db))
1473
+ db.extend("get_suggestion", get_suggestion(db))
1474
+ db.extend("update_suggestion", update_suggestion)
1475
+ db.extend("delete_suggestion", delete_suggestion)
1476
+ db.extend("add_report", add_report)
1477
+ db.extend("get_reports", get_reports(db))
1478
+ db.extend("get_reports_paginated", get_reports_paginated(db))
1479
+ db.extend("get_report", get_report(db))
1480
+ db.extend("update_report", update_report)
1481
+ db.extend("delete_report", delete_report)
1282
1482
  return db
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "goodmap"
3
- version = "1.1.0"
3
+ version = "1.1.2"
4
4
  description = "Map engine to serve all the people :)"
5
5
  authors = ["Krzysztof Kolodzinski <krzysztof.kolodzinski@problematy.pl>"]
6
6
  readme = "README.md"
@@ -22,6 +22,18 @@ aiohttp = "^3.8.4"
22
22
  pydantic = "^2.7.1"
23
23
  platzky = "^1.0.0"
24
24
  deprecation = "^2.1.0"
25
+ sphinx = {version = "^8.0.0", optional = true}
26
+ sphinx-rtd-theme = {version = "^3.0.0", optional = true}
27
+ tomli = {version = "^2.0.0", optional = true}
28
+ myst-parser = {version = "^4.0.0", optional = true}
29
+
30
+ [tool.poetry.extras]
31
+ docs = [
32
+ "sphinx",
33
+ "sphinx-rtd-theme",
34
+ "myst-parser",
35
+ "tomli"
36
+ ]
25
37
 
26
38
  [tool.poetry.group.dev.dependencies]
27
39
  pytest = "^7.1.2"
@@ -33,6 +45,7 @@ black = "^24.8.0"
33
45
  ruff = "^0.4.4"
34
46
  platzky-redirections = "^0.1.0"
35
47
  python-semantic-release = "^10.4.1"
48
+ interrogate = "^1.7.0"
36
49
 
37
50
  [tool.poetry.group.local.dependencies]
38
51
  platzky = {path = "vendor/platzky", develop = true}
@@ -103,4 +116,13 @@ prerelease = false
103
116
 
104
117
  [tool.semantic_release.publish]
105
118
  dist_glob_patterns = ["dist/*"]
106
- upload_to_vcs_release = true
119
+ upload_to_vcs_release = true
120
+
121
+ [tool.interrogate]
122
+ fail-under = 24
123
+ ignore-init-method = true
124
+ ignore-init-module = true
125
+ ignore-magic = true
126
+ ignore-private = true
127
+ ignore-semiprivate = false
128
+ exclude = ["tests", "docs"]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes