goodmap 1.4.0__py3-none-any.whl → 1.5.0__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 +21 -19
- goodmap/feature_flags.py +7 -0
- goodmap/goodmap.py +4 -17
- {goodmap-1.4.0.dist-info → goodmap-1.5.0.dist-info}/METADATA +3 -3
- {goodmap-1.4.0.dist-info → goodmap-1.5.0.dist-info}/RECORD +7 -6
- {goodmap-1.4.0.dist-info → goodmap-1.5.0.dist-info}/LICENSE.md +0 -0
- {goodmap-1.4.0.dist-info → goodmap-1.5.0.dist-info}/WHEEL +0 -0
goodmap/core_api.py
CHANGED
|
@@ -7,6 +7,7 @@ import numpy
|
|
|
7
7
|
import pysupercluster
|
|
8
8
|
from flask import Blueprint, jsonify, make_response, request
|
|
9
9
|
from flask_babel import gettext
|
|
10
|
+
from platzky import FeatureFlagSet
|
|
10
11
|
from platzky.attachment import AttachmentProtocol
|
|
11
12
|
from platzky.config import AttachmentConfig, LanguagesMapping
|
|
12
13
|
from spectree import Response, SpecTree
|
|
@@ -24,6 +25,7 @@ from goodmap.clustering import (
|
|
|
24
25
|
match_clusters_uuids,
|
|
25
26
|
)
|
|
26
27
|
from goodmap.exceptions import LocationValidationError
|
|
28
|
+
from goodmap.feature_flags import CategoriesHelp
|
|
27
29
|
from goodmap.formatter import prepare_pin
|
|
28
30
|
from goodmap.json_security import (
|
|
29
31
|
MAX_JSON_DEPTH_LOCATION,
|
|
@@ -83,7 +85,7 @@ def core_pages(
|
|
|
83
85
|
location_model,
|
|
84
86
|
photo_attachment_class: type[AttachmentProtocol],
|
|
85
87
|
photo_attachment_config: AttachmentConfig,
|
|
86
|
-
feature_flags
|
|
88
|
+
feature_flags: FeatureFlagSet,
|
|
87
89
|
) -> Blueprint:
|
|
88
90
|
core_api_blueprint = Blueprint("api", __name__, url_prefix="/api")
|
|
89
91
|
|
|
@@ -383,15 +385,15 @@ def core_pages(
|
|
|
383
385
|
raw_categories = database.get_categories()
|
|
384
386
|
categories = make_tuple_translation(raw_categories)
|
|
385
387
|
|
|
386
|
-
if not feature_flags
|
|
388
|
+
if CategoriesHelp not in feature_flags:
|
|
387
389
|
return jsonify(categories)
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
390
|
+
|
|
391
|
+
category_data = database.get_category_data()
|
|
392
|
+
categories_help = category_data.get("categories_help")
|
|
393
|
+
proper_categories_help = []
|
|
394
|
+
if categories_help is not None:
|
|
395
|
+
for option in categories_help:
|
|
396
|
+
proper_categories_help.append({option: gettext(f"categories_help_{option}")})
|
|
395
397
|
|
|
396
398
|
return jsonify({"categories": categories, "categories_help": proper_categories_help})
|
|
397
399
|
|
|
@@ -415,7 +417,7 @@ def core_pages(
|
|
|
415
417
|
"options": make_tuple_translation(options),
|
|
416
418
|
}
|
|
417
419
|
|
|
418
|
-
if feature_flags
|
|
420
|
+
if CategoriesHelp in feature_flags:
|
|
419
421
|
option_help_list = categories_options_help.get(key, [])
|
|
420
422
|
proper_options_help = []
|
|
421
423
|
for option in option_help_list:
|
|
@@ -428,7 +430,7 @@ def core_pages(
|
|
|
428
430
|
|
|
429
431
|
response = {"categories": result}
|
|
430
432
|
|
|
431
|
-
if feature_flags
|
|
433
|
+
if CategoriesHelp in feature_flags:
|
|
432
434
|
categories_help = categories_data.get("categories_help", [])
|
|
433
435
|
proper_categories_help = []
|
|
434
436
|
for option in categories_help:
|
|
@@ -466,15 +468,15 @@ def core_pages(
|
|
|
466
468
|
proper_categories_options_help.append(
|
|
467
469
|
{option: gettext(f"categories_options_help_{option}")}
|
|
468
470
|
)
|
|
469
|
-
if not feature_flags
|
|
471
|
+
if CategoriesHelp not in feature_flags:
|
|
470
472
|
return jsonify(local_data)
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
473
|
+
|
|
474
|
+
return jsonify(
|
|
475
|
+
{
|
|
476
|
+
"categories_options": local_data,
|
|
477
|
+
"categories_options_help": proper_categories_options_help,
|
|
478
|
+
}
|
|
479
|
+
)
|
|
478
480
|
|
|
479
481
|
# Register Spectree with blueprint after all routes are defined
|
|
480
482
|
spec.register(core_api_blueprint)
|
goodmap/feature_flags.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
from platzky import FeatureFlag
|
|
2
|
+
|
|
3
|
+
CategoriesHelp = FeatureFlag(alias="CATEGORIES_HELP", description="Show category help text")
|
|
4
|
+
UseLazyLoading = FeatureFlag(
|
|
5
|
+
alias="USE_LAZY_LOADING", description="Enable lazy loading of location fields"
|
|
6
|
+
)
|
|
7
|
+
EnableAdminPanel = FeatureFlag(alias="ENABLE_ADMIN_PANEL", description="Enable admin panel")
|
goodmap/goodmap.py
CHANGED
|
@@ -18,6 +18,7 @@ from goodmap.db import (
|
|
|
18
18
|
extend_db_with_goodmap_queries,
|
|
19
19
|
get_location_obligatory_fields,
|
|
20
20
|
)
|
|
21
|
+
from goodmap.feature_flags import EnableAdminPanel, UseLazyLoading
|
|
21
22
|
|
|
22
23
|
logger = logging.getLogger(__name__)
|
|
23
24
|
|
|
@@ -35,20 +36,6 @@ def create_app(config_path: str) -> platzky.Engine:
|
|
|
35
36
|
return create_app_from_config(config)
|
|
36
37
|
|
|
37
38
|
|
|
38
|
-
# TODO Checking if there is a feature flag secition should be part of configs logic not client app
|
|
39
|
-
def is_feature_enabled(config: GoodmapConfig, feature: str) -> bool:
|
|
40
|
-
"""Check if a feature flag is enabled in the configuration.
|
|
41
|
-
|
|
42
|
-
Args:
|
|
43
|
-
config: Goodmap configuration object
|
|
44
|
-
feature: Name of the feature flag to check
|
|
45
|
-
|
|
46
|
-
Returns:
|
|
47
|
-
bool: True if feature is enabled, False otherwise
|
|
48
|
-
"""
|
|
49
|
-
return config.feature_flags.get(feature, False) if config.feature_flags else False
|
|
50
|
-
|
|
51
|
-
|
|
52
39
|
def create_app_from_config(config: GoodmapConfig) -> platzky.Engine:
|
|
53
40
|
"""Create and configure Goodmap application from config object.
|
|
54
41
|
|
|
@@ -73,7 +60,7 @@ def create_app_from_config(config: GoodmapConfig) -> platzky.Engine:
|
|
|
73
60
|
if "MAX_CONTENT_LENGTH" not in app.config:
|
|
74
61
|
app.config["MAX_CONTENT_LENGTH"] = 100 * 1024 # 100KB
|
|
75
62
|
|
|
76
|
-
if
|
|
63
|
+
if app.is_enabled(UseLazyLoading):
|
|
77
64
|
location_obligatory_fields = get_location_obligatory_fields(app.db)
|
|
78
65
|
# Extend db with goodmap queries first so we can use the bound method
|
|
79
66
|
location_model = create_location_model(location_obligatory_fields, {})
|
|
@@ -175,7 +162,7 @@ def create_app_from_config(config: GoodmapConfig) -> platzky.Engine:
|
|
|
175
162
|
Returns:
|
|
176
163
|
Rendered goodmap-admin.html template or redirect to login
|
|
177
164
|
"""
|
|
178
|
-
if not
|
|
165
|
+
if not app.is_enabled(EnableAdminPanel):
|
|
179
166
|
return redirect("/")
|
|
180
167
|
|
|
181
168
|
user = session.get("user", None)
|
|
@@ -194,7 +181,7 @@ def create_app_from_config(config: GoodmapConfig) -> platzky.Engine:
|
|
|
194
181
|
|
|
195
182
|
app.register_blueprint(goodmap)
|
|
196
183
|
|
|
197
|
-
if
|
|
184
|
+
if app.is_enabled(EnableAdminPanel):
|
|
198
185
|
admin_bp = admin_pages(app.db, location_model)
|
|
199
186
|
app.register_blueprint(admin_bp)
|
|
200
187
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: goodmap
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
Summary: Map engine to serve all the people :)
|
|
5
5
|
Author: Krzysztof Kolodzinski
|
|
6
6
|
Author-email: krzysztof.kolodzinski@problematy.pl
|
|
@@ -20,11 +20,11 @@ Requires-Dist: aiohttp (>=3.8.4,<4.0.0)
|
|
|
20
20
|
Requires-Dist: deprecation (>=2.1.0,<3.0.0)
|
|
21
21
|
Requires-Dist: google-cloud-storage (>=2.7.0,<3.0.0)
|
|
22
22
|
Requires-Dist: gql (>=3.4.0,<4.0.0)
|
|
23
|
-
Requires-Dist: gunicorn (>=20.1,<
|
|
23
|
+
Requires-Dist: gunicorn (>=20.1,<25.0)
|
|
24
24
|
Requires-Dist: humanize (>=4.6.0,<5.0.0)
|
|
25
25
|
Requires-Dist: myst-parser (>=4.0.0,<5.0.0) ; extra == "docs"
|
|
26
26
|
Requires-Dist: numpy (>=2.2.0,<3.0.0)
|
|
27
|
-
Requires-Dist: platzky (>=1.
|
|
27
|
+
Requires-Dist: platzky (>=1.4.1,<2.0.0)
|
|
28
28
|
Requires-Dist: pydantic (>=2.7.1,<3.0.0)
|
|
29
29
|
Requires-Dist: pysupercluster-problematy (>=0.7.8,<0.8.0)
|
|
30
30
|
Requires-Dist: scipy (>=1.15.1,<2.0.0)
|
|
@@ -4,17 +4,18 @@ goodmap/api_models.py,sha256=Bv4OTGuckNneCrxaQ1Y_PMeu7YFLvGUqU2EorvDlUjY,3438
|
|
|
4
4
|
goodmap/clustering.py,sha256=ULB-fPNOUDblgpBK4vzuo0o2yqIcvG84F3R6Za2X_l4,2905
|
|
5
5
|
goodmap/config.py,sha256=CsmC1zuvVab90VW50dtARHbFJpy2vfsIfbque8Zgc-U,1313
|
|
6
6
|
goodmap/core.py,sha256=AgdGLfeJvL7TlTX893NR2YdCS8EuXx93Gx6ndvWws7s,2673
|
|
7
|
-
goodmap/core_api.py,sha256=
|
|
7
|
+
goodmap/core_api.py,sha256=CnQHXzSxym-URHE4teVkyOAT-iIMWWEX0cP7R_01Tg4,19981
|
|
8
8
|
goodmap/data_models/location.py,sha256=_I27R06ovEL9ctv_SZ3yoLL-RwmyE3VDsVOG4a89q50,6798
|
|
9
9
|
goodmap/data_validator.py,sha256=lBmVAPxvSmEOdUGeVYSjUvVVmKfPyq4CWoHfczTtEMM,4090
|
|
10
10
|
goodmap/db.py,sha256=TcqYGbK5yk6S735Si1AzjNqcbB1nsd9pFGOy5qN9Vec,46589
|
|
11
11
|
goodmap/exceptions.py,sha256=jkFAUoc5LHk8iPjxHxbcRp8W6qFCSEA25A8XaSwxwyo,2906
|
|
12
|
+
goodmap/feature_flags.py,sha256=-hiqTX4OlhfY_4M1Kvy-_z1Fx6YTaFi3SVGYa0Pamcw,334
|
|
12
13
|
goodmap/formatter.py,sha256=4rqcg9A9Y9opAi7eb8kMDdUC03M3uzZgCxx29cvvIag,1403
|
|
13
|
-
goodmap/goodmap.py,sha256=
|
|
14
|
+
goodmap/goodmap.py,sha256=f69aUloRe4bpx2JRwZFiHOeUSk0Exq-Qv2FCdwiwLA0,7541
|
|
14
15
|
goodmap/json_security.py,sha256=EHAxNlb16AVwphgf4F7yObtMZpbR9M538dwn_STRcMo,3275
|
|
15
16
|
goodmap/templates/goodmap-admin.html,sha256=LSiOZ9-n29CnlfVNwdgmXwT7Xe7t5gvGh1xSrFGqOIY,35669
|
|
16
17
|
goodmap/templates/map.html,sha256=Uk7FFrZwvHZvG0DDaQrGW5ZrIMD21XrJzMub76uIlAg,4348
|
|
17
|
-
goodmap-1.
|
|
18
|
-
goodmap-1.
|
|
19
|
-
goodmap-1.
|
|
20
|
-
goodmap-1.
|
|
18
|
+
goodmap-1.5.0.dist-info/LICENSE.md,sha256=nkCQOR7uheLRvHRfXmwx9LhBnMcPeBU9d4ebLojDiQU,1067
|
|
19
|
+
goodmap-1.5.0.dist-info/METADATA,sha256=PpLVvzHAcIIKEUVAqBkTZ1zcLXNnFFUivPUFIieiu6k,5798
|
|
20
|
+
goodmap-1.5.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
21
|
+
goodmap-1.5.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|