organizations-local 0.0.19__tar.gz → 0.0.21__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.19 → organizations_local-0.0.21}/PKG-INFO +5 -7
- {organizations_local-0.0.19 → organizations_local-0.0.21}/organizations_local/src/organizations_constants.py +0 -1
- organizations_local-0.0.21/organizations_local/src/organizations_local.py +177 -0
- {organizations_local-0.0.19 → organizations_local-0.0.21}/organizations_local.egg-info/PKG-INFO +5 -7
- organizations_local-0.0.21/organizations_local.egg-info/requires.txt +4 -0
- {organizations_local-0.0.19 → organizations_local-0.0.21}/pyproject.toml +1 -1
- {organizations_local-0.0.19 → organizations_local-0.0.21}/setup.py +5 -8
- organizations_local-0.0.19/organizations_local/src/organizations_local.py +0 -243
- organizations_local-0.0.19/organizations_local.egg-info/requires.txt +0 -6
- {organizations_local-0.0.19 → organizations_local-0.0.21}/README.md +0 -0
- {organizations_local-0.0.19 → organizations_local-0.0.21}/organizations_local/src/__init__.py +0 -0
- {organizations_local-0.0.19 → organizations_local-0.0.21}/organizations_local.egg-info/SOURCES.txt +0 -0
- {organizations_local-0.0.19 → organizations_local-0.0.21}/organizations_local.egg-info/dependency_links.txt +0 -0
- {organizations_local-0.0.19 → organizations_local-0.0.21}/organizations_local.egg-info/top_level.txt +0 -0
- {organizations_local-0.0.19 → organizations_local-0.0.21}/setup.cfg +0 -0
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: organizations-local
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.21
|
|
4
4
|
Summary: PyPI Package for Circles organizations-local Python
|
|
5
|
-
Home-page: https://github.com/circles-zone/
|
|
5
|
+
Home-page: https://github.com/circles-zone/organizations-local-python-package
|
|
6
6
|
Author: Circles
|
|
7
7
|
Author-email: info@circlez.ai
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: License :: Other/Proprietary License
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
|
-
Requires-Dist:
|
|
13
|
-
Requires-Dist:
|
|
14
|
-
Requires-Dist:
|
|
15
|
-
Requires-Dist: logzio-python-handler>=4.1.0
|
|
12
|
+
Requires-Dist: database-mysql-local>=0.0.290
|
|
13
|
+
Requires-Dist: language-remote>=0.0.20
|
|
14
|
+
Requires-Dist: location-local>=0.0.8
|
|
16
15
|
Requires-Dist: user-context-remote>=0.0.58
|
|
17
|
-
Requires-Dist: python-sdk-remote>=0.0.27
|
|
18
16
|
|
|
19
17
|
PyPI Package for Circles organizations-local Python
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
from database_mysql_local.generic_crud_ml import GenericCRUDML
|
|
2
|
+
from language_remote.lang_code import LangCode
|
|
3
|
+
from logger_local.MetaLogger import MetaLogger
|
|
4
|
+
from user_context_remote.user_context import UserContext
|
|
5
|
+
|
|
6
|
+
from .organizations_constants import ORGANIZATIONS_PYTHON_PACKAGE_CODE_LOGGER_OBJECT
|
|
7
|
+
|
|
8
|
+
user_context = UserContext()
|
|
9
|
+
|
|
10
|
+
DEFAULT_SCHEMA_NAME = "organization"
|
|
11
|
+
DEFAULT_TABLE_NAME = "organization_table"
|
|
12
|
+
DEFAULT_VIEW_NAME = "organization_view"
|
|
13
|
+
DEFAULT_ID_COLUMN_NAME = "organization_id"
|
|
14
|
+
DEFAULT_ML_TABLE_NAME = "organization_ml_table"
|
|
15
|
+
DEFAULT_ML_VIEW_NAME = "organization_ml_view"
|
|
16
|
+
DEFAULT_ML_ID_COLUMN_NAME = "organization_ml_id"
|
|
17
|
+
DEFAULT_NOT_DELETED_ML_VIEW_NAME = "organization_ml_not_deleted_view"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# "organization_table fields":
|
|
21
|
+
# "number",
|
|
22
|
+
# "identifier",
|
|
23
|
+
# "is_approved",
|
|
24
|
+
# "is_main",
|
|
25
|
+
# "point",
|
|
26
|
+
# "location_id",
|
|
27
|
+
# "profile_id",
|
|
28
|
+
# "parent_organization_id",
|
|
29
|
+
# "non_members_visibility_scope_id",
|
|
30
|
+
# "members_visibility_scope_id",
|
|
31
|
+
# "Non_members_visibility_profile_id",
|
|
32
|
+
# "is_test_data",
|
|
33
|
+
# "created_timestamp",
|
|
34
|
+
# "created_user_id",
|
|
35
|
+
# "created_real_user_id",
|
|
36
|
+
# "created_effective_user_id",
|
|
37
|
+
# "created_effective_profile_id",
|
|
38
|
+
# "updated_timestamp",
|
|
39
|
+
# "updated_user_id",
|
|
40
|
+
# "updated_real_user_id",
|
|
41
|
+
# "updated_effective_user_id",
|
|
42
|
+
# "updated_effective_profile_id",
|
|
43
|
+
# "start_timestamp",
|
|
44
|
+
# "end_timestamp",
|
|
45
|
+
# "main_group_id"
|
|
46
|
+
#
|
|
47
|
+
# organization_ml_table fields:
|
|
48
|
+
# "organization_ml_id",
|
|
49
|
+
# "organization_id",
|
|
50
|
+
# "lang_code",
|
|
51
|
+
# "is_main",
|
|
52
|
+
# "name",
|
|
53
|
+
# "is_title_approved",
|
|
54
|
+
# "is_description_approved",
|
|
55
|
+
# "description"
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class OrganizationsLocal(GenericCRUDML, metaclass=MetaLogger,
|
|
59
|
+
object=ORGANIZATIONS_PYTHON_PACKAGE_CODE_LOGGER_OBJECT):
|
|
60
|
+
def __init__(self, is_test_data=False) -> None:
|
|
61
|
+
GenericCRUDML.__init__(self, default_schema_name=DEFAULT_SCHEMA_NAME,
|
|
62
|
+
default_table_name=DEFAULT_TABLE_NAME,
|
|
63
|
+
default_column_name=DEFAULT_ID_COLUMN_NAME,
|
|
64
|
+
is_test_data=is_test_data)
|
|
65
|
+
self.default_view_table_name = DEFAULT_VIEW_NAME
|
|
66
|
+
|
|
67
|
+
@staticmethod
|
|
68
|
+
def _clean_organization_dict(organization_dict: dict) -> dict:
|
|
69
|
+
columns = ("name", "is_approved", "is_main", "point", "location_id", "profile_id", "parent_organization_id",
|
|
70
|
+
"non_members_visibility_scope_id", "members_visibility_scope_id",
|
|
71
|
+
"Non_members_visibility_profile_id", "main_group_id")
|
|
72
|
+
organization_dict = {key: organization_dict.get(key) for key in columns}
|
|
73
|
+
return organization_dict
|
|
74
|
+
|
|
75
|
+
@staticmethod
|
|
76
|
+
def _clean_organization_ml_dict(organization_dict: dict) -> dict:
|
|
77
|
+
columns = ("lang_code", "is_main", "title", "is_title_approved",
|
|
78
|
+
"is_description_approved", "description")
|
|
79
|
+
organization_ml_dict = {key: organization_dict.get(key) for key in columns}
|
|
80
|
+
return organization_ml_dict
|
|
81
|
+
|
|
82
|
+
# TODO: rename to insert? same for all
|
|
83
|
+
def insert_organization(self, organization_dict: dict) -> tuple[int, int]:
|
|
84
|
+
# This should be before chaning the organization_dict
|
|
85
|
+
organization_ml_data_dict = self._clean_organization_ml_dict(organization_dict)
|
|
86
|
+
|
|
87
|
+
organization_dict = self._clean_organization_dict(organization_dict)
|
|
88
|
+
organization_id = GenericCRUDML.insert(self, data_dict=organization_dict)
|
|
89
|
+
organization_ml_data_dict["organization_id"] = organization_id
|
|
90
|
+
organization_ml_id = GenericCRUDML.insert(self, table_name="organization_ml_table",
|
|
91
|
+
data_dict=organization_ml_data_dict)
|
|
92
|
+
|
|
93
|
+
return organization_id, organization_ml_id
|
|
94
|
+
|
|
95
|
+
def upsert_organization(self, organization_dict: dict, order_by: str = None) -> dict:
|
|
96
|
+
lang_code = LangCode.detect_lang_code(organization_dict.get('title'))
|
|
97
|
+
organization_ml_dict = self._clean_organization_ml_dict(organization_dict)
|
|
98
|
+
organization_dict = self._clean_organization_dict(organization_dict)
|
|
99
|
+
|
|
100
|
+
if "(" and ")" in organization_dict.get('title', ''):
|
|
101
|
+
organization_id, organzation_ml_ids_list = GenericCRUDML.upsert_value_with_abbreviations(
|
|
102
|
+
self, data_ml_dict=organization_ml_dict, lang_code=lang_code,
|
|
103
|
+
data_dict=organization_dict, schema_name=DEFAULT_SCHEMA_NAME, table_name=DEFAULT_TABLE_NAME,
|
|
104
|
+
ml_table_name=DEFAULT_ML_TABLE_NAME, order_by=order_by)
|
|
105
|
+
else:
|
|
106
|
+
organization_id, organzation_ml_id = GenericCRUDML.upsert_value(
|
|
107
|
+
self, data_ml_dict=organization_ml_dict, lang_code=lang_code,
|
|
108
|
+
data_dict=organization_dict, schema_name=DEFAULT_SCHEMA_NAME, table_name=DEFAULT_TABLE_NAME,
|
|
109
|
+
ml_table_name=DEFAULT_ML_TABLE_NAME, order_by=order_by)
|
|
110
|
+
organzation_ml_ids_list = [organzation_ml_id]
|
|
111
|
+
|
|
112
|
+
upsert_information = {
|
|
113
|
+
"organization_id": organization_id,
|
|
114
|
+
"organization_ml_ids_list": organzation_ml_ids_list
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return upsert_information
|
|
118
|
+
|
|
119
|
+
def update_organization(self, *, organization_id: int, organization_ml_id: int, organization_dict: dict) -> None:
|
|
120
|
+
# TODO: should we have such method in CRUD ML? same for delete
|
|
121
|
+
organization_ml_dict = self._clean_organization_ml_dict(organization_dict)
|
|
122
|
+
organization_ml_dict["organization_id"] = organization_id
|
|
123
|
+
organization_dict = self._clean_organization_dict(organization_dict)
|
|
124
|
+
GenericCRUDML.update_by_column_and_value(self, column_value=organization_id,
|
|
125
|
+
data_dict=organization_dict)
|
|
126
|
+
GenericCRUDML.update_by_column_and_value(self, table_name="organization_ml_table",
|
|
127
|
+
column_value=organization_ml_id, data_dict=organization_ml_dict,
|
|
128
|
+
column_name="organization_ml_id")
|
|
129
|
+
|
|
130
|
+
def get_organization_dict_by_organization_id(
|
|
131
|
+
self, *, organization_id: int, organization_ml_id: int = None, view_table_name: str = None) -> dict:
|
|
132
|
+
view_table_name = view_table_name or self.default_view_table_name
|
|
133
|
+
organization_ml_dict = {}
|
|
134
|
+
if organization_ml_id:
|
|
135
|
+
organization_ml_dict = self.select_one_dict_by_column_and_value(
|
|
136
|
+
view_table_name="organization_ml_view",
|
|
137
|
+
column_value=organization_ml_id, column_name="organization_ml_id")
|
|
138
|
+
organization_dict = self.select_one_dict_by_column_and_value(
|
|
139
|
+
view_table_name=view_table_name,
|
|
140
|
+
column_value=organization_id, column_name="organization_id")
|
|
141
|
+
|
|
142
|
+
return {**organization_dict, **organization_ml_dict}
|
|
143
|
+
|
|
144
|
+
def get_organizations_names_list_by_organizations_ids(
|
|
145
|
+
self, *, organizations_ids_list: list[int], lang_codes_list: list[LangCode] = None,
|
|
146
|
+
view_table_name: str = None) -> list[str]:
|
|
147
|
+
lang_codes_list = lang_codes_list or [LangCode.ENGLISH]
|
|
148
|
+
view_table_name = view_table_name or DEFAULT_ML_VIEW_NAME
|
|
149
|
+
organizations_names_list = []
|
|
150
|
+
for organization_id in organizations_ids_list:
|
|
151
|
+
organization_name_dicts = self.select_multi_dict_by_column_and_value(
|
|
152
|
+
view_table_name=view_table_name, select_clause_value="title, lang_code",
|
|
153
|
+
column_name="organization_id", column_value=organization_id)
|
|
154
|
+
|
|
155
|
+
# filter by lang_codes_list
|
|
156
|
+
# TODO: improve performance
|
|
157
|
+
for lang_code in lang_codes_list:
|
|
158
|
+
for organization_name_dict in organization_name_dicts:
|
|
159
|
+
if organization_name_dict.get('lang_code') == lang_code.value:
|
|
160
|
+
organizations_names_list.append(organization_name_dict.get('title'))
|
|
161
|
+
|
|
162
|
+
return organizations_names_list
|
|
163
|
+
|
|
164
|
+
def delete_by_organization_id(self, organization_id: int, organization_ml_id: int = None) -> None:
|
|
165
|
+
# Delete from organization_table
|
|
166
|
+
self.delete_by_column_and_value(table_name="organization_table",
|
|
167
|
+
column_name="organization_id", column_value=organization_id)
|
|
168
|
+
|
|
169
|
+
# Delete from organization_ml_table
|
|
170
|
+
if organization_ml_id:
|
|
171
|
+
self.delete_by_column_and_value(table_name="organization_ml_table",
|
|
172
|
+
column_name="organization_ml_id", column_value=organization_ml_id)
|
|
173
|
+
|
|
174
|
+
def get_test_organization_id(self) -> int:
|
|
175
|
+
test_organization_id = self.get_test_entity_id(
|
|
176
|
+
entity_name="organization", insert_function=self.insert_organization)
|
|
177
|
+
return test_organization_id
|
{organizations_local-0.0.19 → organizations_local-0.0.21}/organizations_local.egg-info/PKG-INFO
RENAMED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: organizations-local
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.21
|
|
4
4
|
Summary: PyPI Package for Circles organizations-local Python
|
|
5
|
-
Home-page: https://github.com/circles-zone/
|
|
5
|
+
Home-page: https://github.com/circles-zone/organizations-local-python-package
|
|
6
6
|
Author: Circles
|
|
7
7
|
Author-email: info@circlez.ai
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: License :: Other/Proprietary License
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
|
-
Requires-Dist:
|
|
13
|
-
Requires-Dist:
|
|
14
|
-
Requires-Dist:
|
|
15
|
-
Requires-Dist: logzio-python-handler>=4.1.0
|
|
12
|
+
Requires-Dist: database-mysql-local>=0.0.290
|
|
13
|
+
Requires-Dist: language-remote>=0.0.20
|
|
14
|
+
Requires-Dist: location-local>=0.0.8
|
|
16
15
|
Requires-Dist: user-context-remote>=0.0.58
|
|
17
|
-
Requires-Dist: python-sdk-remote>=0.0.27
|
|
18
16
|
|
|
19
17
|
PyPI Package for Circles organizations-local Python
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "organizations-local"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.16" # https://pypi.org/project/organizations-local
|
|
8
8
|
description = "organizations-local Python Package"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
@@ -5,13 +5,13 @@ package_dir = PACKAGE_NAME.replace("-", "_")
|
|
|
5
5
|
|
|
6
6
|
setuptools.setup(
|
|
7
7
|
name=PACKAGE_NAME,
|
|
8
|
-
version='0.0.
|
|
8
|
+
version='0.0.21', # 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
13
|
long_description_content_type='text/markdown',
|
|
14
|
-
url="https://github.com/circles-zone/
|
|
14
|
+
url=f"https://github.com/circles-zone/{PACKAGE_NAME}-python-package",
|
|
15
15
|
packages=[package_dir],
|
|
16
16
|
package_dir={package_dir: f'{package_dir}/src'},
|
|
17
17
|
package_data={package_dir: ['*.py']},
|
|
@@ -21,12 +21,9 @@ setuptools.setup(
|
|
|
21
21
|
"Operating System :: OS Independent",
|
|
22
22
|
],
|
|
23
23
|
install_requires=[
|
|
24
|
-
'
|
|
25
|
-
|
|
26
|
-
'
|
|
27
|
-
'mysql-connector>=2.2.9',
|
|
28
|
-
'logzio-python-handler>= 4.1.0',
|
|
24
|
+
'database-mysql-local>=0.0.290',
|
|
25
|
+
'language-remote>=0.0.20',
|
|
26
|
+
'location-local>=0.0.8',
|
|
29
27
|
'user-context-remote>=0.0.58',
|
|
30
|
-
'python-sdk-remote>=0.0.27',
|
|
31
28
|
],
|
|
32
29
|
)
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
from dotenv import load_dotenv
|
|
2
|
-
from logger_local.Logger import Logger
|
|
3
|
-
from .organizations_constants import ORGANIZATIONS_PYTHON_PACKAGE_CODE_LOGGER_OBJECT
|
|
4
|
-
from user_context_remote.user_context import UserContext
|
|
5
|
-
from database_mysql_local.generic_crud_ml import GenericCRUDML
|
|
6
|
-
from language_remote.lang_code import LangCode
|
|
7
|
-
load_dotenv()
|
|
8
|
-
|
|
9
|
-
logger = Logger(object=ORGANIZATIONS_PYTHON_PACKAGE_CODE_LOGGER_OBJECT)
|
|
10
|
-
user_context = UserContext()
|
|
11
|
-
|
|
12
|
-
DEFAULT_SCHEMA_NAME = "organization"
|
|
13
|
-
DEFAULT_TABLE_NAME = "organization_table"
|
|
14
|
-
DEFAULT_VIEW_NAME = "organization_view"
|
|
15
|
-
DEFAULT_ID_COLUMN_NAME = "organization_id"
|
|
16
|
-
DEFAULT_ML_TABLE_NAME = "organization_ml_table"
|
|
17
|
-
DEFAULT_ML_VIEW_NAME = "organization_ml_view"
|
|
18
|
-
DEFAULT_ML_ID_COLUMN_NAME = "organization_ml_id"
|
|
19
|
-
DEFAULT_NOT_DELETED_ML_VIEW_NAME = "organization_ml_not_deleted_view"
|
|
20
|
-
|
|
21
|
-
'''
|
|
22
|
-
"organization_table fields":
|
|
23
|
-
"number",
|
|
24
|
-
"identifier",
|
|
25
|
-
"is_approved",
|
|
26
|
-
"is_main",
|
|
27
|
-
"point",
|
|
28
|
-
"location_id",
|
|
29
|
-
"profile_id",
|
|
30
|
-
"parent_organization_id",
|
|
31
|
-
"non_members_visibility_scope_id",
|
|
32
|
-
"members_visibility_scope_id",
|
|
33
|
-
"Non_members_visibility_profile_id",
|
|
34
|
-
"is_test_data",
|
|
35
|
-
"created_timestamp",
|
|
36
|
-
"created_user_id",
|
|
37
|
-
"created_real_user_id",
|
|
38
|
-
"created_effective_user_id",
|
|
39
|
-
"created_effective_profile_id",
|
|
40
|
-
"updated_timestamp",
|
|
41
|
-
"updated_user_id",
|
|
42
|
-
"updated_real_user_id",
|
|
43
|
-
"updated_effective_user_id",
|
|
44
|
-
"updated_effective_profile_id",
|
|
45
|
-
"start_timestamp",
|
|
46
|
-
"end_timestamp",
|
|
47
|
-
"main_group_id"
|
|
48
|
-
|
|
49
|
-
organization_ml_table fields:
|
|
50
|
-
"organization_ml_id",
|
|
51
|
-
"organization_id",
|
|
52
|
-
"lang_code",
|
|
53
|
-
"is_main",
|
|
54
|
-
"name",
|
|
55
|
-
"is_name_approved",
|
|
56
|
-
"is_description_approved",
|
|
57
|
-
"description"
|
|
58
|
-
'''
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
class OrganizationsLocal(GenericCRUDML):
|
|
62
|
-
def __init__(self, default_schema_name=DEFAULT_SCHEMA_NAME, default_table_name=DEFAULT_TABLE_NAME,
|
|
63
|
-
default_id_column_name=DEFAULT_ID_COLUMN_NAME, is_test_data=False):
|
|
64
|
-
GenericCRUDML.__init__(self, default_schema_name=default_schema_name,
|
|
65
|
-
default_table_name=default_table_name,
|
|
66
|
-
default_id_column_name=default_id_column_name,
|
|
67
|
-
is_test_data=is_test_data)
|
|
68
|
-
self.default_view_table_name = DEFAULT_VIEW_NAME
|
|
69
|
-
|
|
70
|
-
def insert_organization(self, organization_dict: dict) -> tuple[int, int]:
|
|
71
|
-
logger.start(object={'data': str(organization_dict)})
|
|
72
|
-
# TODO I'm not sure we need the word "data"
|
|
73
|
-
organization_data_dict = {
|
|
74
|
-
"name": organization_dict.get('name'),
|
|
75
|
-
"is_approved": organization_dict.get('is_approved'),
|
|
76
|
-
"is_main": organization_dict.get('is_main'),
|
|
77
|
-
"point": organization_dict.get('point'),
|
|
78
|
-
"location_id": organization_dict.get('location_id'),
|
|
79
|
-
"profile_id": organization_dict.get('profile_id'),
|
|
80
|
-
"parent_organization_id": organization_dict.get('parent_organization_id'),
|
|
81
|
-
"non_members_visibility_scope_id": organization_dict.get('non_members_visibility_scope_id'),
|
|
82
|
-
"members_visibility_scope_id": organization_dict.get('members_visibility_scope_id'),
|
|
83
|
-
"Non_members_visibility_profile_id": organization_dict.get('Non_members_visibility_profile_id'),
|
|
84
|
-
"main_group_id": organization_dict.get('main_group_id')
|
|
85
|
-
}
|
|
86
|
-
organization_id = GenericCRUDML.insert(self, data_dict=organization_data_dict)
|
|
87
|
-
|
|
88
|
-
organization_ml_data_dict = {
|
|
89
|
-
"organization_id": organization_id,
|
|
90
|
-
"lang_code": organization_dict.get('lang_code'),
|
|
91
|
-
"is_main": organization_dict.get('is_main'),
|
|
92
|
-
"title": organization_dict.get('title'),
|
|
93
|
-
"is_name_approved": organization_dict.get('is_name_approved'),
|
|
94
|
-
"is_description_approved": organization_dict.get('is_description_approved'),
|
|
95
|
-
"description": organization_dict.get('description')
|
|
96
|
-
}
|
|
97
|
-
organization_ml_id = GenericCRUDML.insert(self, table_name="organization_ml_table",
|
|
98
|
-
data_dict=organization_ml_data_dict)
|
|
99
|
-
|
|
100
|
-
logger.end(object={'organization_id': organization_id,
|
|
101
|
-
'organization_ml_id': organization_ml_id})
|
|
102
|
-
return organization_id, organization_ml_id
|
|
103
|
-
|
|
104
|
-
def upsert_organization(self, organization_dict: dict, order_by: str = "") -> dict:
|
|
105
|
-
logger.start(object={'data': str(organization_dict)})
|
|
106
|
-
lang_code = LangCode.detect_lang_code(organization_dict.get('title'))
|
|
107
|
-
organization_data_dict = {
|
|
108
|
-
"name": organization_dict.get('name'),
|
|
109
|
-
"is_approved": organization_dict.get('is_approved'),
|
|
110
|
-
"is_main": organization_dict.get('is_main'),
|
|
111
|
-
"point": organization_dict.get('point'),
|
|
112
|
-
"location_id": organization_dict.get('location_id'),
|
|
113
|
-
"profile_id": organization_dict.get('profile_id'),
|
|
114
|
-
"parent_organization_id": organization_dict.get('parent_organization_id'),
|
|
115
|
-
"non_members_visibility_scope_id": organization_dict.get('non_members_visibility_scope_id'),
|
|
116
|
-
"members_visibility_scope_id": organization_dict.get('members_visibility_scope_id'),
|
|
117
|
-
"Non_members_visibility_profile_id": organization_dict.get('Non_members_visibility_profile_id'),
|
|
118
|
-
"main_group_id": organization_dict.get('main_group_id')
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
organization_ml_data_dict = {
|
|
122
|
-
"is_main": organization_dict.get('is_main'),
|
|
123
|
-
"title": organization_dict.get('title'),
|
|
124
|
-
"is_name_approved": organization_dict.get('is_name_approved'),
|
|
125
|
-
"is_description_approved": organization_dict.get('is_description_approved'),
|
|
126
|
-
"description": organization_dict.get('description')
|
|
127
|
-
}
|
|
128
|
-
if "(" and ")" in organization_dict.get('title'):
|
|
129
|
-
organization_id, organzation_ml_ids_list = GenericCRUDML.upsert_value_with_abbreviations(
|
|
130
|
-
self, data_ml_dict=organization_ml_data_dict,
|
|
131
|
-
lang_code=lang_code,
|
|
132
|
-
data_dict=organization_data_dict,
|
|
133
|
-
schema_name=DEFAULT_SCHEMA_NAME,
|
|
134
|
-
table_name=DEFAULT_TABLE_NAME,
|
|
135
|
-
ml_table_name=DEFAULT_ML_TABLE_NAME,
|
|
136
|
-
order_by=order_by
|
|
137
|
-
)
|
|
138
|
-
else:
|
|
139
|
-
organization_id, organzation_ml_id = GenericCRUDML.upsert_value(
|
|
140
|
-
self, data_ml_dict=organization_ml_data_dict,
|
|
141
|
-
lang_code=lang_code,
|
|
142
|
-
data_dict=organization_data_dict,
|
|
143
|
-
schema_name=DEFAULT_SCHEMA_NAME,
|
|
144
|
-
table_name=DEFAULT_TABLE_NAME,
|
|
145
|
-
ml_table_name=DEFAULT_ML_TABLE_NAME,
|
|
146
|
-
order_by=order_by
|
|
147
|
-
)
|
|
148
|
-
organzation_ml_ids_list = [organzation_ml_id]
|
|
149
|
-
|
|
150
|
-
upsert_information = {
|
|
151
|
-
"organization_id": organization_id,
|
|
152
|
-
"organization_ml_ids_list": organzation_ml_ids_list
|
|
153
|
-
}
|
|
154
|
-
logger.end(object={'organization_id': organization_id,
|
|
155
|
-
'organzation_ml_ids_list': organzation_ml_ids_list})
|
|
156
|
-
return upsert_information
|
|
157
|
-
|
|
158
|
-
def update_organization(self, organization_id: int, organization_ml_id: int, organization_dict: dict) -> None:
|
|
159
|
-
logger.start(object={'organization_id': organization_id, 'data': str(organization_dict)})
|
|
160
|
-
organization_data_dict = {
|
|
161
|
-
"name": organization_dict.get('name'),
|
|
162
|
-
"is_approved": organization_dict.get('is_approved'),
|
|
163
|
-
"is_main": organization_dict.get('is_main'),
|
|
164
|
-
"point": organization_dict.get('point'),
|
|
165
|
-
"location_id": organization_dict.get('location_id'),
|
|
166
|
-
"profile_id": organization_dict.get('profile_id'),
|
|
167
|
-
"parent_organization_id": organization_dict.get('parent_organization_id'),
|
|
168
|
-
"non_members_visibility_scope_id": organization_dict.get('non_members_visibility_scope_id'),
|
|
169
|
-
"members_visibility_scope_id": organization_dict.get('members_visibility_scope_id'),
|
|
170
|
-
"Non_members_visibility_profile_id": organization_dict.get('Non_members_visibility_profile_id'),
|
|
171
|
-
"main_group_id": organization_dict.get('main_group_id')
|
|
172
|
-
}
|
|
173
|
-
GenericCRUDML.update_by_id(self, id_column_value=organization_id,
|
|
174
|
-
data_dict=organization_data_dict)
|
|
175
|
-
|
|
176
|
-
organization_ml_data_dict = {
|
|
177
|
-
"organization_id": organization_id,
|
|
178
|
-
"lang_code": organization_dict.get('lang_code'),
|
|
179
|
-
"is_main": organization_dict.get('is_main'),
|
|
180
|
-
"title": organization_dict.get('title'),
|
|
181
|
-
"is_name_approved": organization_dict.get('is_name_approved'),
|
|
182
|
-
"is_description_approved": organization_dict.get('is_description_approved'),
|
|
183
|
-
"description": organization_dict.get('description')
|
|
184
|
-
}
|
|
185
|
-
GenericCRUDML.update_by_id(self, table_name="organization_ml_table",
|
|
186
|
-
id_column_value=organization_ml_id, data_dict=organization_ml_data_dict,
|
|
187
|
-
id_column_name="organization_ml_id")
|
|
188
|
-
logger.end()
|
|
189
|
-
|
|
190
|
-
def get_organization_dict_by_organization_id(self, organization_id: int, organization_ml_id: int = None,
|
|
191
|
-
view_table_name: str = None) -> dict:
|
|
192
|
-
logger.start(object={'organization_id': organization_id})
|
|
193
|
-
view_table_name = view_table_name or self.default_view_table_name
|
|
194
|
-
organization_ml_dict = {}
|
|
195
|
-
if organization_ml_id:
|
|
196
|
-
organization_ml_dict = self.select_one_dict_by_id(view_table_name="organization_ml_view",
|
|
197
|
-
id_column_value=organization_ml_id,
|
|
198
|
-
id_column_name="organization_ml_id")
|
|
199
|
-
organization_dict = self.select_one_dict_by_id(view_table_name=view_table_name, id_column_value=organization_id,
|
|
200
|
-
id_column_name="organization_id")
|
|
201
|
-
logger.end(object={'organization_ml_dict': str(organization_ml_dict)})
|
|
202
|
-
return {**organization_dict, **organization_ml_dict}
|
|
203
|
-
|
|
204
|
-
def get_organizations_names_list_by_organizations_ids(self, organizations_ids_list: list[int],
|
|
205
|
-
lang_codes_list: list[LangCode] = None,
|
|
206
|
-
view_table_name: str = None) -> list[str]:
|
|
207
|
-
logger.start(object={'organizations_ids_list': organizations_ids_list})
|
|
208
|
-
if lang_codes_list is None:
|
|
209
|
-
lang_codes_list = [LangCode.ENGLISH]
|
|
210
|
-
view_table_name = view_table_name or DEFAULT_ML_VIEW_NAME
|
|
211
|
-
organizations_names_list = []
|
|
212
|
-
for organization_id in organizations_ids_list:
|
|
213
|
-
organization_name_dicts = self.select_multi_dict_by_id(
|
|
214
|
-
view_table_name=view_table_name,
|
|
215
|
-
select_clause_value="title, lang_code",
|
|
216
|
-
id_column_name="organization_id",
|
|
217
|
-
id_column_value=organization_id
|
|
218
|
-
)
|
|
219
|
-
# filter by lang_codes_list
|
|
220
|
-
for lang_code in lang_codes_list:
|
|
221
|
-
for organization_name_dict in organization_name_dicts:
|
|
222
|
-
if organization_name_dict.get('lang_code') == lang_code.value:
|
|
223
|
-
organization_name = organization_name_dict.get('title')
|
|
224
|
-
organizations_names_list.append(organization_name)
|
|
225
|
-
logger.end(object={'organizations_names_list': str(organizations_names_list)})
|
|
226
|
-
return organizations_names_list
|
|
227
|
-
|
|
228
|
-
def delete_by_organization_id(self, organization_id: int, organization_ml_id: int = None) -> None:
|
|
229
|
-
logger.start(object={'organization_id': organization_id})
|
|
230
|
-
# Delete from organization_table
|
|
231
|
-
self.delete_by_id(table_name="organization_table",
|
|
232
|
-
id_column_name="organization_id", id_column_value=organization_id)
|
|
233
|
-
# Delete from organization_ml_table
|
|
234
|
-
if organization_ml_id:
|
|
235
|
-
self.delete_by_id(table_name="organization_ml_table", id_column_name="organization_ml_id",
|
|
236
|
-
id_column_value=organization_ml_id)
|
|
237
|
-
logger.end()
|
|
238
|
-
|
|
239
|
-
def get_test_organization_id(self) -> int:
|
|
240
|
-
return self.get_test_entity_id(
|
|
241
|
-
entity_name="organization",
|
|
242
|
-
insert_function=self.insert_organization
|
|
243
|
-
)
|
|
File without changes
|
{organizations_local-0.0.19 → organizations_local-0.0.21}/organizations_local/src/__init__.py
RENAMED
|
File without changes
|
{organizations_local-0.0.19 → organizations_local-0.0.21}/organizations_local.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{organizations_local-0.0.19 → organizations_local-0.0.21}/organizations_local.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|