goodmap 0.5.2__tar.gz → 0.5.3__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.3
2
2
  Name: goodmap
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: Map engine to serve all the people :)
5
5
  Author: Krzysztof Kolodzinski
6
6
  Author-email: krzysztof.kolodzinski@problematy.pl
@@ -13,6 +13,15 @@ def make_tuple_translation(keys_to_translate):
13
13
  return [(x, gettext(x)) for x in keys_to_translate]
14
14
 
15
15
 
16
+ def get_or_none(data, *keys):
17
+ for key in keys:
18
+ if isinstance(data, dict):
19
+ data = data.get(key)
20
+ else:
21
+ return None
22
+ return data
23
+
24
+
16
25
  def paginate_results(items, raw_params, sort_by_default=None):
17
26
  """
18
27
  Apply pagination and sorting to a list of items.
@@ -82,7 +91,12 @@ def paginate_results(items, raw_params, sort_by_default=None):
82
91
 
83
92
 
84
93
  def core_pages(
85
- database, languages: LanguagesMapping, notifier_function, csrf_generator, location_model
94
+ database,
95
+ languages: LanguagesMapping,
96
+ notifier_function,
97
+ csrf_generator,
98
+ location_model,
99
+ feature_flags={},
86
100
  ) -> Blueprint:
87
101
  core_api_blueprint = Blueprint("api", __name__, url_prefix="/api")
88
102
  core_api = Api(core_api_blueprint, doc="/doc", version="0.1")
@@ -195,7 +209,19 @@ def core_pages(
195
209
  """Shows all available categories"""
196
210
  all_data = database.get_data()
197
211
  categories = make_tuple_translation(all_data["categories"].keys())
198
- return jsonify(categories)
212
+
213
+ if not feature_flags.get("CATEGORIES_HELP", False):
214
+ return jsonify(categories)
215
+ else:
216
+ categories_help = all_data["categories_help"]
217
+ proper_categories_help = []
218
+ if categories_help is not None:
219
+ for option in categories_help:
220
+ proper_categories_help.append(
221
+ {option: gettext(f"categories_help_{option}")}
222
+ )
223
+
224
+ return jsonify({"categories": categories, "categories_help": proper_categories_help})
199
225
 
200
226
  @core_api.route("/languages")
201
227
  class Languages(Resource):
@@ -209,7 +235,25 @@ def core_pages(
209
235
  """Shows all available types in category"""
210
236
  all_data = database.get_data()
211
237
  local_data = make_tuple_translation(all_data["categories"][category_type])
212
- return jsonify(local_data)
238
+
239
+ categories_options_help = get_or_none(
240
+ all_data, "categories_options_help", category_type
241
+ )
242
+ proper_categories_options_help = []
243
+ if categories_options_help is not None:
244
+ for option in categories_options_help:
245
+ proper_categories_options_help.append(
246
+ {option: gettext(f"categories_options_help_{option}")}
247
+ )
248
+ if not feature_flags.get("CATEGORIES_HELP", False):
249
+ return jsonify(local_data)
250
+ else:
251
+ return jsonify(
252
+ {
253
+ "categories_options": local_data,
254
+ "categories_options_help": proper_categories_options_help,
255
+ }
256
+ )
213
257
 
214
258
  @core_api.route("/generate-csrf-token")
215
259
  class CsrfToken(Resource):
@@ -40,7 +40,12 @@ def create_app_from_config(config: Config) -> platzky.Engine:
40
40
  CSRFProtect(app)
41
41
 
42
42
  cp = core_pages(
43
- app.db, languages_dict(config.languages), app.notify, generate_csrf, location_model
43
+ app.db,
44
+ languages_dict(config.languages),
45
+ app.notify,
46
+ generate_csrf,
47
+ location_model,
48
+ feature_flags=config.feature_flags,
44
49
  )
45
50
  app.register_blueprint(cp)
46
51
  goodmap = Blueprint("goodmap", __name__, url_prefix="/", template_folder="templates")
@@ -117,6 +117,7 @@ window.SHOW_SUGGEST_NEW_POINT_BUTTON = {{ feature_flags.SHOW_SUGGEST_NEW_POINT_B
117
117
  window.SHOW_SEARCH_BAR = {{ feature_flags.SHOW_SEARCH_BAR | default(false) | tojson }};
118
118
  window.USE_LAZY_LOADING = {{ feature_flags.USE_LAZY_LOADING | default(false) | tojson }};
119
119
  window.SHOW_ACCESSIBILITY_TABLE = {{ feature_flags.SHOW_ACCESSIBILITY_TABLE | default(false) | tojson }};
120
+ window.FEATURE_FLAGS = {{ feature_flags | tojson }};
120
121
  </script>
121
122
  <script src="/static/map.js"></script>
122
123
  {% endblock %}
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "goodmap"
3
- version = "0.5.2"
3
+ version = "0.5.3"
4
4
  description = "Map engine to serve all the people :)"
5
5
  authors = ["Krzysztof Kolodzinski <krzysztof.kolodzinski@problematy.pl>"]
6
6
  readme = "README.md"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes