territories-dashboard-lib 0.1.18__py3-none-any.whl → 0.1.20__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.

Potentially problematic release.


This version of territories-dashboard-lib might be problematic. Click here for more details.

@@ -11,8 +11,32 @@ def get_breakdown_dimension(indicator):
11
11
  return breakdown_dimension
12
12
 
13
13
 
14
+ def get_connection():
15
+ """
16
+ The connection to the indicators database is defined in DATABASES
17
+ The key for the database in DATABASES is defined in settings.INDICATORS_DATABASE
18
+ During testing, the connection can also be defined in READONLY_DATABASES_HANDLER
19
+ which defines a readonly database which will not be recreated during tests
20
+ """
21
+ connection = None
22
+ indicators_database = getattr(settings, "INDICATORS_DATABASE", None)
23
+ if indicators_database:
24
+ connection = connections[indicators_database]
25
+ else:
26
+ testing = getattr(settings, "TESTING", False)
27
+ readonly_databases_handler = getattr(
28
+ settings, "READONLY_DATABASES_HANDLER", None
29
+ )
30
+ if testing and readonly_databases_handler:
31
+ connection = readonly_databases_handler["default"]
32
+ if connection is None:
33
+ raise ValueError("No connection was defined for the indicators database")
34
+ return connection
35
+
36
+
14
37
  def run_custom_query(query, params=None):
15
- with connections[settings.INDICATORS_DATABASE].cursor() as cursor:
38
+ connection = get_connection()
39
+ with connection.cursor() as cursor:
16
40
  cursor.execute(query, params)
17
41
  columns = [col[0] for col in cursor.description]
18
42
  rows = cursor.fetchall()
@@ -36,7 +36,7 @@ urlpatterns = [
36
36
  path(
37
37
  "<str:name>/values/export/",
38
38
  indicator_values_export_view,
39
- name="values",
39
+ name="values-export",
40
40
  ),
41
41
  path(
42
42
  "<str:name>/values/",
@@ -1,5 +1,3 @@
1
- import html
2
-
3
1
  from territories_dashboard_lib.indicators_lib.enums import MeshLevel
4
2
  from territories_dashboard_lib.indicators_lib.query.utils import run_custom_query
5
3
 
@@ -63,7 +61,7 @@ def make_filter(dashboard: Dashboard, territory_id: str, territory_mesh: MeshLev
63
61
  for f in dashboard.filters.all():
64
62
  value = territory_meshes.get(f.mesh)
65
63
  if value:
66
- value = html.escape(value)
64
+ value = value.replace("'", "!'") # RISON escape
67
65
  filter_string = f"""NATIVE_FILTER-{f.superset_id}:(__cache:(label:'{value}',validateStatus:!f,value:!('{value}')),extraFormData:(filters:!((col:{f.superset_col},op:IN,val:!('{value}')))),filterState:(label:'{value}',validateStatus:!f,value:!('{value}')),id:NATIVE_FILTER-{f.superset_id},ownState:())"""
68
66
  filters.append(filter_string)
69
67
  if not filters:
@@ -201,13 +201,9 @@ class ParamsHandler:
201
201
  for m in get_all_meshes()
202
202
  if not (m == MeshLevel.Town and max_territory_mesh == MeshLevel.National)
203
203
  ]
204
- print("MESHES", meshes)
205
204
  min_mesh_index = meshes.index(max_territory_mesh)
206
- print("index", min_mesh_index)
207
205
  if get_allow_same_mesh() is False:
208
206
  min_mesh_index += 1
209
- print("AGAIN", min_mesh_index)
210
- print("Allow same mesh", get_allow_same_mesh())
211
207
  self.meshes = meshes[min(min_mesh_index, len(meshes) - 1) :]
212
208
 
213
209
  ######################## Commons
@@ -278,7 +274,6 @@ def with_params(view_func):
278
274
 
279
275
  response = view_func(request, *args, context=context, **kwargs)
280
276
  handler.set_cookie(response)
281
- print(context["params"])
282
277
  return response
283
278
 
284
279
  return wrapper
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: territories-dashboard-lib
3
- Version: 0.1.18
3
+ Version: 0.1.20
4
4
  Summary: Librairie pour la visualisation d'indicateurs territoriaux.
5
5
  Author-email: Bastien <bastien@prune.sh>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -20,7 +20,7 @@ territories_dashboard_lib/indicators_lib/models.py,sha256=9f8XmM_WDuIjQTF9V3p3BA
20
20
  territories_dashboard_lib/indicators_lib/payloads.py,sha256=I03bgoNoLTehd8lfby0xbSy2zUXKRILMUOqYGqvg-Ig,1288
21
21
  territories_dashboard_lib/indicators_lib/refresh_filters.py,sha256=uPdKKcCtfwQL2QoGXtRcZcxagYpVv2yiiiTTsCYaXEI,652
22
22
  territories_dashboard_lib/indicators_lib/table.py,sha256=BsvimE68NxXdRI7xnUVYK1axZRZTywVpSUDEtAYWlMo,5332
23
- territories_dashboard_lib/indicators_lib/urls.py,sha256=BrizGcGJzvcijMvkImMzsi4zRzsgw4fl_cIScsfDYcU,2482
23
+ territories_dashboard_lib/indicators_lib/urls.py,sha256=1Rr5mDOitIA40bZcO3lGlseQsvXIwyw1QM6PyUPi_Nw,2489
24
24
  territories_dashboard_lib/indicators_lib/views.py,sha256=EH0bMC_zCXXpou6hqohk2tni3oGLR5rZGVFHu1QH3a4,17138
25
25
  territories_dashboard_lib/indicators_lib/migrations/0001_initial.py,sha256=3EyizMGkqve5Gtxrmf-mADzzmOhcAVWe-P0y1TIBKCs,8092
26
26
  territories_dashboard_lib/indicators_lib/migrations/0002_filter_color_indicator_min_mesh_and_more.py,sha256=Lz6_UVKLAmaRT-OskwbTMh3PjIh0k4BaGyIOHCC8zMI,884
@@ -31,11 +31,11 @@ territories_dashboard_lib/indicators_lib/query/details.py,sha256=si43KVB5QxgQTc9
31
31
  territories_dashboard_lib/indicators_lib/query/histogram.py,sha256=NpQdAqVzm-bB5AuMZF3jOzEJKLjecwafhlorkYQY6IU,2964
32
32
  territories_dashboard_lib/indicators_lib/query/indicator_card.py,sha256=pu-oGTQ8-niIFtZP09HIgJJWkFfJb1CGX99EdsojJDw,3232
33
33
  territories_dashboard_lib/indicators_lib/query/top_10.py,sha256=3eDBd5w1ovfaMOyN3JQ5mYxBSUrcRJjR1i0v7HG04o4,3677
34
- territories_dashboard_lib/indicators_lib/query/utils.py,sha256=nCeQCLzfq35KZzun9hpM5U34TN7JowB4t3NshIzfLAo,649
34
+ territories_dashboard_lib/indicators_lib/query/utils.py,sha256=o9tQTMSSlidH60JLo5RwVfWY3UXFCx0b44VeHiWC6cM,1610
35
35
  territories_dashboard_lib/superset_lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
36
  territories_dashboard_lib/superset_lib/admin.py,sha256=3Yj3PjCd-jC0g4uMNmah-OST-yoE7DDEzJkx2kWlrXg,563
37
37
  territories_dashboard_lib/superset_lib/guest_token.py,sha256=smsl11NS2Sgsuz5UJlvI_lDaBi6Fj9rdpSVmuUol8Fs,2300
38
- territories_dashboard_lib/superset_lib/logic.py,sha256=upbhWFGkkiMPM8MMtPrGf5FONdbt1zBPT46tcn5Wv3g,2483
38
+ territories_dashboard_lib/superset_lib/logic.py,sha256=vVzSimSlrwefVVdEf2dMr83MW2c_yB4k2uw_Szu_nHg,2492
39
39
  territories_dashboard_lib/superset_lib/models.py,sha256=D_IKcYggr8OeH4Gc9KxmU0ArQ3lq8DFN-e0JDQs9Dng,2613
40
40
  territories_dashboard_lib/superset_lib/serializers.py,sha256=k5DcdwN-k5w9dPchiyxBZtG3BAULp8c00JTO3DR6rA4,250
41
41
  territories_dashboard_lib/superset_lib/urls.py,sha256=URXJLciWDTlzU7gIymlK0nWwAm3Iq8bMkhO0P7RwMuk,254
@@ -63,7 +63,7 @@ territories_dashboard_lib/website_lib/context_processors.py,sha256=Xq9W_w86Oh242
63
63
  territories_dashboard_lib/website_lib/forms.py,sha256=BNbHx6CgMlA33z6eD-1VaI7AkyO20ZsloJKsec4BcoU,1146
64
64
  territories_dashboard_lib/website_lib/models.py,sha256=y5L7MtONhA9oev5UI6rBejHexLo7r1v_XyxB8h2OEs4,5356
65
65
  territories_dashboard_lib/website_lib/navigation.py,sha256=D9YNfBVPpO9bRgNT02j99sp0A0_uqDaBgc25BbQOako,3994
66
- territories_dashboard_lib/website_lib/params.py,sha256=M7a3SsLpFiGsPlHy9hOzbwvnWRGyOHSCeDLym70gFTA,10067
66
+ territories_dashboard_lib/website_lib/params.py,sha256=RiRMbj5TJxyUUuf-_H98X5UucJlh9gICXofJrDTv6Jg,9868
67
67
  territories_dashboard_lib/website_lib/serializers.py,sha256=PVcOC52zlNn2tp7IRwMuB4T7rOaLl3bLKiqqesWgRE4,3772
68
68
  territories_dashboard_lib/website_lib/static_content.py,sha256=08Fw3190RsTZ8wXwZkmskh-86widq7NRmTD9Ve-9PJY,589
69
69
  territories_dashboard_lib/website_lib/views.py,sha256=ZNz23Vrws-L49xeZzrhSJA8KFpqSnURn-9-b0RdR9JE,6760
@@ -173,8 +173,8 @@ territories_dashboard_lib/website_lib/templates/territories_dashboard_lib/websit
173
173
  territories_dashboard_lib/website_lib/templates/territories_dashboard_lib/website/svg/delete-back.svg,sha256=fJPjkZT2jdTcW2nmwr7YtBayOmQKOxiGNyO8bM8jP2U,618
174
174
  territories_dashboard_lib/website_lib/templatetags/htmlparams.py,sha256=jWXlmT-nFh7YefVP_zJSXEA1YgT37wnWqelPhmj7UoM,2092
175
175
  territories_dashboard_lib/website_lib/templatetags/other_filters.py,sha256=EEczSQi8lJZ_rfceuXQz3iF1SIxh5d-3-liTY8lkKtU,944
176
- territories_dashboard_lib-0.1.18.dist-info/licenses/licence.md,sha256=9Tat8mM_Yyww-wmWps8avlOhzumqEUGYy8853tKy7aE,7804
177
- territories_dashboard_lib-0.1.18.dist-info/METADATA,sha256=KYZodmgolAFZaZftmzy1o8EfGdQtaFI2zF9o4p6YQkM,6191
178
- territories_dashboard_lib-0.1.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
179
- territories_dashboard_lib-0.1.18.dist-info/top_level.txt,sha256=Cih-lil8CSXTpDZV6fgHKIKIBtUjDaNpmkiuW2TSzsk,26
180
- territories_dashboard_lib-0.1.18.dist-info/RECORD,,
176
+ territories_dashboard_lib-0.1.20.dist-info/licenses/licence.md,sha256=9Tat8mM_Yyww-wmWps8avlOhzumqEUGYy8853tKy7aE,7804
177
+ territories_dashboard_lib-0.1.20.dist-info/METADATA,sha256=V2rYOF3qDF6uN1aMWqb-kZvITZUrMgCPwwqimHlxodw,6191
178
+ territories_dashboard_lib-0.1.20.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
179
+ territories_dashboard_lib-0.1.20.dist-info/top_level.txt,sha256=Cih-lil8CSXTpDZV6fgHKIKIBtUjDaNpmkiuW2TSzsk,26
180
+ territories_dashboard_lib-0.1.20.dist-info/RECORD,,