goodmap 1.1.1__py3-none-any.whl → 1.1.2__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 CHANGED
@@ -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)
goodmap/db.py CHANGED
@@ -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
 
@@ -1320,6 +1457,8 @@ def delete_report(db, report_id):
1320
1457
 
1321
1458
  def extend_db_with_goodmap_queries(db, location_model):
1322
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))
1323
1462
  db.extend("get_locations", get_locations(db, location_model))
1324
1463
  db.extend("get_locations_paginated", get_locations_paginated(db, location_model))
1325
1464
  db.extend("get_location", get_location(db, location_model))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: goodmap
3
- Version: 1.1.1
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)
@@ -1,15 +1,15 @@
1
1
  goodmap/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
2
2
  goodmap/config.py,sha256=sseE4sceFB8OBuFsrRpQJvjv0Vg5KFdkzihBX_hbE2c,1313
3
3
  goodmap/core.py,sha256=rzMhOIYnR1jxTX6uHQJKIPLYxdUm4_v2d6LrtHtJpHU,1465
4
- goodmap/core_api.py,sha256=MxJ7SGOFBBnV_cBIiZoImHLaY8_FtEW-dl3od5-mIt8,13529
4
+ goodmap/core_api.py,sha256=RVG4X64BSXTIzmj9mPK1DcT9p6xD00NnmX8FUaoj-uE,13277
5
5
  goodmap/data_models/location.py,sha256=H3EKozc-WZvrYm6cwajl8_gaw4rQhxdlvxR1mk4mpkA,1104
6
6
  goodmap/data_validator.py,sha256=lBmVAPxvSmEOdUGeVYSjUvVVmKfPyq4CWoHfczTtEMM,4090
7
- goodmap/db.py,sha256=UKWrd0b0zvz8T-bjnclXXLAtW-1fcxv8Rd6z_Dqmpvg,43695
7
+ goodmap/db.py,sha256=y8yRwlp2TQnSgfmn3qHXOt1UPO71yqHwQN0LckcNk7o,47725
8
8
  goodmap/formatter.py,sha256=VlUHcK1HtM_IEU0VE3S5TOkZLVheMdakvUeW2tCKdq0,783
9
9
  goodmap/goodmap.py,sha256=q6okPopWBH6jDkKJcGDegebaapHLFUVilJ3p3aKi97k,2960
10
10
  goodmap/templates/goodmap-admin.html,sha256=39PJ1drk_xdkyzXgPZZNXYq9gA9oTVeR8hsgeae6E0g,35614
11
11
  goodmap/templates/map.html,sha256=N4N0ONzEFUS4bFtOA2jgXVbMQ7cKd1cRYIVnGLUzBIE,3995
12
- goodmap-1.1.1.dist-info/METADATA,sha256=GHTcCxF_L_qMoEoFI6Re3DAyriNrKA9Y6Hau-8vji7Y,5356
13
- goodmap-1.1.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
14
- goodmap-1.1.1.dist-info/licenses/LICENSE.md,sha256=nkCQOR7uheLRvHRfXmwx9LhBnMcPeBU9d4ebLojDiQU,1067
15
- goodmap-1.1.1.dist-info/RECORD,,
12
+ goodmap-1.1.2.dist-info/METADATA,sha256=X2grUYh0m9TtQEceRzy5knUJT6HwWyBQihyF9KmIdjs,5619
13
+ goodmap-1.1.2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
14
+ goodmap-1.1.2.dist-info/licenses/LICENSE.md,sha256=nkCQOR7uheLRvHRfXmwx9LhBnMcPeBU9d4ebLojDiQU,1067
15
+ goodmap-1.1.2.dist-info/RECORD,,