organizations-local 0.0.49__tar.gz → 0.0.50__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.
- {organizations_local-0.0.49 → organizations_local-0.0.50}/PKG-INFO +1 -1
- organizations_local-0.0.50/organizations_local/src/organizations_constants.py +19 -0
- {organizations_local-0.0.49 → organizations_local-0.0.50}/organizations_local/src/organizations_local.py +70 -36
- {organizations_local-0.0.49 → organizations_local-0.0.50}/organizations_local.egg-info/PKG-INFO +1 -1
- {organizations_local-0.0.49 → organizations_local-0.0.50}/setup.py +8 -8
- organizations_local-0.0.49/organizations_local/src/organizations_constants.py +0 -19
- {organizations_local-0.0.49 → organizations_local-0.0.50}/README.md +0 -0
- {organizations_local-0.0.49 → organizations_local-0.0.50}/organizations_local/src/__init__.py +0 -0
- {organizations_local-0.0.49 → organizations_local-0.0.50}/organizations_local.egg-info/SOURCES.txt +0 -0
- {organizations_local-0.0.49 → organizations_local-0.0.50}/organizations_local.egg-info/dependency_links.txt +0 -0
- {organizations_local-0.0.49 → organizations_local-0.0.50}/organizations_local.egg-info/requires.txt +0 -0
- {organizations_local-0.0.49 → organizations_local-0.0.50}/organizations_local.egg-info/top_level.txt +0 -0
- {organizations_local-0.0.49 → organizations_local-0.0.50}/pyproject.toml +0 -0
- {organizations_local-0.0.49 → organizations_local-0.0.50}/setup.cfg +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from logger_local.LoggerComponentEnum import LoggerComponentEnum
|
|
2
|
+
|
|
3
|
+
ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_ID = 286
|
|
4
|
+
ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_NAME = "organization-local-python-package"
|
|
5
|
+
DEVELOPER_EMAIL = "tal.g@circ.zone"
|
|
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,
|
|
11
|
+
}
|
|
12
|
+
|
|
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,
|
|
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(
|
|
61
|
-
|
|
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__(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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",
|
|
72
|
-
"
|
|
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 = (
|
|
80
|
-
|
|
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 =
|
|
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,
|
|
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(
|
|
93
|
-
|
|
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,
|
|
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
|
|
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
|
|
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(
|
|
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,
|
|
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
|
-
|
|
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 =
|
|
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
|
|
254
|
+
main_profile_id: int | None) -> list[dict]:
|
|
230
255
|
if main_profile_id is None:
|
|
231
|
-
update_status_and_information_list = [
|
|
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] =
|
|
236
|
-
|
|
237
|
-
|
|
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 =
|
|
248
|
-
|
|
249
|
-
|
|
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 = {
|
|
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
|
|
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
|
|
@@ -5,25 +5,25 @@ package_dir = PACKAGE_NAME.replace("-", "_")
|
|
|
5
5
|
|
|
6
6
|
setuptools.setup(
|
|
7
7
|
name=PACKAGE_NAME,
|
|
8
|
-
version='0.0.
|
|
8
|
+
version='0.0.50', # https://pypi.org/project/organizations-local/
|
|
9
9
|
author="Circles",
|
|
10
10
|
author_email="info@circlez.ai",
|
|
11
11
|
description="PyPI Package for Circles organizations-local Python",
|
|
12
12
|
long_description="PyPI Package for Circles organizations-local Python",
|
|
13
|
-
long_description_content_type=
|
|
13
|
+
long_description_content_type="text/markdown",
|
|
14
14
|
url=f"https://github.com/circles-zone/{PACKAGE_NAME}-python-package",
|
|
15
15
|
packages=[package_dir],
|
|
16
|
-
package_dir={package_dir: f
|
|
17
|
-
package_data={package_dir: [
|
|
16
|
+
package_dir={package_dir: f"{package_dir}/src"},
|
|
17
|
+
package_data={package_dir: ["*.py"]},
|
|
18
18
|
classifiers=[
|
|
19
19
|
"Programming Language :: Python :: 3",
|
|
20
20
|
# "License :: Other/Proprietary License",
|
|
21
21
|
"Operating System :: OS Independent",
|
|
22
22
|
],
|
|
23
23
|
install_requires=[
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
"database-mysql-local>=0.0.290",
|
|
25
|
+
"language-remote>=0.0.20",
|
|
26
|
+
"location-local>=0.0.8",
|
|
27
|
+
"user-context-remote>=0.0.58",
|
|
28
28
|
],
|
|
29
29
|
)
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
from logger_local.LoggerComponentEnum import LoggerComponentEnum
|
|
2
|
-
|
|
3
|
-
ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_ID = 286
|
|
4
|
-
ORGANIZATIONS_LOCAL_PYTHON_COMPONENT_NAME = "organization-local-python-package"
|
|
5
|
-
DEVELOPER_EMAIL = "tal.g@circ.zone"
|
|
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
|
|
11
|
-
}
|
|
12
|
-
|
|
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
|
|
19
|
-
}
|
|
File without changes
|
{organizations_local-0.0.49 → organizations_local-0.0.50}/organizations_local/src/__init__.py
RENAMED
|
File without changes
|
{organizations_local-0.0.49 → organizations_local-0.0.50}/organizations_local.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{organizations_local-0.0.49 → organizations_local-0.0.50}/organizations_local.egg-info/requires.txt
RENAMED
|
File without changes
|
{organizations_local-0.0.49 → organizations_local-0.0.50}/organizations_local.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|