goodmap 1.1.1__py3-none-any.whl → 1.1.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 +2 -7
- goodmap/db.py +148 -13
- {goodmap-1.1.1.dist-info → goodmap-1.1.3.dist-info}/METADATA +6 -1
- {goodmap-1.1.1.dist-info → goodmap-1.1.3.dist-info}/RECORD +6 -6
- {goodmap-1.1.1.dist-info → goodmap-1.1.3.dist-info}/WHEEL +0 -0
- {goodmap-1.1.1.dist-info → goodmap-1.1.3.dist-info}/licenses/LICENSE.md +0 -0
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
|
-
|
|
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
|
|
@@ -332,7 +333,7 @@ def json_file_db_get_location_obligatory_fields(db):
|
|
|
332
333
|
|
|
333
334
|
|
|
334
335
|
def google_json_db_get_location_obligatory_fields(db):
|
|
335
|
-
return
|
|
336
|
+
return db.data.get("map", {}).get("location_obligatory_fields", [])
|
|
336
337
|
|
|
337
338
|
|
|
338
339
|
def mongodb_db_get_location_obligatory_fields(db):
|
|
@@ -351,7 +352,7 @@ def get_location_obligatory_fields(db):
|
|
|
351
352
|
|
|
352
353
|
|
|
353
354
|
def google_json_db_get_data(self):
|
|
354
|
-
return
|
|
355
|
+
return self.data.get("map", {})
|
|
355
356
|
|
|
356
357
|
|
|
357
358
|
def json_file_db_get_data(self):
|
|
@@ -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
|
|
|
@@ -401,7 +538,7 @@ def json_file_db_get_categories(self):
|
|
|
401
538
|
|
|
402
539
|
|
|
403
540
|
def google_json_db_get_categories(self):
|
|
404
|
-
return
|
|
541
|
+
return self.data.get("map", {}).get("categories", {}).keys()
|
|
405
542
|
|
|
406
543
|
|
|
407
544
|
def mongodb_db_get_categories(self):
|
|
@@ -454,17 +591,17 @@ def json_file_db_get_category_data(self, category_type=None):
|
|
|
454
591
|
|
|
455
592
|
|
|
456
593
|
def google_json_db_get_category_data(self, category_type=None):
|
|
457
|
-
data =
|
|
594
|
+
data = self.data.get("map", {})
|
|
458
595
|
if category_type:
|
|
459
596
|
return {
|
|
460
|
-
"categories": {category_type: data
|
|
597
|
+
"categories": {category_type: data.get("categories", {}).get(category_type, [])},
|
|
461
598
|
"categories_help": data.get("categories_help", []),
|
|
462
599
|
"categories_options_help": {
|
|
463
600
|
category_type: data.get("categories_options_help", {}).get(category_type, [])
|
|
464
601
|
},
|
|
465
602
|
}
|
|
466
603
|
return {
|
|
467
|
-
"categories": data
|
|
604
|
+
"categories": data.get("categories", {}),
|
|
468
605
|
"categories_help": data.get("categories_help", []),
|
|
469
606
|
"categories_options_help": data.get("categories_options_help", {}),
|
|
470
607
|
}
|
|
@@ -507,9 +644,7 @@ def get_location_from_raw_data(raw_data, uuid, location_model):
|
|
|
507
644
|
|
|
508
645
|
|
|
509
646
|
def google_json_db_get_location(self, uuid, location_model):
|
|
510
|
-
return get_location_from_raw_data(
|
|
511
|
-
json.loads(self.blob.download_as_text(client=None))["map"], uuid, location_model
|
|
512
|
-
)
|
|
647
|
+
return get_location_from_raw_data(self.data.get("map", {}), uuid, location_model)
|
|
513
648
|
|
|
514
649
|
|
|
515
650
|
def json_file_db_get_location(self, uuid, location_model):
|
|
@@ -541,9 +676,7 @@ def get_locations_list_from_raw_data(map_data, query, location_model):
|
|
|
541
676
|
|
|
542
677
|
|
|
543
678
|
def google_json_db_get_locations(self, query, location_model):
|
|
544
|
-
return get_locations_list_from_raw_data(
|
|
545
|
-
json.loads(self.blob.download_as_text(client=None))["map"], query, location_model
|
|
546
|
-
)
|
|
679
|
+
return get_locations_list_from_raw_data(self.data.get("map", {}), query, location_model)
|
|
547
680
|
|
|
548
681
|
|
|
549
682
|
def json_file_db_get_locations(self, query, location_model):
|
|
@@ -573,7 +706,7 @@ def get_locations(db, location_model):
|
|
|
573
706
|
def google_json_db_get_locations_paginated(self, query, location_model):
|
|
574
707
|
"""Google JSON locations with improved pagination."""
|
|
575
708
|
# Get all locations from raw data
|
|
576
|
-
data =
|
|
709
|
+
data = self.data.get("map", {})
|
|
577
710
|
all_locations = list(get_locations_list_from_raw_data(data, query, location_model))
|
|
578
711
|
return PaginationHelper.create_paginated_response(all_locations, query)
|
|
579
712
|
|
|
@@ -1320,6 +1453,8 @@ def delete_report(db, report_id):
|
|
|
1320
1453
|
|
|
1321
1454
|
def extend_db_with_goodmap_queries(db, location_model):
|
|
1322
1455
|
db.extend("get_data", get_data(db))
|
|
1456
|
+
db.extend("get_visible_data", get_visible_data(db))
|
|
1457
|
+
db.extend("get_meta_data", get_meta_data(db))
|
|
1323
1458
|
db.extend("get_locations", get_locations(db, location_model))
|
|
1324
1459
|
db.extend("get_locations_paginated", get_locations_paginated(db, location_model))
|
|
1325
1460
|
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.
|
|
3
|
+
Version: 1.1.3
|
|
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
|

|
|
@@ -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=
|
|
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=
|
|
7
|
+
goodmap/db.py,sha256=2yZIQO6KbN6y21gxwO0xmxXIcXXrk7wqd7mgSOAefJw,47491
|
|
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.
|
|
13
|
-
goodmap-1.1.
|
|
14
|
-
goodmap-1.1.
|
|
15
|
-
goodmap-1.1.
|
|
12
|
+
goodmap-1.1.3.dist-info/METADATA,sha256=CstkaPb9MW6r9Pj03bVWuCfEmW-juFPr9UGe30l3Fyo,5619
|
|
13
|
+
goodmap-1.1.3.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
14
|
+
goodmap-1.1.3.dist-info/licenses/LICENSE.md,sha256=nkCQOR7uheLRvHRfXmwx9LhBnMcPeBU9d4ebLojDiQU,1067
|
|
15
|
+
goodmap-1.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|