dmart 0.1.9__py3-none-any.whl → 1.4.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.
api/managed/utils.py CHANGED
@@ -469,22 +469,23 @@ async def serve_request_update(request, owner_shortname: str):
469
469
  schema_shortname=record_schema_shortname,
470
470
  )
471
471
 
472
- requested_checksum = record.attributes.get("last_checksum_history")
473
- if requested_checksum:
474
- latest_history = await db.get_latest_history(
475
- space_name=request.space_name,
476
- subpath=record.subpath,
477
- shortname=record.shortname,
478
- )
479
- if latest_history and latest_history.last_checksum_history != requested_checksum:
480
- raise api.Exception(
481
- status.HTTP_409_CONFLICT,
482
- api.Error(
483
- type="request",
484
- code=InternalErrorCode.CONFLICT,
485
- message="Resource has been updated by another request!",
486
- ),
472
+ if settings.is_sha_required:
473
+ requested_checksum = record.attributes.get("last_checksum_history")
474
+ if requested_checksum:
475
+ latest_history = await db.get_latest_history(
476
+ space_name=request.space_name,
477
+ subpath=record.subpath,
478
+ shortname=record.shortname,
487
479
  )
480
+ if latest_history and latest_history.last_checksum_history != requested_checksum:
481
+ raise api.Exception(
482
+ status.HTTP_409_CONFLICT,
483
+ api.Error(
484
+ type="request",
485
+ code=InternalErrorCode.CONFLICT,
486
+ message="Resource has been updated by another request!",
487
+ ),
488
+ )
488
489
 
489
490
  # CHECK PERMISSION
490
491
  if not await access_control.check_access(
@@ -1534,22 +1535,23 @@ async def serve_space_update(request, record, owner_shortname: str, is_replace:
1534
1535
  user_shortname=owner_shortname,
1535
1536
  )
1536
1537
 
1537
- requested_checksum = record.attributes.get("last_checksum_history")
1538
- if requested_checksum:
1539
- latest_history = await db.get_latest_history(
1540
- space_name=space.shortname,
1541
- subpath=record.subpath,
1542
- shortname=space.shortname,
1543
- )
1544
- if latest_history and latest_history.last_checksum_history != requested_checksum:
1545
- raise api.Exception(
1546
- status.HTTP_409_CONFLICT,
1547
- api.Error(
1548
- type="request",
1549
- code=InternalErrorCode.CONFLICT,
1550
- message="Resource has been updated by another request. Please refresh and try again.",
1551
- ),
1538
+ if settings.is_sha_required:
1539
+ requested_checksum = record.attributes.get("last_checksum_history")
1540
+ if requested_checksum:
1541
+ latest_history = await db.get_latest_history(
1542
+ space_name=space.shortname,
1543
+ subpath=record.subpath,
1544
+ shortname=space.shortname,
1552
1545
  )
1546
+ if latest_history and latest_history.last_checksum_history != requested_checksum:
1547
+ raise api.Exception(
1548
+ status.HTTP_409_CONFLICT,
1549
+ api.Error(
1550
+ type="request",
1551
+ code=InternalErrorCode.CONFLICT,
1552
+ message="Resource has been updated by another request. Please refresh and try again.",
1553
+ ),
1554
+ )
1553
1555
 
1554
1556
  old_flat = flatten_dict(old_space.model_dump())
1555
1557
  new_flat = flatten_dict(space.model_dump())
@@ -1379,7 +1379,7 @@ class SQLAdapter(BaseDataAdapter):
1379
1379
  ffv_resource_type.append(perm_key_splited[2])
1380
1380
 
1381
1381
  if len(ffv_spaces):
1382
- perm_key_splited_query = f'@space_name:{'|'.join(ffv_spaces)} @subpath:{f"/{'|/'.join(ffv_subpath)}"} @resource_type:{'|'.join(ffv_resource_type)} {' '.join(ffv_query)}'
1382
+ perm_key_splited_query = f'@space_name:{"|".join(ffv_spaces)} @subpath:/{"|/".join(ffv_subpath)} @resource_type:{"|".join(ffv_resource_type)} {" ".join(ffv_query)}'
1383
1383
  if query.search:
1384
1384
  query.search += f' {perm_key_splited_query}'
1385
1385
  else:
@@ -2146,7 +2146,7 @@ class SQLAdapter(BaseDataAdapter):
2146
2146
 
2147
2147
  return history_diff
2148
2148
  except Exception as e:
2149
- print("[!store_entry_diff]", e)
2149
+ print("[!store_entry_diff]", e, old_version_flattend, new_version_flattend)
2150
2150
  logger.error(f"Failed parsing an entry. Error: {e}")
2151
2151
  return {}
2152
2152
 
@@ -2466,7 +2466,7 @@ class SQLAdapter(BaseDataAdapter):
2466
2466
  try:
2467
2467
  return await self.load(space_name, "/", space_name, core.Space)
2468
2468
  except Exception as e:
2469
- print("[!fetch_space]", e)
2469
+ print("[!fetch_space]", e, space_name)
2470
2470
  return None
2471
2471
 
2472
2472
  async def set_user_session(self, user_shortname: str, token: str) -> bool:
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dmart
3
- Version: 0.1.9
4
- Requires-Python: >=3.10
3
+ Version: 1.4.0
4
+ Requires-Python: >=3.11
5
5
  Requires-Dist: fastapi
6
6
  Requires-Dist: pydantic
7
7
  Requires-Dist: pydantic[email]
@@ -19,7 +19,6 @@ Requires-Dist: pydantic-settings
19
19
  Requires-Dist: fastapi-sso
20
20
  Requires-Dist: sqlmodel
21
21
  Requires-Dist: psycopg[binary]
22
- Requires-Dist: asyncpg
23
22
  Requires-Dist: greenlet
24
23
  Requires-Dist: alembic
25
24
  Requires-Dist: jinja2
@@ -5,7 +5,7 @@ get_settings.py,sha256=Sbe2WCoiK398E7HY4SNLfDN_GmE8knR4M-YJWF31jcg,153
5
5
  main.py,sha256=XqKHlgFy_S_EtvbGsSxiCMSApSU33BlTpv8T4UWX0yc,17351
6
6
  migrate.py,sha256=hn1MZoVby_Jjqhc7y3CrLcGD619QmVZv3PONNvO7VKQ,665
7
7
  password_gen.py,sha256=xjx8wi105ZYvhLBBQj7_rugACpxifGXHse6f7YlGXWQ,196
8
- run_notification_campaign.py,sha256=wKo8B79eiATOmAnxXsOJkSvb5BGwZTAQuxN6-HfA7Ws,2907
8
+ run_notification_campaign.py,sha256=ZCvHfaimK4W6q4XuHs2r6wavMGipYYw4aUkNlxmGUd8,2652
9
9
  scheduled_notification_handler.py,sha256=m26TryqHuvXR5PUPvzY9nFnpJpfbsuRjc_Q6wHdxvE8,4643
10
10
  schema_migration.py,sha256=a1w3c-fSm95MVWFzobgy0AxIbhbzMDSfD46easTmwKE,6132
11
11
  schema_modulate.py,sha256=vB7NxvqghqNpFe__p0ll03WsvNftzxBbQ6UXB2UfxNU,6454
@@ -40,7 +40,7 @@ api/info/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
40
  api/info/router.py,sha256=sQZZor7A-uDzsJX39aqEA7bMZOJ-WTitYeFvVNWfaHw,3938
41
41
  api/managed/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
42
  api/managed/router.py,sha256=0xfJ3NXV3XHyG8yWLEECBJt-XppymOxYuMDvQJdO1MI,50865
43
- api/managed/utils.py,sha256=OZgqqWAKMXqhFOloBcm85KiE4BpZ8h0CNffK8O7Pc7c,72639
43
+ api/managed/utils.py,sha256=KyDqnGK_ndX2Uy47FmrPHmu6PpZ35IhgjGjA816x-uY,72841
44
44
  api/public/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
45
  api/public/router.py,sha256=TrraWs2LGL_c_JRDbvS8OHm3fJ-ZKF7o4El7wvjV4Mk,24753
46
46
  api/qr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -70,7 +70,7 @@ data_adapters/file/drop_index.py,sha256=OK3wXwaO9tUcHcJjqyLeBnkElzK35MZMi8YLGWdr
70
70
  data_adapters/file/health_check.py,sha256=cMvwsXhjEykjrTyB3HtUn8QqKdtB_h5w8mGOEYPepzU,24221
71
71
  data_adapters/file/redis_services.py,sha256=83STcca5fYFaEVLRYAxfUQXeUQZqJOT8XH-GBSbkR-E,39914
72
72
  data_adapters/sql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
- data_adapters/sql/adapter.py,sha256=xdd5EcZU1fF4GTBxSg4BUyKvd8o95kcf1FqtPHUN2u8,154514
73
+ data_adapters/sql/adapter.py,sha256=MlNRWjUigjjS2SRzDYNaUOsGwTFPHZQn-o0DXxKKHl8,154565
74
74
  data_adapters/sql/adapter_helpers.py,sha256=Eu22NElz2fMu6zyOsGsGrnAZcyWhHz9I__RJ9z6cwK0,15076
75
75
  data_adapters/sql/create_tables.py,sha256=KqaXHTDOD8YaqGNc_e0iHHotd0WE3Kad_tBevtoGA20,17427
76
76
  data_adapters/sql/create_users_folders.py,sha256=fm3P-CMcPX4b4DqXHKWMOtfX4RHdaev2nCDhYrS5cIs,1911
@@ -82,7 +82,7 @@ languages/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
82
82
  languages/arabic.json,sha256=UL61rP9_M42CGfU94G5-1bXVUVnsJWXzoqhaXTXTJuM,910
83
83
  languages/english.json,sha256=Y7eZ2X8c427_97qYrHOeGb2d725T-YlNNFVSi8FB7Kw,649
84
84
  languages/kurdish.json,sha256=GgPLkVKyhIQjT7h3cPfDh0oyzg26znvBUe5X_Zz2TWI,864
85
- languages/loader.py,sha256=yaBJHGVRxi8Z-H8x4MOQcwyhiY0zD9UY-m0AjLi4eq8,393
85
+ languages/loader.py,sha256=3gf2WmfSQ-AVIpyLAm_5J5NcQlWqBxQHMjcUd04Pijs,381
86
86
  models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
87
87
  models/api.py,sha256=f5X56dudyEysPmDuI5grM2RRCXuIQoehaAB6wMAGG28,6473
88
88
  models/core.py,sha256=tEb7cbnC71yE9SDluynj7dE3U8Ed-EbF3uRJizy-uuU,16880
@@ -103,7 +103,7 @@ plugins/redis_db_update/plugin.py,sha256=z05k1zNJgBnKPj-jrtMUeI9br75ZPlifbzL0Hxp
103
103
  plugins/resource_folders_creation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
104
104
  plugins/resource_folders_creation/plugin.py,sha256=OwYPtRjMt2esAAEdv1FjdZgjEz01yt2xOZQi3nB0kEQ,3327
105
105
  plugins/system_notification_sender/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
106
- plugins/system_notification_sender/plugin.py,sha256=96xzmuUGvO2WOJ5y90akDoRB7Bqy-VpOo6ht8-rLLtQ,8253
106
+ plugins/system_notification_sender/plugin.py,sha256=MUOujwyRJ3yQrXwZ-X4qSdx0ZNU2c-sYy0d0-U8twoA,8253
107
107
  plugins/update_access_controls/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
108
108
  plugins/update_access_controls/plugin.py,sha256=43UV4vg-zxBF_7Bv0AZH6gU0Bgy2ybapNK21wJTF05k,301
109
109
  pytests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -121,7 +121,7 @@ utils/access_control.py,sha256=8cCKr-6bL-Shl8j8xtfjEykMPGy6wkbNz-NRwLCdx-Y,11757
121
121
  utils/async_request.py,sha256=Lm2xGXLeph7P1_fLhhNJDhPubKT2ncFn_Ueft4JVoeI,255
122
122
  utils/exporter.py,sha256=HjcZCzcuH6N6f7Gn2hkTEeEFyo-MfrsiZUYAE-9kkVQ,9718
123
123
  utils/firebase_notifier.py,sha256=nAeCUo5Mtwxygwj8ONlw8ZAtL_ekdJBabvU0z2dZ3NY,2391
124
- utils/generate_email.py,sha256=_yHJiYp9dd1IT2lL2N2VmPrsCuKN30YTmE0votM9It8,1132
124
+ utils/generate_email.py,sha256=25i1iNVDfyRDq7vvZVFkaTYfMZFkAg1ZVQO2GdK7yRQ,1122
125
125
  utils/helpers.py,sha256=gNxLg09cclRWrKNBy2pwGZsxGA0iFS5iZ_nyra3SmnI,9928
126
126
  utils/hypercorn_config.py,sha256=q28HGRLWo9wjOVF183WwFPs3HQo4Nexc7q_7dmSVHRI,311
127
127
  utils/internal_error_code.py,sha256=KGlXPC5YruPmb0ORVY7U3EEVpBgSLuU4lHdXgwUVN2M,1637
@@ -130,20 +130,20 @@ utils/logger.py,sha256=peejQnq9B0eaHwdLynBHT7FUCq7jCX_DhkX6BcxrLkA,5274
130
130
  utils/middleware.py,sha256=PAVwnLzs0cyT_ZIgc1slqadEOJNCPliLhOTjaYx0Waw,3399
131
131
  utils/notification.py,sha256=O9oOeU9cRm3e9UAc-VJONWx-TzqbCMddFNaTQilE6ks,2479
132
132
  utils/password_hashing.py,sha256=NZZsmtPG9Vkocipk3DlDKKHKUdxRKA4yOhCurD8dUhg,356
133
- utils/plugin_manager.py,sha256=nIu99A8BWDhGerL880o5K9pCVQZbnjHJPNo1wQ_UbfU,7900
133
+ utils/plugin_manager.py,sha256=brQoE4u2WxH6EMvUOYQlnOnSUbKwha92-UfAgWUaHRU,7645
134
134
  utils/query_policies_helper.py,sha256=jBcNI_15P6LqVeWz6w9UMreLuNIc50GxqAf17KzxE84,4392
135
135
  utils/regex.py,sha256=cv9b_l_e8tz42mKckeeyDgypKqh2e71E28co2iuEVxA,2286
136
136
  utils/repository.py,sha256=9L-IvQ0Js0SQ5OR-Rh0i2Wdu4H9H06r8eE84hfBIu7Q,18313
137
137
  utils/router_helper.py,sha256=Tgoq3oakejdEeyeVieTNk38JsPZ8x5RuR0kw2THc1mI,604
138
- utils/settings.py,sha256=jKesIr67J9RP-QwrzsUQzXRAGjqpvYGUhmPuGY_GNpI,5639
138
+ utils/settings.py,sha256=SIunwTJF0Ac9fUWRt3sUsgWzMkWk0RUryEANYuOJQ9k,5660
139
139
  utils/sms_notifier.py,sha256=04D6D_ldk3S9SojI7_381pqLc8v9lligeNHAysohz7w,550
140
140
  utils/social_sso.py,sha256=Dm1W6U9OwKbAeUwM-kwJBHFEoreeoN-s-RHdOZ1-cNg,2216
141
141
  utils/ticket_sys_utils.py,sha256=9QAlW2iiy8KyxQRBDj_WmzS5kKb0aYJmGwd4qzmGVqo,7005
142
142
  utils/web_notifier.py,sha256=QM87VVid2grC5lK3NdS1yzz0z1wXljr4GChJOeK86W4,843
143
143
  utils/templates/activation.html.j2,sha256=XAMKCdoqONoc4ZQucD0yV-Pg5DlHHASZrTVItNS-iBE,640
144
144
  utils/templates/reminder.html.j2,sha256=aoS8bTs56q4hjAZKsb0jV9c-PIURBELuBOpT_qPZNVU,639
145
- dmart-0.1.9.dist-info/METADATA,sha256=Qoj8pMpyCZ9uJXFJxfuOeofT0WOWqlvGwW-vYUbql3s,2091
146
- dmart-0.1.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
147
- dmart-0.1.9.dist-info/entry_points.txt,sha256=GjfoGh1bpxuU9HHGJzbtCFPNptHv9TryxHMN3uBSKpg,37
148
- dmart-0.1.9.dist-info/top_level.txt,sha256=JTypu1r5v9v7ru-60JSSbnSMEESHFRMacpcz-rPJx_U,262
149
- dmart-0.1.9.dist-info/RECORD,,
145
+ dmart-1.4.0.dist-info/METADATA,sha256=vxNYgfiH0Y8TWKyFOmiXTx69CA-SOILtIqnt2Mj-7kY,2068
146
+ dmart-1.4.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
147
+ dmart-1.4.0.dist-info/entry_points.txt,sha256=GjfoGh1bpxuU9HHGJzbtCFPNptHv9TryxHMN3uBSKpg,37
148
+ dmart-1.4.0.dist-info/top_level.txt,sha256=JTypu1r5v9v7ru-60JSSbnSMEESHFRMacpcz-rPJx_U,262
149
+ dmart-1.4.0.dist-info/RECORD,,
languages/loader.py CHANGED
@@ -1,4 +1,3 @@
1
- import glob
2
1
  import json
3
2
  from pathlib import Path
4
3
 
@@ -69,7 +69,7 @@ class Plugin(PluginBase):
69
69
  retrieve_json_payload=True,
70
70
  space_name="management",
71
71
  subpath="notifications/system",
72
- search=f"@payload.body.on_space:{data.space_name} @payload.body.on_subpath:{data.subpath.lstrip("/")} @payload.body.on_action:{data.action_type}",
72
+ search=f"@payload.body.on_space:{data.space_name} @payload.body.on_subpath:{data.subpath.lstrip('/')} @payload.body.on_action:{data.action_type}",
73
73
  limit=30,
74
74
  offset=0
75
75
  ), "dmart")
@@ -11,22 +11,9 @@ from utils.settings import settings
11
11
  CUSTOM_PLUGINS_PATH = settings.spaces_folder / "custom_plugins"
12
12
 
13
13
  # Allow python to search for modules inside the custom plugins
14
- # be including the path to the parent folder of the custom plugins to sys.path
15
- back_out_of_project = 2
16
- back_to_spaces = 0
17
-
18
- for part in CUSTOM_PLUGINS_PATH.parts:
19
- if part == "..":
20
- back_to_spaces += 1
21
-
22
- if __file__.endswith(".pyc"):
23
- back_out_of_project += 1
24
-
25
- sys.path.append(
26
- "/".join(__file__.split("/")[:-(back_out_of_project+back_to_spaces)]) +
27
- "/" +
28
- "/".join(CUSTOM_PLUGINS_PATH.parts[back_to_spaces:-1])
29
- )
14
+ # by including the path to the parent folder of the custom plugins to sys.path
15
+ if CUSTOM_PLUGINS_PATH.parent.exists():
16
+ sys.path.append(str(CUSTOM_PLUGINS_PATH.parent.resolve()))
30
17
 
31
18
  def load_notification_plugin():
32
19
  # Load the plugin module
utils/generate_email.py CHANGED
@@ -1,4 +1,3 @@
1
- import os
2
1
  from jinja2 import Environment, FileSystemLoader
3
2
  from pathlib import Path
4
3
 
utils/plugin_manager.py CHANGED
@@ -21,22 +21,9 @@ from utils.settings import settings
21
21
  CUSTOM_PLUGINS_PATH = settings.spaces_folder / "custom_plugins"
22
22
 
23
23
  # Allow python to search for modules inside the custom plugins
24
- # be including the path to the parent folder of the custom plugins to sys.path
25
- back_out_of_project = 2
26
- back_to_spaces = 0
27
-
28
- for part in CUSTOM_PLUGINS_PATH.parts:
29
- if part == "..":
30
- back_to_spaces += 1
31
-
32
- if __file__.endswith(".pyc"):
33
- back_out_of_project += 1
34
-
35
- sys.path.append(
36
- "/".join(__file__.split("/")[:-(back_out_of_project+back_to_spaces)]) +
37
- "/" +
38
- "/".join(CUSTOM_PLUGINS_PATH.parts[back_to_spaces:-1])
39
- )
24
+ # by including the path to the parent folder of the custom plugins to sys.path
25
+ if CUSTOM_PLUGINS_PATH.parent.exists():
26
+ sys.path.append(str(CUSTOM_PLUGINS_PATH.parent.resolve()))
40
27
 
41
28
  class PluginManager:
42
29
 
utils/settings.py CHANGED
@@ -5,7 +5,6 @@ import os
5
5
  import re
6
6
  import string
7
7
  import random
8
- import sys
9
8
  from venv import logger
10
9
 
11
10
  from pydantic import Field
@@ -78,6 +77,7 @@ class Settings(BaseSettings):
78
77
  session_inactivity_ttl: int = 0 # Set initially to 0 to disable session timeout. Possible value : 60 * 60 * 24 * 7 # 7 days
79
78
  request_timeout: int = 35 # In seconds the time of dmart requests.
80
79
  jq_timeout: int = 2 # secs
80
+ is_sha_required: bool = False
81
81
 
82
82
  url_shorter_expires: int = 60 * 60 * 48 # 48 hours
83
83
 
@@ -157,7 +157,7 @@ try:
157
157
  Settings()
158
158
  )
159
159
  except Exception as e:
160
- # logger.error(f"Failed to load settings.\nError: {e}")
160
+ logger.error(f"Failed to load settings.\nError: {e}")
161
161
  # sys.exit(1)
162
162
  pass
163
163
 
File without changes