organizations-local 0.0.49__py3-none-any.whl → 0.0.50__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.
@@ -4,16 +4,16 @@ ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_ID = 286
4
4
  ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_NAME = "organization-local-python-package"
5
5
  DEVELOPER_EMAIL = "tal.g@circ.zone"
6
6
  ORGANIZATIONS_PYTHON_PACKAGE_CODE_LOGGER_OBJECT = {
7
- 'component_id': ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_ID,
8
- 'component_name': ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_NAME,
9
- 'component_category': LoggerComponentEnum.ComponentCategory.Code.value,
10
- 'developer_email': DEVELOPER_EMAIL
7
+ "component_id": ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_ID,
8
+ "component_name": ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_NAME,
9
+ "component_category": LoggerComponentEnum.ComponentCategory.Code.value,
10
+ "developer_email": DEVELOPER_EMAIL,
11
11
  }
12
12
 
13
13
  ORGANIZATIONS_PYTHON_PACKAGE_TEST_LOGGER_OBJECT = {
14
- 'component_id': ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_ID,
15
- 'component_name': ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_NAME,
16
- 'component_category': LoggerComponentEnum.ComponentCategory.Unit_Test.value,
17
- 'testing_framework': LoggerComponentEnum.testingFramework.pytest.value,
18
- 'developer_email': DEVELOPER_EMAIL
14
+ "component_id": ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_ID,
15
+ "component_name": ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_NAME,
16
+ "component_category": LoggerComponentEnum.ComponentCategory.Unit_Test.value,
17
+ "testing_framework": LoggerComponentEnum.testingFramework.pytest.value,
18
+ "developer_email": DEVELOPER_EMAIL,
19
19
  }
@@ -57,53 +57,74 @@ DEFAULT_NOT_DELETED_ML_VIEW_NAME = "organization_ml_not_deleted_view"
57
57
  # "description"
58
58
 
59
59
 
60
- class OrganizationsLocal(GenericCRUDML, metaclass=MetaLogger,
61
- object=ORGANIZATIONS_PYTHON_PACKAGE_CODE_LOGGER_OBJECT):
60
+ class OrganizationsLocal(
61
+ GenericCRUDML,
62
+ metaclass=MetaLogger,
63
+ object=ORGANIZATIONS_PYTHON_PACKAGE_CODE_LOGGER_OBJECT,
64
+ ):
62
65
  def __init__(self, is_test_data=False) -> None:
63
- GenericCRUDML.__init__(self, default_schema_name=DEFAULT_SCHEMA_NAME,
64
- default_table_name=DEFAULT_TABLE_NAME,
65
- default_column_name=DEFAULT_ID_COLUMN_NAME,
66
- is_test_data=is_test_data)
66
+ GenericCRUDML.__init__(
67
+ self,
68
+ default_schema_name=DEFAULT_SCHEMA_NAME,
69
+ default_table_name=DEFAULT_TABLE_NAME,
70
+ default_column_name=DEFAULT_ID_COLUMN_NAME,
71
+ is_test_data=is_test_data,
72
+ )
67
73
  self.default_view_table_name = DEFAULT_VIEW_NAME
68
74
 
69
75
  @staticmethod
70
76
  def _clean_organization_dict(organization_dict: dict) -> dict:
71
- columns = ("name", "is_approved", "is_main", "point", "location_id", "profile_id", "parent_organization_id",
72
- "non_members_visibility_scope_id", "members_visibility_scope_id",
77
+ columns = ("name", "is_approved", "is_main", "point", "location_id",
78
+ "profile_id", "parent_organization_id",
79
+ "non_members_visibility_scope_id",
80
+ "members_visibility_scope_id",
73
81
  "Non_members_visibility_profile_id", "main_group_id")
74
82
  organization_dict = {key: organization_dict.get(key) for key in columns}
75
83
  return organization_dict
76
84
 
77
85
  @staticmethod
78
86
  def _clean_organization_ml_dict(organization_dict: dict) -> dict:
79
- columns = ("lang_code", "is_main", "title", "is_title_approved",
80
- "is_description_approved", "description")
87
+ columns = (
88
+ "lang_code",
89
+ "is_main",
90
+ "title",
91
+ "is_title_approved",
92
+ "is_description_approved",
93
+ "description",
94
+ )
81
95
  organization_ml_dict = {key: organization_dict.get(key) for key in columns}
82
96
  return organization_ml_dict
83
97
 
84
98
  # TODO: rename to insert? same for all
85
99
  def insert_organization(self, organization_dict: dict) -> tuple[int, int]:
86
100
  # This should be before chaning the organization_dict
87
- organization_ml_data_dict = self._clean_organization_ml_dict(organization_dict)
101
+ organization_ml_data_dict = \
102
+ self._clean_organization_ml_dict(organization_dict)
88
103
 
89
104
  organization_dict = self._clean_organization_dict(organization_dict)
90
- organization_id = GenericCRUDML.insert(self, data_dict=organization_dict)
105
+ organization_id = GenericCRUDML.insert(self,
106
+ data_dict=organization_dict)
91
107
  organization_ml_data_dict["organization_id"] = organization_id
92
- organization_ml_id = GenericCRUDML.insert(self, table_name="organization_ml_table",
93
- data_dict=organization_ml_data_dict)
108
+ organization_ml_id = GenericCRUDML.insert(
109
+ self, table_name="organization_ml_table",
110
+ data_dict=organization_ml_data_dict)
94
111
 
95
112
  return organization_id, organization_ml_id
96
113
 
97
- def upsert_organization(self, organization_dict: dict, order_by: str = None) -> dict:
114
+ def upsert_organization(self, organization_dict: dict,
115
+ order_by: str = None) -> dict:
98
116
  lang_code = LangCode.detect_lang_code_restricted(
99
117
  text=organization_dict.get('title'),
100
- # TODO the lang code can be in the organization_dict or in the UserContext, I'm not sure English as default is correct
118
+ # TODO the lang code can be in the organization_dict or in the
119
+ # UserContext, I'm not sure English as default is correct
101
120
  default_lang_code=LangCode.ENGLISH)
102
121
  organization_ml_dict = self._clean_organization_ml_dict(
103
122
  organization_dict)
104
123
  organization_dict = self._clean_organization_dict(organization_dict)
105
124
 
106
- # TODO Why do we need to do this if outside of GenericCrud in every entity, can we move this "if" into the Generic Crud method? Can we avoid two methods? The parameters of the two methods are the same?
125
+ # TODO Why do we need to do this if outside of GenericCrud in every
126
+ # entity, can we move this "if" into the Generic Crud method? Can we
127
+ # avoid two methods? The parameters of the two methods are the same?
107
128
  if "(" and ")" in organization_dict.get('title', ''):
108
129
  organization_id, organzation_ml_ids_list =\
109
130
  GenericCRUDML.upsert_value_with_abbreviations(
@@ -124,12 +145,14 @@ class OrganizationsLocal(GenericCRUDML, metaclass=MetaLogger,
124
145
  # TODO upsert_result_dict
125
146
  upsert_information = {
126
147
  "organization_id": organization_id,
127
- "organization_ml_ids_list": organzation_ml_ids_list
148
+ "organization_ml_ids_list": organzation_ml_ids_list,
128
149
  }
129
150
 
130
151
  return upsert_information
131
152
 
132
- def update_organization(self, *, organization_id: int, organization_ml_id: int, organization_dict: dict) -> None:
153
+ def update_organization(
154
+ self, *, organization_id: int, organization_ml_id: int, organization_dict: dict
155
+ ) -> None:
133
156
  # TODO: should we have such a method in CRUD ML? Same for delete
134
157
  organization_ml_dict = self._clean_organization_ml_dict(
135
158
  organization_dict)
@@ -155,7 +178,9 @@ class OrganizationsLocal(GenericCRUDML, metaclass=MetaLogger,
155
178
  column_name="organization_ml_id")
156
179
  organization_dict = self.select_one_dict_by_column_and_value(
157
180
  view_table_name=view_table_name,
158
- column_value=organization_id, column_name="organization_id")
181
+ column_value=organization_id,
182
+ column_name="organization_id",
183
+ )
159
184
 
160
185
  return {**organization_dict, **organization_ml_dict}
161
186
 
@@ -179,7 +204,7 @@ class OrganizationsLocal(GenericCRUDML, metaclass=MetaLogger,
179
204
  for lang_code in lang_codes_list:
180
205
  for organization_name_dict in organization_name_dicts:
181
206
  if organization_name_dict.get('lang_code') ==\
182
- lang_code.value:
207
+ lang_code.value:
183
208
  organizations_names_list.append(
184
209
  organization_name_dict.get('title'))
185
210
 
@@ -194,7 +219,7 @@ class OrganizationsLocal(GenericCRUDML, metaclass=MetaLogger,
194
219
  view_table_name = view_table_name or DEFAULT_ML_VIEW_NAME
195
220
  organizations_ids_and_names_list = []
196
221
  select_clause_value = "organization_id, title"
197
- placeholders = ', '.join(['%s'] * len(organizations_ids_list))
222
+ placeholders = ", ".join(["%s"] * len(organizations_ids_list))
198
223
  where_clause_value = f"organization_id in ({placeholders})"
199
224
  organizations_ids_and_names_list = self.select_multi_tuple_by_where(
200
225
  view_table_name=view_table_name,
@@ -226,15 +251,20 @@ class OrganizationsLocal(GenericCRUDML, metaclass=MetaLogger,
226
251
  # Was def get_update_status(self, *, last_modified_timestamp: str, main_profile_id: int) -> UpdateStatus:
227
252
  def get_update_status_and_information_list(self, *,
228
253
  last_modified_timestamp: str,
229
- main_profile_id: int or None) -> list[dict]:
254
+ main_profile_id: int | None) -> list[dict]:
230
255
  if main_profile_id is None:
231
- update_status_and_information_list = [{"update_status": UpdateStatus.UPDATE_CIRCLEZ}]
256
+ update_status_and_information_list = [
257
+ {"update_status": UpdateStatus.UPDATE_CIRCLEZ}
258
+ ]
232
259
  return update_status_and_information_list
233
260
  sync_conflict_resolution = SyncConflictResolution()
234
261
  # TODO: Shall we also check update_timestamp in organization_table to see if the name was changed?
235
- update_status_and_information_list: list[dict] = sync_conflict_resolution.get_update_status_and_information_list_by_where(
236
- schema_name="organization_profile", view_table_name="organization_profile_view",
237
- where="profile_id = %s", params=(main_profile_id,), local_last_modified_column_name="updated_timestamp",
262
+ update_status_and_information_list: list[dict] = \
263
+ sync_conflict_resolution.get_update_status_and_information_list_by_where(
264
+ schema_name="organization_profile",
265
+ view_table_name="organization_profile_view",
266
+ where="profile_id = %s", params=(main_profile_id,),
267
+ local_last_modified_column_name="updated_timestamp",
238
268
  remote_last_modified_timestamp=last_modified_timestamp)
239
269
  # Add organization_names to update_status_and_information_list
240
270
  # TODO: Can we use a list of only the updated organization since the last sync?
@@ -244,23 +274,27 @@ class OrganizationsLocal(GenericCRUDML, metaclass=MetaLogger,
244
274
  if organization_id is not None:
245
275
  organizations_ids_list.append(organization_id)
246
276
 
247
- organizations_ids_and_names_list = self.get_organizations_ids_and_names_list_by_organizations_ids(
248
- organizations_ids_list=organizations_ids_list,
249
- view_table_name="organization_ml_view")
277
+ organizations_ids_and_names_list = (
278
+ self.get_organizations_ids_and_names_list_by_organizations_ids(
279
+ organizations_ids_list=organizations_ids_list,
280
+ view_table_name="organization_ml_view",
281
+ )
282
+ )
250
283
 
251
284
  # Convert organizations_ids_and_names_list to a dictionary
252
- organizations_ids_and_names_dict = {item[0]: item[1] for item in organizations_ids_and_names_list}
285
+ organizations_ids_and_names_dict = {
286
+ item[0]: item[1] for item in organizations_ids_and_names_list
287
+ }
253
288
 
254
289
  for update_status_and_information in update_status_and_information_list:
255
290
  organization_id = update_status_and_information.get("organization_id")
256
291
  if organization_id is not None:
257
292
  update_status_and_information["organization_name"] = organizations_ids_and_names_dict.get(organization_id)
258
-
259
- return update_status_and_information_list
260
293
 
294
+ return update_status_and_information_list
261
295
 
262
- def get_organization_name_by_organization_identifier(self, organization_identifier: str) -> str or None:
263
- organization_name=self.select_one_value_by_column_and_value(
296
+ def get_organization_name_by_organization_identifier(self, organization_identifier: str) -> str | None:
297
+ organization_name = self.select_one_value_by_column_and_value(
264
298
  select_clause_value="name",
265
299
  schema_name="organization",
266
300
  view_table_name="organization_view",
@@ -268,4 +302,4 @@ class OrganizationsLocal(GenericCRUDML, metaclass=MetaLogger,
268
302
  column_value=organization_identifier,
269
303
  )
270
304
 
271
- return organization_name
305
+ return organization_name
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: organizations-local
3
- Version: 0.0.49
3
+ Version: 0.0.50
4
4
  Summary: PyPI Package for Circles organizations-local Python
5
5
  Home-page: https://github.com/circles-zone/organizations-local-python-package
6
6
  Author: Circles
@@ -0,0 +1,7 @@
1
+ organizations_local/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ organizations_local/organizations_constants.py,sha256=mh_XncG0Q8-k_VUCHWVQRdlMXNnf_GCiCcL-rn7R3lw,902
3
+ organizations_local/organizations_local.py,sha256=Ynxtqf_8a4VK42iFbEUM7fIlLwD9AM1xldX7X7SUrXQ,14103
4
+ organizations_local-0.0.50.dist-info/METADATA,sha256=B6aSAUbcy9fKwBaIQ_xw10Top8WFAiQ_0SFwfogGNq4,773
5
+ organizations_local-0.0.50.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
6
+ organizations_local-0.0.50.dist-info/top_level.txt,sha256=Y8wRcm3jFTyMdysBub_P8iqX1VOMS0ohUxA1GQdngFU,20
7
+ organizations_local-0.0.50.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.4.0)
2
+ Generator: setuptools (80.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,7 +0,0 @@
1
- organizations_local/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- organizations_local/organizations_constants.py,sha256=pxyAMmv4BFCfzyDsF92vImLdazA7_0ecKyVmOR9peEE,900
3
- organizations_local/organizations_local.py,sha256=I2G3_8zFkBIoE-4PbPB83SZhHN2Gx9v2pjiFwSmI2b4,13769
4
- organizations_local-0.0.49.dist-info/METADATA,sha256=PAI7FwUaP8DiMLAxOG_JU-rIUfogjme6AYA1Gv6SLv0,773
5
- organizations_local-0.0.49.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
6
- organizations_local-0.0.49.dist-info/top_level.txt,sha256=Y8wRcm3jFTyMdysBub_P8iqX1VOMS0ohUxA1GQdngFU,20
7
- organizations_local-0.0.49.dist-info/RECORD,,